LCD R/W Pin

Status
Not open for further replies.
RESOLVED.


Hi,

(for later) Happy New Year to you all!

I've a 4x20 lcd connected to an 18f2420. Code is C18. It's connected in 4 bit mode. I'm trying to read the busy flag - in one set up it works ok and in the other not.
In the first (problem) setup all lcd data and control pins are connected to PORTC with lcd R/W on RC5. The lcd won't initialise. The second setup is the same as the first but the lcd R/W pin is connected to RA5 and it initialises ok.
Looked at waveforms for R/W and busy pin (DB7) on a scope in both situations and they look pretty much the same. I'm a bit stuck.

Thanks in advance for any help.

Code snippets:

Code:
#define LCD_RS       LATCbits.LATC4        // RS = Register Select [lcd pin 04] pic pin 15
//#define LCD_RW    LATCbits.LATC5        // RW = Read / Write [lcd pin 05] pic pin 16
#define LCD_En        LATCbits.LATC6        // En = Enable [lcd pin 06] pic pin 17

//#define LCD_RS       LATAbits.LATA4        // RS = Register Select [lcd pin 04] pic pin 6
#define LCD_RW        LATAbits.LATA5        // RW = Read / Write [lcd pin 05] pic pin 7
//#define LCD_En     LATAbits.LATA6        // En = Enable [lcd pin 06] pic pin 10

#define LCD_BF            PORTCbits.RC3     // BF = Busy Flag [pic pin 14]
#define LCDdata2port    LATC

void LCD_E (void)    
{    
    LCD_En = 1;    
    LCD_En = 0;    //data read into lcd on high to low transition of E    
}
    
void LCD_busy (void)
{
    TRISCbits.TRISC3 = 1;  // When TRIS = 0 it's DB7, Tris = 1 it's lcd busy flag.
    LCD_RW = 1;
    LCD_En = 1;
    while (LCD_BF);
    LCD_En = 0;
    LCD_RW = 0;
    TRISCbits.TRISC3 = 0;               

}
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…