aj9999
Junior Member level 3
I am using MPLAB/C30 with an explorer16 board and a PIC24fj128GA010 PIM. I am attempting to flash the LEDs attached to port A. I can flash any of the LEDs independently but when I try to flash more than one of them only the first one listed in the code will work. In the code below RA0 will flash but not RA1. If I reverse the order so that RA1 is first then RA0 will work but not RA1 will. If I use PORTA = 0x03 then it works so it appears to be a problem with the PORTAbits.RA? command but i dont know why.
and from the delay.h file
Code:
#include <p24FJ128GA010.h>
#include <16BitDelay.h>
int main()
{
AD1PCFG = 0xffff;
TRISA = 0x00;
PORTA = 0x00;
while(1)
{
PORTAbits.RA0 = 1;
PORTAbits.RA1 = 1;
msDelay(500);
PORTAbits.RA0 = 0;
PORTAbits.RA1 = 0;
msDelay(500);
}
}
Code:
int x=0;
void msDelay(int d)
{
while (d>0)
{
for (x=0; x<500; x++)
{
}
d--;
}
}