atmega16 & lcd 240x40

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Problem to initialize lcd display... Nothing show up!

EDIT:
I want to use it on character mode, character size 7x5
Contrast is ok.

Vikay and the chip onboard:
http://www.arianecorp.com/Graphi...
http://www.aet.cup.edu/ftp/eet/3...

; ********************** MACRO ******************************
.macro busyloop
waitbusyflag:	; check busyflag from lcd
cbi ddrc, 7		; change dataline PC7 to input
nop
sbic portc, 7
rjmp waitbusyflag
sbi ddrc, 7		; dataline back to default
.endmacro


.macro writedata
in temp, portd	; write instruction
cbr temp, (1<<pd1)+(1<<pd2) ;DATA REG. & WRITE
out portd, temp
sbi portd, 0	; enable high
.endmacro


.macro writeinstruction
in temp, portd	; write instruction
cbr temp, (1<<pd1) ;WRITE
sbr temp, (1<<pd2) ;INSTRUCTION REG.
out portd, temp
sbi portd, 0	; enable high
.endmacro


.macro write
nop
cbi portd, 0	; enable down
nop
nop
nop
nop
.endmacro

;************* LCD SECTION ****************************************
;
; PD0 = ENABLE; PD1 = R/W; PD2 = REGISTER SELECT; PC7 = BUSY FLAG
;
; REGISTER SELECT: RS	=1 INSTRUCTION REG.
; 						=0 DATA REG.
;
; 						FIRST SEND INSTRUCTION, THEN WRITE DATA
;
;
; R/W:					=1 READ
;						=0 WRITE
;
; EN					=1->0	DATA IS WRITTEN TO THE MODULE
;						=1		DATA CAN BE READ FROM THE MODUL
;********************************************************************


busyloop

;******* setup mode *******
writeinstruction	; 1. Mode Control:
ldi temp, 0x00
out portc, temp
write

writedata			; set command
ldi temp, 0x3c
out portc, temp
write


busyloop

;******* set character pitch *******
writeinstruction	; set instruction reg
ldi temp, 0x01
out portc, temp
write

writedata			; set command
ldi temp, 0xa5
out portc, temp
write

busyloop

;******* set number of characters *******
writeinstruction	; set instruction reg
ldi temp, 0x02
out portc, temp
write

writedata			; set command
ldi temp, 0x27
out portc, temp
write

busyloop

;******* set number of time divisions *******
writeinstruction	; set instruction reg
ldi temp, 0x03
out portc, temp
write

writedata			; set command
ldi temp, 0x27
out portc, temp
write

busyloop

;******* set cursor position *******
writeinstruction	; set instruction reg
ldi temp, 0x04
out portc, temp
write

writedata			; set command
ldi temp, 0x0a
out portc, temp
write

busyloop

;******* set display start low order address *******
writeinstruction	; set instruction reg
ldi temp, 0x08
out portc, temp
write

writedata			; set command
ldi temp, 0xb7
out portc, temp
write

busyloop

;******* set display start high order address *******
writeinstruction	; set instruction reg
ldi temp, 0x09
out portc, temp
write

writedata			; set command
ldi temp, 0xb7
out portc, temp
write

busyloop

;******* set cursor address (low) *******
writeinstruction	; set instruction reg
ldi temp, 0x0a
out portc, temp
write

writedata			; set command
ldi temp, 0x041
out portc, temp
write

busyloop

;******* set cursor address (high) *******
writeinstruction	; set instruction reg
ldi temp, 0x0b
out portc, temp
write

writedata			; set command
ldi temp, 0x42
out portc, temp
write

busyloop

;******* write display data *******
writeinstruction	; set instruction reg
ldi temp, 0x0c
out portc, temp
write

writedata			; set command
ldi temp, 0x41
out portc, temp
write

busyloop

inc store
end:

rjmp loop

Regards
heguli

Last Edited: Tue. Jan 2, 2007 - 03:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First you should make sure that the LCD is all right.
May be the contrust isn't suitable, so you see nothing.
Take a look at the "Application Diagram" at the bottom of page 2 in the datasheet(VK2040.pdf).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmega works with internal 4MHz clock, forgot to mention.

Regards
heguli

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Could these be equal?:

set display start low order address = 0x41
set display start high order address = 0x00

set cursor address (low) = 0x41
set cursor address (high) = 0x00

write display data = 0x41

Regards
heguli

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Heguli!

did you get it to initialized? I gave two of those displays and i have similar problem. Only way to get something to displayed, i put random data in tight loop to displaymodule, so i assume that display is ok

-welpe