Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

HD44780 read busy flag in 4-bit mode

Status
Not open for further replies.

T3STY

Full Member level 4
Joined
Apr 17, 2012
Messages
239
Helped
24
Reputation
48
Reaction score
24
Trophy points
1,308
Activity points
3,715
I'm still working with LCDs and PIC16F84. I've written part of a 4-bit independent pins driver, it's working fine most of it.
What I want to do now is to create a function that reads the busy flag and the address, but I'm not sure how to proceed. The HD44780 manual says I can read it with a busy flag request, like this:
Code:
RS RW RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0
 0  1  BF  AC  AC  AC  AC  AC  AC  AC
But how should I proceed exactly? I mean, ok, I can send the request with RS=0, RW=1; at this point data shall be written from display to the pins. But the data I have to read is 8 bit long, and I am using 4 bit data transfer. How will the display send the 8 bits in 4 bit mode? Will it make 2 write cycles, the second after a specific delay? Or should I make the request twice and shift myself the incoming data?
The manual says nothing about it and I'm totally aware on what to do.
 

I'm still working with LCDs and PIC16F84. I've written part of a 4-bit independent pins driver, it's working fine most of it.
What I want to do now is to create a function that reads the busy flag and the address, but I'm not sure how to proceed. The HD44780 manual says I can read it with a busy flag request, like this:
Code:
RS RW RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0
 0  1  BF  AC  AC  AC  AC  AC  AC  AC
But how should I proceed exactly? I mean, ok, I can send the request with RS=0, RW=1; at this point data shall be written from display to the pins. But the data I have to read is 8 bit long, and I am using 4 bit data transfer. How will the display send the 8 bits in 4 bit mode? Will it make 2 write cycles, the second after a specific delay? Or should I make the request twice and shift myself the incoming data?
The manual says nothing about it and I'm totally aware on what to do.


Hi,

You might find these lcd pdfs helpful.
http://www.epemag.wimborne.co.uk/resources.htm

Assume you are meaning you want to Read the current Cursor Address and Data Out of the Lcd ?

Although I have never tried, assume it will send its info in the same way as you would send 4 bit nibbles.
 

The attached LCD library has a Busy Flag routine implemented in both 4 and 8 bit modes.

Code Snippet of Busy Flag Check:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifdef CHECKBUSY
 
unsigned char 
lcd_read_cmd_nowait(void)
{
    unsigned char c, readc;
 
    LCD_DATA_TRIS    |=  ~OUTPUT_DATA;  // Set data lines to input
 
    LCD_RW = 1; // Read LCD
    _delay(2); // short propagation delay
 
    if (fourbit) {
        LCD_STROBE_READ(readc); // Read high nibble
        // Move 4 bits to high nibble while zeroing low nibble
        c = ( ( readc << 4 ) & 0xF0 ); 
        LCD_STROBE_READ(readc); // Read low nibble
            c |= ( readc & 0x0F ); // Or in 4 more bits to low nibble
    } else {
        LCD_STROBE_READ(readc); 
        c = readc;
    }
    LCD_RW = 0; // Return to default mode of writing LCD
    LCD_DATA_TRIS &= OUTPUT_DATA; // Return to default mode of writing LCD
 
    return(c);
}
 
void
lcd_check_busy(void) // Return when the LCD is no longer busy, or we've waiting long enough!
{
    // To avoid hanging forever in event there's a bad or 
    // missing LCD on hardware.  Will just run SLOW, but still run.
    unsigned int retry; 
    unsigned char c;
 
    for (retry=1000; retry-- > 0; ) {
        c = lcd_read_cmd_nowait();
        if (0==(c&0x80)) break; // Check busy bit.  If zero, no longer busy
    }
}
 
#endif



You should be able to adapt the above code snippet to your routines.


BigDog
 

Attachments

  • PIC16F LCD Library.zip
    3.7 KB · Views: 131

Hmm, it looks like I was right, I have to make 2 busy requests to get the whole 8 bit result.
Thanks for the help :)
 

Correct, you need to read both nibbles to have access to the Busy Flag which is the MSb.

BigDog
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top