Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/20/02 09:02
Read: times


 
#29425 - RE: 4 bit LCD initialisation / Peter
Hi all,
Peter-> If you look at my close enough, you should see that I have done what the data sheet says about initialisation.

Sunil-> I am using the Bipom microntroller and a Hitachi HD44780U LCD. The compiler I am using is the 3rd part software supplied by the microcontroller's manufacturer called Micro-IDE. Have you got any other compiler that you can send it to me? My email is cbphee@hotmail.com.

Mahmood-> Can you please take a look at my codes and let me know if there is any thing I need to change...Thanks a million for that.

My code:

LCD_DataPort EQU P0
LCD_DB4 BIT P0.4
LCD_DB5 BIT P0.5
LCD_DB6 BIT P0.6
LCD_DB7 BIT P0.7
LCD_RS BIT P2.0
LCD_EN BIT P2.1
LCD_RW BIT P2.2

ORG 00h ;Reset
ACALL MAIN ; Starts program

Dly1ms: PUSH ACC MOV ACC,R0 ; R0 use as a counter
MOV R0,#0
Dly1ms1: DJNZ R0,Dly1ms1
Dly1ms2: DJNZ R0,Dly1ms2
Dly1ms3: DJNZ R0,Dly1ms3
Dly1ms4: DJNZ R0,Dly1ms4
MOV R0,A
POP ACC
RET

Dly10ms: PUSH ACC
MOV ACC,#10 ; 10ms delay
Dly10ms1: ACALL Dly1ms
DJNZ ACC,Dly10ms1
POP ACC
RET

Toggle_EN: SETB LCD_EN ; EN pin '1'
ACALL Dly10ms ; Delay 10 ms
CLR LCD_EN ; EN pin '0'
ACALL Dly10ms ; Delay 10 ms
RET

Data_Write: SETB LCD_RS ; Data
Clr LCD_RW ; WRITE data
MOV LCD_DataPort,ACC
ACALL Toggle_EN ACALL Chk_BF ; Ch the bflag
Ret

Instr_Write: CLR LCD_RS ; Instruction
CLR LCD_RW ; WRITE instr
MOV LCD_DataPort,ACC ACALL Toggle_EN ACALL Chk_BF ; Checks the Busy Flag
RET
Chk_BF: CLR LCD_RS ; Instruction
SETB LCD_RW ; READ
; Read first part of the return value (high nibble)
MOV ACC,LCD_DataPort
ACALL Toggle_EN
SWAP A
; If bit 7 high, LCD still busy
JB ACC.7,Chk_BF
CLR LCD_RW
RET

Unlock_LCD: CLR LCD_RS ; Command
CLR LCD_RW ; WRITE
MOV LCD_DataPort,#030h
ACALL Toggle_EN
ACALL Dly1ms RET

LCD_Init: ACALL Dly10ms ACALL Dly10ms ACALL Dly10ms ACALL Dly10ms ACALL Dly10ms ACALL Unlock_LCD ACALL Unlock_LCD ACALL Unlock_LCD

MOV LCD_DataPort,#020h ACALL Toggle_EN

MOV A,#020h ACALL Instr_Write MOV A,#080h ACALL Instr_Write

MOV A,#000h ACALL Instr_Write MOV A,#080h ACALL Instr_Write
MOV A,#000h ACALL Instr_Write MOV A,#0F0h ACALL Instr_Write
MOV A,#000h ACALL Instr_Write MOV A,#010h ACALL Instr_Write
MOV A,#000h ACALL Instr_Write MOV A,#060h ACALL Instr_Write RET

MAIN: ACALL LCD_iNIT
RET

List of 17 messages in thread
TopicAuthorDate
4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
   RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation : My C code            01/01/70 00:00      

Back to Subject List