- Mon Jul 17, 2006 11:53 pm
#15952
Hi everyone,
Well I too got myself on of the Nokia LCD ripoffs from Sparkfun a couple of months back. I have only now gotten around to making up a board to test it out (I make my own PCBs photographically).
The first problem I had was that the pin numbers written on the LCD module itself are in the opposite direction of the pinout supplied by Sparkfun (i.e. pin 1 was really pin 10 and vice versa).
Although it seems to be wired right now (the backlight is working) I just hope that I didn't destroy one of the 3.3V logic inputs with the 6.2V from the backlight when I plugged the display in wrong :/
Anyways I'm running a PIC18F2420. It's actually my first time with a PIC18 part (I've used hundreds of PIC16s) but migration seems straightforward enough (although there's a few gotchas when using MPASM commands that refer to the address line).
The point is that I'm not getting anything on the display. The backlight is on but no-one's home
Here's my code. If anyone can see any glaring errors it would be great if you could let me know. I suppose the biggest hassle is finding out if I have indeed fried an input or not.....
Thanks,
Zac
Well I too got myself on of the Nokia LCD ripoffs from Sparkfun a couple of months back. I have only now gotten around to making up a board to test it out (I make my own PCBs photographically).
The first problem I had was that the pin numbers written on the LCD module itself are in the opposite direction of the pinout supplied by Sparkfun (i.e. pin 1 was really pin 10 and vice versa).
Although it seems to be wired right now (the backlight is working) I just hope that I didn't destroy one of the 3.3V logic inputs with the 6.2V from the backlight when I plugged the display in wrong :/
Anyways I'm running a PIC18F2420. It's actually my first time with a PIC18 part (I've used hundreds of PIC16s) but migration seems straightforward enough (although there's a few gotchas when using MPASM commands that refer to the address line).
The point is that I'm not getting anything on the display. The backlight is on but no-one's home
Here's my code. If anyone can see any glaring errors it would be great if you could let me know. I suppose the biggest hassle is finding out if I have indeed fried an input or not.....
Thanks,
Zac
Code: Select all
;******************************************************************************
; Start of main program
;******************************************************************************
Main
call LCD_init
movlw RAMWR ; Writing pixels
call LCD_wr_cmd
movlw 0xff ; Number of pixels to transmit / 2
movwf pixel_cnt
pixel_loop
movlw 0xf0
call LCD_wr_data
movlw 0x0f
call LCD_wr_data
movlw 0x00
call LCD_wr_data
decfsz pixel_cnt, f
goto pixel_loop
bsf LED
movlw d'160'
movwf contrast
movlw VOLUP
call lcd_wr_cmd
call dly100ms
decfsz contrast
goto $ - 4
bcf LED
goto $
;******************************************************************************
; SUBROUTINES
;******************************************************************************
;------------------------------------------------------------
; LCD_INIT
; Initialises the LCD
;------------------------------------------------------------
LCD_INIT
bcf lcd_cs ; CS Low
bcf LCD_data ; Data low
bsf LCD_clk ; Clock high
bsf lcd_reset
bcf LCD_reset ; Reset LCD
bsf LCD_reset
bsf LCD_clk ; Set clock high
bsf LCD_data ; Data high
bsf LCD_clk
call dly100ms
movlw DISCTL ;display control
call lcd_wr_cmd
movlw 0x03
call lcd_wr_data
movlw 0x1A
call lcd_wr_data
movlw 0x0C
call lcd_wr_data
movlw 0x00
call lcd_wr_data
movlw COMSCN ; common scan direction
movlw 0x01
call lcd_wr_data
movlw OSCON ; oscillator on
call lcd_wr_cmd
movlw SLPOUT ; sleep out
call lcd_wr_cmd
movlw VOLCTR ; electronic volume control
call lcd_wr_cmd
movlw 0x05 ; cares about lower 6 bits V1 volume
call lcd_wr_data
movlw 0x0 ; cares about lower 3 bits 1+Rb/Ra, supposed to specify resistance
call lcd_wr_cmd
movlw PWRCTR ; power control
call lcd_wr_cmd
movlw 0x0f ; turn stuff on
call lcd_wr_data
movlw 0x64
call lcd_wr_data
movlw DISINV ; inverse display
call lcd_wr_cmd
movlw DATCTL ; Data control
call lcd_wr_cmd
movlw 0x00
call lcd_wr_data
movlw 0x00
call lcd_wr_data
movlw 0x01
call lcd_wr_data
movlw 0x00
call lcd_wr_data
movlw RGBSET8
call lcd_wr_cmd
movlw 0x00
call lcd_wr_data
movlw 0x02
call lcd_wr_data
movlw 0x04
call lcd_wr_data
movlw 0x06
call lcd_wr_data
movlw 0x08
call lcd_wr_data
movlw 0x0a
call lcd_wr_data
movlw 0x0c
call lcd_wr_data
movlw 0x0f
call lcd_wr_data
movlw 0x00
call lcd_wr_data
movlw 0x02
call lcd_wr_data
movlw 0x04
call lcd_wr_data
movlw 0x06
call lcd_wr_data
movlw 0x08
call lcd_wr_data
movlw 0x0a
call lcd_wr_data
movlw 0x0c
call lcd_wr_data
movlw 0x0f
call lcd_wr_data
movlw 0x00
call lcd_wr_data
movlw 0x05
call lcd_wr_data
movlw 0x0a
call lcd_wr_data
movlw 0x0f
call lcd_wr_data
movlw NOOP ; no op
call lcd_wr_cmd
movlw PASET ; page start/end ram
call lcd_wr_cmd
movlw 2 ; for some reason it starts at 2
call lcd_wr_data
movlw d'131'
call lcd_wr_data
movlw CASET ; column start/end ram
call lcd_wr_cmd
movlw 0x00
call lcd_wr_data
movlw d'131'
call lcd_wr_data
movlw DISON ; display on
call lcd_wr_cmd
call dly100ms
retlw 0x00 ; Done
;------------------------------------------------------------
; LCD_WR_DATA
; Transmits a data byte to the LCD
; Optimised for speed
; Data in W
;------------------------------------------------------------
LCD_WR_DATA
movwf temp0 ; Store data
bcf LCD_CS ; Select LCD
bsf LCD_DATA ; Indicate that data is being transmitted
bsf LCD_CLK ; Clock out bit
bcf LCD_CLK
rlcf temp0, f ; Get bit 7
bcf LCD_DATA ; Set data based on bit
btfsc status, c
bsf LCD_DATA
bsf LCD_CLK ; Clock out bit
bcf LCD_CLK
rlcf temp0, f ; Get bit 6
bcf LCD_DATA ; Set data based on bit
btfsc status, c
bsf LCD_DATA
bsf LCD_CLK ; Clock out bit
bcf LCD_CLK
rlcf temp0, f ; Get bit 5
bcf LCD_DATA ; Set data based on bit
btfsc status, c
bsf LCD_DATA
bsf LCD_CLK ; Clock out bit
bcf LCD_CLK
rlcf temp0, f ; Get bit 4
bcf LCD_DATA ; Set data based on bit
btfsc status, c
bsf LCD_DATA
bsf LCD_CLK ; Clock out bit
bcf LCD_CLK
rlcf temp0, f ; Get bit 3
bcf LCD_DATA ; Set data based on bit
btfsc status, c
bsf LCD_DATA
bsf LCD_CLK ; Clock out bit
bcf LCD_CLK
rlcf temp0, f ; Get bit 2
bcf LCD_DATA ; Set data based on bit
btfsc status, c
bsf LCD_DATA
bsf LCD_CLK ; Clock out bit
bcf LCD_CLK
rlcf temp0, f ; Get bit 1
bcf LCD_DATA ; Set data based on bit
btfsc status, c
bsf LCD_DATA
bsf LCD_CLK ; Clock out bit
bcf LCD_CLK
rlcf temp0, f ; Get bit 0
bcf LCD_DATA ; Set data based on bit
btfsc status, c
bsf LCD_DATA
bsf LCD_CLK ; Clock out bit
bcf LCD_CLK
bsf LCD_CS ; Deselect LCD
retlw 0x00 ; Done
; NOTE: LCD_WR_CMD is identical to lcd_wr_data except the initial bit is clear.