Professional Documents
Culture Documents
Signup
Login
Author Message
Fivestar widget
Total votes: 0
Level: Wannabe I have written my own HD44780 display functions that do everything I
Joined: Tue. Feb 27, 2001
Posts: 89 View posts want to do except it usees delays to compensate for the AVR being
Location: Huntington, WV much faster than the LCD. Everything in my code so far seems to
work solidly in both 8-bit and 4-bit mode.
I would like to replace the delays with a function that can be called
that waits for the Busy Flag to clear and/or possibly returns the BF.
All the code I have seen so far needs a lot of other code to set this
up and execute. So long as the function knows the data port and the
three control pins this should be a simple function.
I'm thinking this could be the simple function:
Change the data port DDRx from output to input.
Clear the LCD RS pin and Set R/W pin.
Set the LCD E pin .
Read the LCD data port, PINx.
Clear the LCD E pin.
Change the data port DDRx back to output.
http://www.avrfreaks.net/forum/simple-c-or-asm-lcd-busy-flag-check-function 1/7
1/20/2018 Is simple C or ASM LCD Busy Flag check function | AVR Freaks
I have seen code before that I'm sure does this. I have gone over it
but understanding it was beyond me.
Mike
Tags:
AVR Microcontrollers, megaAVR and tinyAVR
Top
Log In / Register to post comments
Total votes: 0
Top
Log In or Register to post comments
Total votes: 0
Level: Hangaround
Joined: Thu. Jul 21, 2011 #ifdef LCD_CHECK_BUSY
Posts: 158 View posts void waitForLcd(void) {
Location: San jose, CA,
USA // adapted form http://www.8051projects.net/lcd-interf
http://www.avrfreaks.net/forum/simple-c-or-asm-lcd-busy-flag-check-function 2/7
1/20/2018 Is simple C or ASM LCD Busy Flag check function | AVR Freaks
#else
void waitForLcd(void) {
_delay_us(50);
}
#endif
link
i am a NOOO00B!!
Top
Log In or Register to post comments
Total votes: 0
Peter
Top
Log In or Register to post comments
http://www.avrfreaks.net/forum/simple-c-or-asm-lcd-busy-flag-check-function 3/7
1/20/2018 Is simple C or ASM LCD Busy Flag check function | AVR Freaks
Total votes: 0
Regardless of if the only read you do is to check the busy flag it still
Level: 10k+ Postman makes sense to divide this into two separate pieces:
Joined: Wed. Mar 27,
2002
Posts: 26837 View posts - A function that reads a byte from the LCD module, and
Location: Lund, Sweden - A function that checks the busy flag.
Sketchy:
uint8_t LCD_ReadAddressBusy()
{
//...
}
int LcdBusy()
{
while (LcdReadAddressBusy & 0x80);
}
Do not worry about the extra level of function calls now. Care about
efficiency of the code later. Get it to work first.
As of January 15, 2018, Site fix-up work has begun! Now do your part and
report any bugs or deficiencies
here(http://www.avrfreaks.net/forum/consolidating-site-errors-
and-deficiencies).
"Some questions have no answers."[C Baird] "There comes a point where the
spoon-feeding has to stop and the independent thinking has to start." [C
Lawson] "There are always ways to disagree, without being disagreeable."[E
Weddington] "Words represent concepts. Use the wrong words, communicate the
wrong concept." [J Morin] "Persistence only goes so far if you set yourself up
for failure." [Kartman]
Top
Log In or Register to post comments
http://www.avrfreaks.net/forum/simple-c-or-asm-lcd-busy-flag-check-function 4/7
1/20/2018 Is simple C or ASM LCD Busy Flag check function | AVR Freaks
pidkits
Total votes: 0
// read the busy flag and address counter from the LCD
// returns 6 bit address plus busy flag (in bit 7)
static uint8_t lcd_readByte() { // 58 uS at 1MHz
uint8_t d,b;
lcd_RW_high(); // RW = 1 to read
tick();
lcd_EN_high(); // EN = 1 to enable read
tick();
b = _DB_PIN; // read pins while EN is high
lcd_EN_low();
tick();
d = ( bitRead(b,_DB4) << 4 ); // high nibble
d |= ( bitRead(b,_DB5) << 5 );
d |= ( bitRead(b,_DB6) << 6 );
d |= ( bitRead(b,_DB7) << 7 );
lcd_EN_high();
tick();
b = _DB_PIN; // read pins while EN is high
lcd_EN_low();
tick();
d |= ( bitRead(b,_DB4) << 0 ); // low nibble
d |= ( bitRead(b,_DB5) << 1 );
d |= ( bitRead(b,_DB6) << 2 );
d |= ( bitRead(b,_DB7) << 3 );
lcd_RW_low(); // clear the RW flag
return d; // contains a full byte read from the LCD
}
http://www.avrfreaks.net/forum/simple-c-or-asm-lcd-busy-flag-check-function 5/7
1/20/2018 Is simple C or ASM LCD Busy Flag check function | AVR Freaks
Jim
Top
Log In or Register to post comments
Total votes: 0
I've never met a pig I didn't like, as long as you have some salt and pepper.
Top
Log In or Register to post comments
Jump To
--megaAVR and tinyAVR
Privacy(http://www.atmel.com/About/privacy.aspx)
Contact(http://www.atmel.com/About/contact/distributors/default.aspx?
contactType=Online%20Directory)
Site Use Terms(http://www.atmel.com/About/legal.aspx)
http://www.avrfreaks.net/forum/simple-c-or-asm-lcd-busy-flag-check-function 6/7
1/20/2018 Is simple C or ASM LCD Busy Flag check function | AVR Freaks
Cookies(http://www.atmel.com/About/cookies.aspx)
http://www.avrfreaks.net/forum/simple-c-or-asm-lcd-busy-flag-check-function 7/7