I am working on PIC18F4550.
I have configured PORTA Pin0-Pin3 as inputs using following code
PORTA=0X00;
LATA=0X00;
ADCON1=0x0F;
CMCON = 0x07;
TRISA =0XCF;
and PORTE as outputs using following code
TRISEbits.TRISE0=0
TRISEbits.TRISE1=0;
TRISEbits.TRISE2=0;
I have connected a passive keypad to this pins and I am just scanning inputs by making outputs 1 at a time.
But I am getting very erratic values in PORTA register. I even tried debugging using pickit3. I set a break point just after making output 1 and before I scan for inputs. PORTA register is changing in whimsical manner even when I haven't pressed any key. Please suggest what I might be doing wrong.