PIC + MOP 2X8 no worky.
Posted: Mon Apr 02, 2007 10:37 pm
I saw this forum was empty so I decided to start it off. So, here's the background. After several months of having my MOP-AL82B-BYFY-25J-3IN sitting on my shelf I finally got around to trying to get it to work with a PIC project of mine.
I gone over the wiring and it's correct, but I just can't get it to quite work. I've followed the 8 bit flow chart on initialization and just can't get a cursor or a letter to show up. Here's a c/p of the code below. Maybe someone can see if I messed up somewhere. The clock speed on the chip is coming from a freq generator at 100Hz so I can watch things work slow so I'm pretty sure that it's not a high speed timing issue. I believe it's a step or two I don't know about.
Thanks in advance.
Oh, and I have the R/W line tied to ground for the time being in case you notice nothing about it in the code.
*****************************
#DEFINE E PORTC, 4
#DEFINE RS PORTC, 5
#DEFINE LCD PORTB
#DEFINE VOLT PORTC, 2
#DEFINE LED PORTC, 3
LIST R=DEC
INCLUDE "P16F870.INC"
CBLOCK 0x020
ENDC
ORG 0
MAINLINE
BCF STATUS, RP0
BCF STATUS, RP1
CLRF PORTA
CLRF LCD
CLRF PORTC
BSF STATUS, RP0
MOVLW 0X00
MOVWF (TRISA^ 0x080)
MOVWF (TRISB^ 0X080)
MOVWF (TRISC^ 0x080)
BCF STATUS, RP0
; INITIALIZE
; FUNTION SET
BSF VOLT; Activates logic power after ports get cleared.
NOP
NOP
NOP
BSF LED;Lets me see when I reach this spot.
BCF RS
BSF E
MOVLW 0X038
MOVWF LCD
BCF E
NOP
NOP
BSF E
MOVLW 0X038
MOVWF LCD
BCF E
; DISPLAY OFF
BSF E
MOVLW 0X008
MOVWF LCD
BCF E
NOP
NOP
; CLEAR DISPLAY
BSF E
MOVLW 0X001
MOVWF LCD
NOP
BCF E
nop
NOP
; DISPLAY ON
BSF E
MOVLW 0X0C
MOVWF LCD
NOP
BCF E
; MODE SET
BSF E
MOVLW 0X06
MOVWF LCD
NOP
BCF E
NOP
NOP
NOP
NOP
NOP
NOP
; WRITE "H"
BSF RS
BSF E
MOVLW 0X42
MOVWF LCD
BCF E
BCF RS
LOOP
NOP
NOP
GOTO LOOP
END
I gone over the wiring and it's correct, but I just can't get it to quite work. I've followed the 8 bit flow chart on initialization and just can't get a cursor or a letter to show up. Here's a c/p of the code below. Maybe someone can see if I messed up somewhere. The clock speed on the chip is coming from a freq generator at 100Hz so I can watch things work slow so I'm pretty sure that it's not a high speed timing issue. I believe it's a step or two I don't know about.
Thanks in advance.
Oh, and I have the R/W line tied to ground for the time being in case you notice nothing about it in the code.
*****************************
#DEFINE E PORTC, 4
#DEFINE RS PORTC, 5
#DEFINE LCD PORTB
#DEFINE VOLT PORTC, 2
#DEFINE LED PORTC, 3
LIST R=DEC
INCLUDE "P16F870.INC"
CBLOCK 0x020
ENDC
ORG 0
MAINLINE
BCF STATUS, RP0
BCF STATUS, RP1
CLRF PORTA
CLRF LCD
CLRF PORTC
BSF STATUS, RP0
MOVLW 0X00
MOVWF (TRISA^ 0x080)
MOVWF (TRISB^ 0X080)
MOVWF (TRISC^ 0x080)
BCF STATUS, RP0
; INITIALIZE
; FUNTION SET
BSF VOLT; Activates logic power after ports get cleared.
NOP
NOP
NOP
BSF LED;Lets me see when I reach this spot.
BCF RS
BSF E
MOVLW 0X038
MOVWF LCD
BCF E
NOP
NOP
BSF E
MOVLW 0X038
MOVWF LCD
BCF E
; DISPLAY OFF
BSF E
MOVLW 0X008
MOVWF LCD
BCF E
NOP
NOP
; CLEAR DISPLAY
BSF E
MOVLW 0X001
MOVWF LCD
NOP
BCF E
nop
NOP
; DISPLAY ON
BSF E
MOVLW 0X0C
MOVWF LCD
NOP
BCF E
; MODE SET
BSF E
MOVLW 0X06
MOVWF LCD
NOP
BCF E
NOP
NOP
NOP
NOP
NOP
NOP
; WRITE "H"
BSF RS
BSF E
MOVLW 0X42
MOVWF LCD
BCF E
BCF RS
LOOP
NOP
NOP
GOTO LOOP
END