• 0

MPLABX IDE Tutorial Project not Working


Go to solution Solved by mskreen,

Question

Hi,

I went through the MPLAB X IDE tutorial. I then changed the product properties to suit my device (PIC32MZ2048ECG100) and debugger (Chipkit PGM). I also changed the port to PortB where user-LED 3 is connected (RB11). When I debug using Simulator, the variables change as they should. However when I program the device, LED3 does not light up as it should. So I also added ANSELB =0 statement to make it a digital port. But still nothing happens.  I have exhausted all possible causes I could think of. I would appreciate any ideas. Below is the code, Thanks.

 

#include <xc.h>

#pragma config FWDTEN = OFF, JTAGEN = OFF

void delay(void);

unsigned int ctr = 0;
unsigned int delayVal = 2048;

int main(void)
{
    LATB= 0;  //LED 3 is connected to RB11
    TRISB = 0x0000; //set the lower sixteen bits of a port as output ports by 
                    //setting the lower eight bits to zero
    ANSELB=0; //set port B as digital

    while(1) //infinite loop
    {
        LATB = 0b0000000000000000; // assigns 0 to the lower 11th bit of LATB register
        delay();

        LATB = 0b0000100000000000; // assigns to the lower 11th bit of LATB register
        delay();

        ctr++;
    }
}

void delay(void) //controls the amount of time that the values appear
{
    unsigned int i,j;

    for (i = 0; i < delayVal; i++)
    {
        for (j = 0; j < 20; j++);
    }
}

 

/**********************************************************************
* © 2013 Microchip Technology Inc.
* SOFTWARE LICENSE AGREEMENT:
* Microchip Technology Inc. (Microchip) licenses this software to you
* solely for use with Microchip dsPIC digital signal controller
* products. The software is owned by Microchip and is protected under
* applicable copyright laws.  All rights reserved.
*
* SOFTWARE IS PROVIDED AS IS.  MICROCHIP EXPRESSLY DISCLAIMS ANY
* WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP
* BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL
* DAMAGES, LOST PROFITS OR LOST DATA, HARM TO YOUR EQUIPMENT, COST OF
* PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
* BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
* ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS.
**********************************************************************/

Edited by KaitlynFranz
Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0
  • Solution

Hello Tawachi,

I copy and pasted your code into a new project and it worked just fine. I am using the same chip (PIC32MZ2048ECG100) along with the ChipKit Programmer. Are you plugging your ChipKit PGM into the correct port (JP1)? This is what my board configuration looks like: https://forum.digilentinc.com/gallery/image/40-chipkit_wi-firejpg/

Edited by mskreen
Link to post
Share on other sites
  • 0

Hi Mskreen,

Thank you for confirming that the code works fine.

I am developing using Imaginations Flowcloud. I tried again the same code but this time using the Flowcloud Skeleton App and it worked fine. Previously I was using the Flowcloud starter app and it could not work. I guess it is something to do with the Flowcloud Starter app code which I have to figure out.

Thanks you so much.

Regards, Tawachi.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now