| ??? 12/27/07 03:19 Read: times |
#148760 - Do not use fixed delays - check for LCD busy Responding to: ???'s previous message |
I found out in the hard way that the LCD manuals were quite optimistic when giving information for the execution times of LCD commands.
I also found out that some commands actually finished very rapidly. This all seemed to depend on when I kicked the LCD module. After throwing the fixed delays out of the window my code became at least 3 times faster especially on writing characters to the LCD. Here is a code that checks whether a LCD is busy:
// -----------------------------------------------------------------------
// LcdBusy.c
// -----------------------------------------------------------------------
#include "Lcd.h"
// -----------------------------------------------------------------------
// Check if the LCD is busy doing stuff
// -----------------------------------------------------------------------
extern bool_t LcdBusy ( void ) {
uint8_t busdata;
if ( LcdExist() ) {
ApplicationIrqDisable();
ApplicationLcdBusRead();
ApplicationLcdSetRW( 1 );
ApplicationLcdSetRS( 0 );
ApplicationLcdSetE( 1 );
busdata = ApplicationLcdGetBus();
ApplicationLcdSetE( 0 );
ApplicationLcdBusRelease();
ApplicationIrqEnable();
}
else {
busdata = 0;
}
return busdata & 0x80 ? 1 : 0;
}
// -----------------------------------------------------------------------
// EOF: LcdBusy.c
// -----------------------------------------------------------------------
And here is a sample on how to use it: // -----------------------------------------------------------------------
// LcdWait.c
// -----------------------------------------------------------------------
#include "Lcd.h"
// -----------------------------------------------------------------------
// Wait for the display
// -----------------------------------------------------------------------
extern bool_t LcdWait ( uint16_t aMaxtime ) {
uint16_t mytime;
mytime = aMaxtime;
while ( mytime != 0 && LcdBusy() ) {
mytime--;
ApplicationDelay( 1 );
}
return LcdBusy();
}
// -----------------------------------------------------------------------
// EOF: LcdWait.c
// -----------------------------------------------------------------------
|
| Topic | Author | Date |
| LCD 8x24 - samsung 0282a | 01/01/70 00:00 | |
| add. info | 01/01/70 00:00 | |
| add. info | 01/01/70 00:00 | |
| What language are you using? | 01/01/70 00:00 | |
| solved! | 01/01/70 00:00 | |
| Binary numbers in 'C' | 01/01/70 00:00 | |
| Wrong operator | 01/01/70 00:00 | |
| As You are using C, why not | 01/01/70 00:00 | |
| Do not use fixed delays - check for LCD busy | 01/01/70 00:00 | |
| I've found the opposite! | 01/01/70 00:00 | |
| Binary numbers in 'C' | 01/01/70 00:00 | |
| Infinite waits | 01/01/70 00:00 | |
| Actually it is time | 01/01/70 00:00 | |
| Another opposite | 01/01/70 00:00 | |
| and .. | 01/01/70 00:00 | |
| Whoaaaaaa..... | 01/01/70 00:00 | |
LCD Timeout | 01/01/70 00:00 | |
| Code formatting - avoid TABs | 01/01/70 00:00 | |
| Oh - sorry about that ... | 01/01/70 00:00 | |
| Did you see this? | 01/01/70 00:00 |



