Display speed – I2C LCD (with STM32)

You need to know the display speed, if you intend to display things while your process is running.  Displays are much slower compared to your uC and other similar processing components. Ignorance of the time, needed to display your data may result in failure.

In cases where you implement interrupts in your process, this issue becomes more complicated.

When an application is sensitive to timing, we have to handle our processes carefully. Micro-controllers can be very fast nowadays, but there are still slow components in your system such as displays.

I recently decided to check performance of popular LCD type displays (because I had problems) , and here I share the results. My intention is not supplying codes to drive the displays (sorry for the laziness). Besides that, my purpose is not to give exact figures which are valid for all uC speeds and SW/HW.  I just want to give an idea based on my projects where I use STM32F103 series. Exact durations are very dependent on your code.

I also checked speed of Graphic TFT displays with SPI and Parallel Interfaces, but it will be subject of another post.

Back side of 4X20 LCD – I2C decoder mounted.

DISPLAY SPEED : LCD DISPLAY WITH I2C INTERFACE

My example is a text display with 4 lines of 20 characters, which is very popular and widely used. In my projects I have been using this item with an I2C driver, since I  generally have a shortage of uC I/O pins. If you drive it directly from its parallel pins, it will be much faster, but I haven’t tested that case.

As a general info, to convert an integer to ASCII and display it on LCD, takes around 10-15 ms. That is quite long, isn’t it? If you are following position of something using an encoder, and attempt to continuously display that, then you are in trouble.

DISPLAYING WITH INTEGER CONVERSION USING ItoA()

  • Converting an integer value of “9000” into ascii : 4.5 uS (using itoa() algorithm)
  • Displaying “AAAA_AAAA_AAAA_A” on LCD (16 Chars) : 10.4 ms
  • Displaying only one character : 1.4 ms then add 0.5 ms for each additional character

    The conversion algorithm itoa() is given below for your reference.

SPRINTF() is MUCH SLOWER THAN ItoA()

sprintf(displayBuffer,” %d      ” number);    

This takes 41 us for a 4 digit integer, ten times slower compared to ItoA. But provides additional formatting feature for decimals.

itoa CONVERTION ALGORITHM

void itoa(int i, unsigned char b[], uint8_t c){

char const digit[] = “0123456789ABCDEF”;
int shifter;
char* p = b;

if(i<0){
*p++ = ‘-‘;
i *= -1;
}

shifter = i;
do{ //Move to where representation ends
++p;
shifter = shifter/c;
} while(shifter);

*p = ‘\0’;
do { //Move back, inserting digits as u go
*–p = digit[i%c];
i = i/c;
} while(i);
}

Leave a Reply

Your email address will not be published. Required fields are marked *