Bazi13
Newbie level 3
ks0108b
Hi, here r many posts about gLCD and KS0108B, but I didn't found many about 192x64 gLCD. I'm trying to writte somenthing on that gLCD using ATmega32 in asm. I'have never use any gLCD and I feel litle confused. I wrote a short programm and i think I can't controle it:/. Could You tell me what is wrong in this :
.include "m32def.inc"
;*********************** *************************
.equ DANA = PORTD ;D
.equ STER = PORTB ;B
.equ RS = 2
.equ RW = 3
.equ E = 4
.equ CS1 = 5
.equ CS2 = 6
.equ CS3 = 7
.equ SYS_FREQ = 16
;*********************** PROG***************************
.cseg
;
ldi R16, high(RAMEND)
out SPH, R16
ldi R16, low(RAMEND)
out SPL, R16
ldi R16, 0xFF
out DDRD, R16
out DDRB, R16
cbi DDRB, DDB1
cbi DDRB, DDB0
ldi R16, 0x00
out DDRA, R16
out DDRC, R16
ldi R16, 0x00
out PORTA, R16
out PORTC, R16
LCD_ON:
sbi STER, E
nop
cbi STER, E
rcall wait_450ns
cbi STER, RW
cbi STER, RS
cbi STER, CS1
cbi STER, CS2
cbi STER, CS3
sbi STER, E
rcall wait_450ns
ldi R20, 0x3F ;DISPLAY ON
out DANA, R20
rcall wait_450ns
cbi STER, E
nop
rjmp stan
ldi R20, 0x50 ;set Y address
rjmp instr
rjmp stan
ldi R20, 0xBB ;set X address
rjmp instr
rjmp stan
ldi R20, 0xC3 ;set Z address
rjmp instr
rjmp stan
ldi R20, 0xE7
rjmp data
rjmp stan
kon:
rjmp kon
instr:
sbi STER, E
nop
cbi STER, E
rcall wait_450ns
cbi STER, RW
sbi STER, RS
cbi STER, CS1
cbi STER, CS2
cbi STER, CS3
sbi STER, E
rcall wait_450ns
out DANA, R20
rcall wait_450ns
cbi STER, E
nop
ret
data:
sbi STER, E
nop
cbi STER, E
rcall wait_450ns
cbi STER, RW
cbi STER, RS
cbi STER, CS1
sbi STER, CS2
sbi STER, CS3
sbi STER, E
rcall wait_450ns
out DANA, R20
rcall wait_450ns
cbi STER, E
nop
ret
stan:
ldi R16, 0x00
out DDRD, R16
petla_stan:
sbi STER, E
nop
cbi STER, E
rcall wait_450ns
sbi STER, RW
cbi STER, RS
sbi STER, E
rcall wait_450ns
in R20, PIND
cbi STER, E
nop
nop
sbrc R20, 7
rjmp wait_450ns
ldi R16, 0xFF
out DDRD, R16
ret
function instr - instruction, function stan- checks bussy flag of gLCD
plizz help me, i don't know why tah doesn't work.... gLCD "draw" some pixels, but I doesn't controlle which ones
Hi, here r many posts about gLCD and KS0108B, but I didn't found many about 192x64 gLCD. I'm trying to writte somenthing on that gLCD using ATmega32 in asm. I'have never use any gLCD and I feel litle confused. I wrote a short programm and i think I can't controle it:/. Could You tell me what is wrong in this :
.include "m32def.inc"
;*********************** *************************
.equ DANA = PORTD ;D
.equ STER = PORTB ;B
.equ RS = 2
.equ RW = 3
.equ E = 4
.equ CS1 = 5
.equ CS2 = 6
.equ CS3 = 7
.equ SYS_FREQ = 16
;*********************** PROG***************************
.cseg
;
ldi R16, high(RAMEND)
out SPH, R16
ldi R16, low(RAMEND)
out SPL, R16
ldi R16, 0xFF
out DDRD, R16
out DDRB, R16
cbi DDRB, DDB1
cbi DDRB, DDB0
ldi R16, 0x00
out DDRA, R16
out DDRC, R16
ldi R16, 0x00
out PORTA, R16
out PORTC, R16
LCD_ON:
sbi STER, E
nop
cbi STER, E
rcall wait_450ns
cbi STER, RW
cbi STER, RS
cbi STER, CS1
cbi STER, CS2
cbi STER, CS3
sbi STER, E
rcall wait_450ns
ldi R20, 0x3F ;DISPLAY ON
out DANA, R20
rcall wait_450ns
cbi STER, E
nop
rjmp stan
ldi R20, 0x50 ;set Y address
rjmp instr
rjmp stan
ldi R20, 0xBB ;set X address
rjmp instr
rjmp stan
ldi R20, 0xC3 ;set Z address
rjmp instr
rjmp stan
ldi R20, 0xE7
rjmp data
rjmp stan
kon:
rjmp kon
instr:
sbi STER, E
nop
cbi STER, E
rcall wait_450ns
cbi STER, RW
sbi STER, RS
cbi STER, CS1
cbi STER, CS2
cbi STER, CS3
sbi STER, E
rcall wait_450ns
out DANA, R20
rcall wait_450ns
cbi STER, E
nop
ret
data:
sbi STER, E
nop
cbi STER, E
rcall wait_450ns
cbi STER, RW
cbi STER, RS
cbi STER, CS1
sbi STER, CS2
sbi STER, CS3
sbi STER, E
rcall wait_450ns
out DANA, R20
rcall wait_450ns
cbi STER, E
nop
ret
stan:
ldi R16, 0x00
out DDRD, R16
petla_stan:
sbi STER, E
nop
cbi STER, E
rcall wait_450ns
sbi STER, RW
cbi STER, RS
sbi STER, E
rcall wait_450ns
in R20, PIND
cbi STER, E
nop
nop
sbrc R20, 7
rjmp wait_450ns
ldi R16, 0xFF
out DDRD, R16
ret
function instr - instruction, function stan- checks bussy flag of gLCD
plizz help me, i don't know why tah doesn't work.... gLCD "draw" some pixels, but I doesn't controlle which ones