georgiod9
Newbie level 4
Hello everyone,
Im trying to light up a LED using interrupt on change with 18F4550. In my schematic, I have the trigger on RB4. Whenever I press that button, the interrupt is supposed to set my LED to 1. This doesn't happen on PORTB4. I tried it on Ports B5,B6, and B7 they all worked, but the problem remains on PORTB4.
The code is as follows:
Any help is appreciated. Thanks!
- - - Updated - - -
Update:
Issue was solved by setting the bits PCFG3, PCFG2, PCFG1 and PCFG0 on ADCON1 as digital I/O ports instead of the default which is analog. Setting the listed bits to 1 will allow us to use RB0, RB1, RB3 and RB4 as digital I/O as per the datasheet.
Therefore, ALWAYS read the datasheet thoroughly before beginning your application.
Im trying to light up a LED using interrupt on change with 18F4550. In my schematic, I have the trigger on RB4. Whenever I press that button, the interrupt is supposed to set my LED to 1. This doesn't happen on PORTB4. I tried it on Ports B5,B6, and B7 they all worked, but the problem remains on PORTB4.
The code is as follows:
Code:
sbit LED at RC0_bit;
void interrupt();
void main()
{
INTCON = 0x88;
SPPCON = 0x00; //I tried disabling the SPP function
SPPCFG.CSEN = 0;
TRISB = 0xFF;
PORTB = 0;
TRISC = 0;
PORTC = 0;
while(1)
{
}
}
void interrupt()
{
LED = 1;
INTCON.RBIF = 0;
}
- - - Updated - - -
Update:
Issue was solved by setting the bits PCFG3, PCFG2, PCFG1 and PCFG0 on ADCON1 as digital I/O ports instead of the default which is analog. Setting the listed bits to 1 will allow us to use RB0, RB1, RB3 and RB4 as digital I/O as per the datasheet.
Therefore, ALWAYS read the datasheet thoroughly before beginning your application.