Maker Pro
Maker Pro

PIC18F4550 interface display is not working on power ON

Hi,

I am using 16x2 LCD display interfaced with pic18f4550. I can display latters on it, but if I switch OFF and then tried to switch ON my display is not showing only boxes. Display is showing latter's only when I reset the controller. I don't know why this is happening. I have added 100nf capacitor to the VCC pin of controller.

Please suggest me any solution that can help me to resolve the issue.
 
Thanks for the suggestion.

Now my display is working properly but once I enable the keypad scan function my display is continuously getting reset. It looks like PIC18F 4550 is getting reset, I have monitored (using scope) reset pin of controller, it is showing clean 5 volt DC. I don't know why my display is continuously flashing the displayed charectors.

Below is the code for my keypad scan

Code:
void keypad(){
    unsigned char col_sense=0x00;
    
    col_sense = PORTB & 0x07;
    if(col_sense != 0x07){
        delayms(20);
        col_sense = PORTB & 0x07;
        if(col_sense != 0x07){
            LATB = 0x1F;
            col_sense = PORTB & 0x07;
            if(col_sense == 0x03){
                lcd_cmd(0x80);
                lcd_data(0x31);
                while(col_sense == 0x03)col_sense = PORTB & 0x07;
                delayms(20);
            }
        }
    }
}
 
Your code makes little sense to me. What is it trying to do?

Here is what it appears to do:

if the low 3 bits of PORTB are all 1, we are done, return.
wait 20 msec.
if the low 3 bits of PORTB are all 1 we are done, return.
set LATB to 0x1F (four low bits on, all others off)
if the low 3 bits of PORTB are 011, do some LCD commands (this seems unlikely since you just set them to 111.)

wait until the low 3 bits of PORTB are not 011
delay 20 ms
return

Don't know what the LCD commands do and I am too lazy to look them up.
Most likely that is what is flashing your screen.

Also, the statement LATB = 0x1F might be problematical if you did not intend to alter the high 4 bits.

Bob
 
Thanks for the reply.

The keypad code here is used to display charecter '1' on LCD display once key is pressed. The 3x3 matrix keypad is used. Coloums of the display are connected to PB0 to PB2 and Rows are connected to PB3 to PB5. The above code is just scanning the key at 1x1 position.

"Most likely that is what is flashing your screen" - I tried commenting the LCD code in keypad function but it doesn't help.
 
Top