Does anyone have any clue why this code will not initialize the LCD? I’m out of ideas. This code is the umpteenth revision with no success.
;*******************************************************************************
;*******************************************************************************
.cdecls C,LIST,"msp430x16x.h" ; Include device header file
;-------------------------------------------------------------------------------
.text ; Progam Start
;-------------------------------------------------------------------------------
RESET mov.w #0A00h,SP ; Initialize stack pointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
bis.b #0ffh,&P1DIR ; P1.x output
bis.b #00fh,&P2DIR ; P2.(0-3) output
;
iniLCD mov.w #0528h,R15 ; Set delay to 40ms (1320 cycles @32k Hz)
dec1 dec.w R15 ; Decrement R15
jnz dec1 ; Delay done?
mov.b #00000000b,&P2OUT ; Function Set: RS(0), RW(0) (Write, ini E (low))
mov.b #00110000b,&P1OUT ; Function Set: DB(001110xx) (ini to 8-bit, sel 2 line disp, 5x8 char font)
bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
mov.w #0084h,R15 ; Set delay to 4.1ms (132 cycles @32k Hz)
dec2 dec.w R15 ; Decrement R15
jnz dec2 ; Delay done?
mov.b #00000000b,&P2OUT ; Function Set: RS(0), RW(0) (Write, ini E (low))
mov.b #00110000b,&P1OUT ; Function Set: DB(001110xx) (ini to 8-bit, sel 2 line disp, 5x8 char font)
bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
nop
nop
nop
nop
nop
nop
nop
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
mov.w #0004h,R15 ; Set delay to 100us (4 cycles @32k Hz)
dec3 dec.w R15 ; Decrement R15
jnz dec3 ; Delay done?
mov.b #00000010b,&P2OUT ; Function Set: RW(1) (Read)
chkLCD0 bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
nop
nop
nop
nop
mov.b &P1IN,R10 ; Busy?
nop
nop
nop
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bit.b #10000000b,R10
jnz chkLCD0
mov.b #00000000b,&P2OUT ; Function Set: RS(0), RW(0) (Write, ini E (low))
mov.b #00111000b,&P1OUT ; Function Set: DB(001110xx) (ini to 8-bit, sel 2 line disp, 5x8 char font)
bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bis.b #00000010b,&P2OUT ; Function Set: RW(1) (Read)
chkLCD1 bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
nop
nop
nop
nop
mov.b &P1IN,R10 ; Busy?
nop
nop
nop
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bit.b #10000000b,R10
jnz chkLCD1
mov.b #00000000b,&P2OUT ; Function Set: RS(0), RW(0) (Write, ini E (low))
mov.b #00001000b,&P1OUT ; Function Set: DB(00001000) (Display Off)
bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bis.b #00000010b,&P2OUT ; Function Set: RW(1) (Read)
chkLCD2 bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
nop
nop
nop
nop
mov.b &P1IN,R10 ; Busy?
nop
nop
nop
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bit.b #10000000b,R10
jnz chkLCD2
mov.b #00000000b,&P2OUT ; Function Set: RS(0), RW(0) (Write, ini E (low))
mov.b #00000001b,&P1OUT ; Function Set: DB(00000001) (Display Clear)
bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bis.b #00000010b,&P2OUT ; Function Set: RW(1) (Read)
chkLCD3 bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
nop
nop
nop
nop
mov.b &P1IN,R10 ; Busy?
nop
nop
nop
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bit.b #10000000b,R10
jnz chkLCD3
mov.b #00000000b,&P2OUT ; Function Set: RS(0), RW(0) (Write, ini E (low))
mov.b #00000110b,&P1OUT ; Function Set: DB(00000110) (Entry Mode: inc, no disp shift)
bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bis.b #00000010b,&P2OUT ; Function Set: RW(1) (Read)
chkLCD4 bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
nop
nop
nop
nop
mov.b &P1IN,R10 ; Busy?
nop
nop
nop
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bit.b #10000000b,R10
jnz chkLCD4
mov.b #00000000b,&P2OUT ; Function Set: RS(0), RW(0) (Write, ini E (low))
mov.b #00001110b,&P1OUT ; Function Set: DB(00001110) (turn on display)
bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bis.b #00000010b,&P2OUT ; Function Set: RW(1) (Read)
chkLCD5 bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
nop
nop
nop
nop
mov.b &P1IN,R10 ; Busy?
nop
nop
nop
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bit.b #10000000b,R10
jnz chkLCD5
mov.b #00000100b,&P2OUT ; Function Set: RW(0) (Write)
mov.b #01001000b,&P1OUT ; Function Set: DB(01001000) (write 'H')
bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
mov.b #00000010b,&P2OUT ; Function Set: RW(1) (Read)
chkLCD6 bis.b #00000001b,&P2OUT ; Execute: E(1) (toggle E)
nop
nop
nop
nop
nop
mov.b &P1IN,R10 ; Busy?
nop
nop
nop
nop
bic.b #00000001b,&P2OUT ; Execute: E(0) (toggle E)
bit.b #10000000b,R10
jnz chkLCD6
endloop xor.b #0fh,&P6OUT
jmp endloop
;--------------------------------------------------------------------------------
; Interrupt Vectors
;--------------------------------------------------------------------------------
.sect ".reset" ; MSP430 RESET Vector
.short RESET ;
.end
I’m trying to run this off of the OLIMEX msp430 proto board (simplest, just RS232) and powering the lcd off of 5v on 16->15 and 2->1. The code is drawn out to make sure that no preprocessing/optimization could be introducing problems.