LCDproc development and user support list

Text archives Help

[lcdproc] Newbie questions

Chronological Thread 
  • From: t_amani AT (Thierry AMANI)
  • Subject: [lcdproc] Newbie questions
  • Date: Fri, 22 Sep 2000 11:48:48 +0200


> The heartbeat, scrolling and screenchanges and -refreshs are
> _very_ slow (refresh about every 4 seconds, time between client
> connecting and showing the first screen about 30seconds,
> heartbeat changes every 3 seconds) is my mashine sooooo slow ?
> can I fix it ? (how?)

I had the same problem but now it walks fine.
The problem comes from the use of the function usleep() in the hd44780
driver, precisely in function HD44780_senddata() (file
usleep(int n) is supposed to make the system wait n microseconds.
Unfortunately during this waiting time, the system switch to another
and switches between processes take much more time (I read somewhere 20
So I decided not to use usleep(). Instead, I defined a macro in file
#define USLEEP_1() port_out(0x80, 0x0)
This macro performs a writting operation on port 0x80. In most case this
port is never used by the system.
A writting/reading operation on a port takes exactly 1 microseconds.
Using USLEEP_1(), the function HD44780_senddata() becomes:

static void HD44780_senddata(unsigned char flags, unsigned char ch)
unsigned char h = ch >> 4;
unsigned char l = ch & 15;
int i;
port_out(lp, 128 | EN | flags | h);
for ( i=0; i<1600; i++)
port_out(lp, 128 | flags | h); port_out(lp, 128 | EN | flags | l);
for ( i=0; i<1600; i++)
port_out(lp, 128 | flags | l);

One can notice the presence of loops. I put them to make a waiting time
>1600 microseconds. Why 1600? I read somewhere that the hd44780 device needs
1640 ms to clear the display.
So I tried different values between 2000 and 1400. The fact is that a small
value causes the display to be refreshed more frequently, but a too small
value causes the display not to function properly. The value 1600 walked on
my configuration, a celeron 400Mhz on an abit BE6 motherboard, and the
display was refreshed twice a second. I tried it on a celeron 500 Mhz with
an intel i810 chipset, but it didn't work. I had to put 2400. The display
was then refreshed only once a second.
Also, you'll need to ask permission to write on port 0x80. You ask it in
function HD44780_init() file hd44780.c.

// Set up io port correctly, and open it...
if ((ioperm(port,3,1)) == -1) {
fprintf(stderr, "HD44780_init: failed (%s)\n", strerror(errno));
return -1;


// Set up io port correctly, and open it...
if ((ioperm(port,3,1)) == -1) {
fprintf(stderr, "HD44780_init: failed (%s)\n", strerror(errno));
return -1;

// For delaying after a writing operation ...
if ((ioperm(0x80,1,1)) == -1) {
fprintf(stderr, "HD44780_init (delaying): failed (%s)\n",
return -1;

usleep() is also used in HD44780_init(), but it's not a problem, the
function is called only one time.

I hope what I said wasn't too confusing. I know my english is not great.
I have joined my hd44780.c and hd44780.h files.
Don't forget to try different values for the loops in HD44780_senddata().


IT-Telecom student - ESIGETEL

Attachment: hd44780.c
Description: Binary data

Attachment: hd44780.h
Description: Binary data

To unsubscribe from this list send a blank message to
lcdproc-unsubscribe AT

Archive powered by MHonArc 2.6.18.

Top of page