Page 159 - Making PIC Microcontroller Instruments and Controllers
P. 159
sEttlNG ouT ouR t EstG |l{lElll t 5 l
0
0
0 0 1 0 1 0 se! cursor shift eLc
0
0
0
0 =cursor shift off
I =shift to rishL, or Left {0)
load for a comand function
' D
0
0 0 0 1 1 1 1 d s p _ a y o . b l \ - -
0
0
0
0
1=culsor on so we can see lt
1 = b l i n k o n s o w e c a n s e e i t
load for a command function
' . . ' 6 6 -
0 0 0 0 0 1 1 0 r i t e c
0
0
0
0
1 =increment cursor in positiwe dir
0 =display not shifled
Load for a comand function
At the end ofthese instructions, the display will have been initialized the way we
There is also this business about the busy flag that we need to be thinking about.
The display lakes time to do whatever we askit to do, and the time varies with what
we asked itto do. Wc can wait afew milliseconds between ins[uctions to make sure
it has had erough time for the lask to complete, or we can monilor the busy llag and
as soon as it is not busy we can send the next instruction. Since lime is always at a
premium, and we want to run as fast as we can. it means we must consider moni
toring the busy flag. (This is impoftant because addressing the LCD is one ofthe most
time'consuming pafts of most programs, and these small processors are running at
only some 20 MHz.)
THE BUSY FLAG
The i nsnxction sheet tells us that the busy llag is bit 5 at localion I I I 0001 I in the LCD.
Meta Code for waiting for ihe busy bit iD |he LCD to clear is as follows: