Presentation units: Liquid Crystal Display

advertisement
TNE019 Mikrodatorer F3
1
Presentation units: Liquid Crystal Display - LCD
Driver and display in one unit. We communicate with driver.
Driver to LCD is handled automatic with a microcontroller.
This type has 2 lines and 16 characters/line. Same principle also for
graphic displays. Send ASCII-coded character to desired address.
TNE019 Mikrodatorer F3
LCD Block diagram
Two registers to write:
* Instruction Register – IR
* Data Register - DR
Three memory :
•Display data RAM
80 character
• Character Generator ROM
160 character
• Character Generator RAM
8 character
(lab type is LM16255)
2
TNE019 Mikrodatorer F3
It is also possible
to make your own
character in 5*7 pixels
and save it in RAM.
LCD Characters
3
TNE019 Mikrodatorer F3
LCD-signals
4
Clock data
Register select.
TNE019 Mikrodatorer F3
Flowchart for programming LCD
5
TNE019 Mikrodatorer F3
Instruction set for LCD
6
TNE019 Mikrodatorer F3
7
LCD programming, initialize
First initiate LCD (see flowchart page 5):
Init_LCD
Initcode
……..
……..
clrf
movlw
movwf
call
movlw
movwf
movf
call
call
incf
decfsz
bra
……..
Offset
0x07
Antal
Wait
HIGH Initcode
PCLATH
Offset,W
Initcod
CtrlLCD
offset,F
Antal
Init_LCD
……..
addwf
retlw
retlw
retlw
retlw
retlw
retlw
retlw
return
PCL,F
0x38
0x38
0x38
0x38
0x0C
0x01
0x06
;Offset variable in RAM
;Antal variable in RAM
;wait > 15 ms
;address to table
;offset in table
;fetch code
;write code
;increment offset
;decrement Antal-counter
;next initcode to LCD
TNE019 Mikrodatorer F3
8
Subroutine CtrlLCD
CtrlLCD
movwf
movlw
movwf
nop
nop
nop
movlw
movwf
return
PORTB
0x01
PORTA
;Controlbyte to LCD
;E=1 and RS=0
;to LCD
0x00
PORTA
;E=0 and RS=0
;to LCD
TNE019 Mikrodatorer F3
LCD programming, write character
9
Write character: send address, send data, send address, send data…
If character is to be print on first line in first position you don’t need address.
For example you can display dec number 35 (stored in memory called TAL
as 0011 0101 binärt).
……..
swapf
andlw
iorlw
call
call
movf
andlw
iorlw
call
call
……
TAL,W
H’0F’
H’30’
DataLCD
Wait
TAL,W
H’0F’
H’30’
DataLCD
Wait
;Exchange nibble ->W
;ASCII-code
;Send to LCD
;Wait
;TAL -> W
;ASCII-code
;Send to LCD
TNE019 Mikrodatorer F3
10
STACK in processor systems.
In general processor systems a stack is a limited part of RAM, used to save return addresses
for subroutines and interrupt. It is also possible to temporary save variables and do parameter
transfers between main program and subroutine. To handle this processors usually have a
specially register called stackpointer which you have to initiate to a RAM high address.
When an address is saved from programcounter (PC), stackpointer automatically decrement
one step to a lower address. After a return instruction stackpointer is incrementet one step and
address value to main program is copied back to programcounter (PC).
PIC has a special stack area which not is a part of data RAM. In PIC18F452 stack has 31 level.
The address to this stack is hold by a stackpointer register called STKPTR register.
The stack is handled automatic.
TNE019 Mikrodatorer F3
11
Stackpointer register
TNE019 Mikrodatorer F3
12
STACK example in processor systems.
Ex:
Address
……
0012
0016
…..
Test
002E
0030
0032
……
Opcode Operand
……..
EC 2E F0 00
0E 33
…..
00 00
00 00
00 12
…….
……..
Symbolic code
……..
call
0x2e
movlw
0x33
nop
nop
return
;PC just now
;next to execute
Hardware stack when in subroutine
Stack Level
0
1
2
..
Return Address
Empty
000016
000000
…….
;2 words
;
Stack Pointer
Download