Shinnster
Member level 4
- Joined
- Sep 15, 2009
- Messages
- 70
- Helped
- 1
- Reputation
- 2
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Malaysia
- Activity points
- 1,800
For 4-bit interface data, only four bus lines (DB4 to DB7) are used for transfer. Bus lines DB0 to DB3
are disabled. The data transfer between the HD44780U and the MPU is completed after the 4-bit data
has been transferred twice. As for the order of data transfer, the four high order bits (for 8-bit
operation, DB4 to DB7) are transferred before the four low order bits (for 8-bit operation, DB0 to
DB3).
The busy flag must be checked (one instruction) after the 4-bit data has been transferred twice. Two
more 4-bit operations then transfer the busy flag and address counter data.
movlw h'F0' ;this will be used to remove the lower bits
andwf LCDchar,w ;top half of W now contains the top half of LCDchar value
movwf PORTB ;output it to the port
bsf LCDE ;make E high
bcf LCDE ;make E low again
movlw h'F0'
swapf LCDchar,f ;swap top and bottom half of LCDchar
andwf LCDchar,w ;top half of W now contains the bottom half of LCDchar
movwf PORTB ;output it to the port
bsf LCDE ;make E high
bcf LCDE ;make E low again
movlw h'0F'
swapf LCDchar,f
andwf LCDchar,w
movwf PORTB
bsf LCDE
bcf LCDE
swapf LCDchar,w
andlw h'0F'
movwf PORTB
bsf LCDE
bcf LCDE
addwf PCL,f
retlw <value for combination 0001>
retlw <value for combination 0010>
retlw <value for combination 0011>
.
.
.
retlw <value for combination 1111>
LIST p=16f84a
#include <P16f877a.INC>
BSF STATUS,RP0
MOVLW 0x00 ;Port A as output (Has Enable and RS)
MOVWF TRISA
MOVLW 0x0F ;Port B - 00001111 (RB0-RB3 = Row) (RB4-RB7 = Column | D4-D7 ~ LCD)
MOVWF TRISB
BCF STATUS,RP0
BCF PORTA,2 ; R/S set 0
banksel TRISA
MOVLW 0x00 ;Port A as output (Has Enable and RS)
MOVWF TRISA
MOVLW 0x0F ;Port B - 00001111 (RB0-RB3 = Row) (RB4-RB7 = Column | D4-D7 ~ LCD)
MOVWF TRISB
banksel PORTA
BCF PORTA,2 ; R/S set 0
BSF PORTB,7 ; Column 4
GOTO READ_ROW
GOTO KEYPAD
MyTable
addwf PCL.f
retlw h'41'
retlw h'17'
retlw h'DE'
retlw h'07'
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?