The PIC GPIO puzzles me.
My requirement is to light up LEDs one after another with a slight delay and at the end of it all the LEDs need to glow.
Below is the code that I wrote.
void initPorts()
{
PORTA = 0X00;
TRISA = 0X00;
PORTC = 0x00;
CMCON0 = 0X07;
TRISC = 0x00;
}
void main()
{
initPorts();
while(1)
{
RC5 = HI; __delay_ms(50);
RC4 = HI; __delay_ms(50);
RC3 = HI; __delay_ms(50);
RC2 = HI; __delay_ms(50);
RC1 = HI; __delay_ms(50);
RC0 = HI; __delay_ms(50);
}
}
When I execute this code on the target - LEDs on Port RC4 and RC5 glow continuously and the LEDs connected to the remaining ports sequentially switch on and off creating a running light effect.
What am I doing wrong??
Thanks for any response.
Ravi Upadhyaya
Bookmarks