Reading the busy Flag

As discussed in the previous section, there must be some delay which is needed to be there for LCD to successfully process the command or data. So this delay can be made either with a delay loop of specified time more than that of LCD process time or we can read the busy flag, which is recomended. The reason to use busy flag is that delay produced is almost for the exact amount of time for which LCD need to process the time. So is best suited for every application.
Steps to read busy flag
when we send the command, the BF or D7th bit of the LCD becomes 1 and as soon as the command is processed the BF = 0. Following are the steps to be kept in mind while reading the Busy flag.
  • Select command register
  • Select read operation
  • Send enable signal
  • Read the flag

So following the above steps we can write the code in assembly as below...

;Ports used are same as the previous example

         setb   LCD_D7        ;Make D7th bit of LCD data port as i/p
         setb   LCD_en        ;Make port pin as o/p
         clr    LCD_rs        ;Select command register
         setb   LCD_rw        ;we are reading
         clr    LCD_en        ;Enable H->
         setb   LCD_en
         jb     LCD_D7,check  ;read busy flag again and again till it becomes 0
         ret                  ;Return from busy routine

The equivalent C code Keil C compiler. Similar code can be written for SDCC.

void LCD_busy()

     LCD_D7   = 1;           //Make D7th bit of LCD as i/p
     LCD_en   = 1;           //Make port pin as o/p
     LCD_rs   = 0;           //Selected command register
     LCD_rw   = 1;           //We are reading

     while(LCD_D7){          //read busy flag again and again till it becomes 0
           LCD_en   = 0;     //Enable H->
           LCD_en   = 1;


The above routine will provide the necessary delay for the instructions to complete. If you dont want to read the busy flag you can simply use a delay routine to provide the a specific ammount of delay. A simple delay routine for the LCD is given below.

         mov  r7,#50H
         mov  r6,#FFH
         djnz r6,$
         djnz r7,back
         ret                  ;Return from busy routine
void LCD_busy()
         unsigned char i,j;
         for(i=0;i<50;i++)        //A simple for loop for delay

Now we are ready with the initialization routine and the busy routine for LCD. In the next section we will see how to send data and command to the LCD.

Share it! Like it!



Thu May 30 2024, 09:33 am
Wed May 29 2024, 03:33 pm
Wed May 29 2024, 03:19 pm
Wed May 29 2024, 05:35 am
Tue May 28 2024, 01:54 pm
Tue May 28 2024, 08:55 am
Tue May 28 2024, 06:41 am
Mon May 27 2024, 06:16 pm