Connect with us

PIC18F4550 interface display is not working on power ON

Discussion in 'Microcontrollers, Programming and IoT' started by shindehari, Dec 23, 2018.

  1. shindehari

    shindehari

    14
    1
    May 19, 2014
    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.
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    9,230
    1,861
    Nov 17, 2011
    Obviously the LCD controller is not reset correctly on power on. Obvious solution: send a reset command to the LCD as part of your PIC's initializaton routine.
     
  3. shindehari

    shindehari

    14
    1
    May 19, 2014
    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);
                }
            }
        }
    }
     
  4. BobK

    BobK

    7,609
    1,648
    Jan 5, 2010
    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
     
  5. shindehari

    shindehari

    14
    1
    May 19, 2014
    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.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-