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++); } }
Question
Tawachi
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.
**********************************************************************/
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.