Hi,
I am doing a small project at home with an LCD and four push buttons connected to PIC18F4550 controller.
LCD is connected to PORTD & PORTB, which is working perfectly fine. But four push buttons connected as keypad matrix is connected to PORTA, which is giving lot of issues.
I have configures PORTA0:A1 as output pins and PORTA2:A3 as input pins. During initialization I have set - ADCON1 = 0x0f, CMCON = 0x07, TRISA=0x0C.
I set the output A0 as high using LATA=0x01 and read the PORTA after few milli seconds. Delay routine is
When I read PORTA, I always get junk data. When I don't press any key then the value should be zero as I mask the PORTA with 0x0C to consider only input pins.
As well when I run the program in release mode, I feel the controller is getting reset.
Can anyone help me in sorting this problem out?
Initialization code
I am doing a small project at home with an LCD and four push buttons connected to PIC18F4550 controller.
LCD is connected to PORTD & PORTB, which is working perfectly fine. But four push buttons connected as keypad matrix is connected to PORTA, which is giving lot of issues.
I have configures PORTA0:A1 as output pins and PORTA2:A3 as input pins. During initialization I have set - ADCON1 = 0x0f, CMCON = 0x07, TRISA=0x0C.
I set the output A0 as high using LATA=0x01 and read the PORTA after few milli seconds. Delay routine is
Rich (BB code):
for(i=0;i<100;i++)
{
_asm
NOP
_endasm
}
As well when I run the program in release mode, I feel the controller is getting reset.
Can anyone help me in sorting this problem out?
Initialization code
Rich (BB code):
#pragma config FOSC=XT_XT //INTOSCIO_EC //4 MHz crystal
#pragma config PLLDIV = 1
#pragma config WDT=OFF
#pragma config LVP=OFF