❓ Help ATMEGA32 LCD Continuous Refresh

Status
Not open for further replies.

Arcturus

Lazy Dev
Contributor
Magandang umaga PHCians!
Baka po may makatulong sakin dito sa Assembly Language. Refresh po kasi ng refresh yung LCD ko sa Simulation sa Proteus.
AVR 7.0 po yung gamit kong software.
Ito po yung Sample video:


Ito po yung Code:
[CODE title="LCD Interfacing in Atmega32"].equ en = PC3
.equ rw = PC2
.equ rs = PC1

.org 0x00

MAIN:
cli
ldi R16,high(ramend)
out sph,R16
ldi R16,low(ramend)
out spl,R16

ldi R16, 0xff
out DDRC, R16
out DDRD, R16

ldi R16,0x00
out PORTC,R16
out PORTD,R16


call LCDinit

ldi r18,0x00
out DDRA,r18

call LOOP
call MAIN


LOOP:
in R18, PINA

cpi R18, 0x01 ; Low Level Swtich is ON
BREQ MESSAGE1

cpi R18, 0x02 ; Medium Level Swtich is ON
BREQ MESSAGE2

cpi R18, 0x04 ; High Level Swtich is ON
BREQ MESSAGE3

cpi R18, 0x03 ; Low and Medium Level Swtich is ON
BREQ MESSAGE2

cpi R18, 0x05 ; Low and High Level Swtich is ON
BREQ MESSAGE3

cpi R18, 0x06 ; Medium and High Level Swtich is ON
BREQ MESSAGE3

cpi R18, 0x07 ; All Level Swtich is ON
BREQ MESSAGE3
BRNE MESSAGE4 ; No Swtich is ON

ret

MESSAGE1:
ldi zh,high(mesg1<<1)
ldi zl,low(mesg1<<1)
call DISPLAYSTRING
ret

MESSAGE2:
ldi zh,high(mesg2<<1)
ldi zl,low(mesg2<<1)
call DISPLAYSTRING
ret

MESSAGE3:
ldi zh, high(mesg3<<1)
ldi zl, low(mesg3<<1)
call DISPLAYSTRING
ret

MESSAGE4:
ldi zh, high(mesg4<<1)
ldi zl, low(mesg4<<1)
call DISPLAYSTRING
ret

con:
rjmp con

LCDinit:
ldi r16,0x01
call cmdwrite
ldi r16,0x06
call cmdwrite
ldi r16,0x38
call cmdwrite
ldi r16,0x0c
call cmdwrite
ret

cmdwrite:
cbi PORTC,en
cbi PORTC,rs
cbi PORTC,rw
out PORTD,R16
sbi PORTC,en
call delay
cbi PORTC,en
ret

DISPLAYSTRING:

clr R0
cp R16,R0
lpm R16,z+
breq check
call datawrt
rjmp DISPLAYSTRING

check:
ret

datawrt:
cbi PORTC,en
sbi PORTC,rs
cbi PORTC,rw
out PORTD,r16
sbi PORTC,en
call delay
cbi PORTC,en
ret

delay:
push R16
push R17

a1:ldi R17,0xFF
a2:dec R17
brne a2
dec R16
brne a1
pop R16
pop R17
ret

mesg1: .db "LOW LEVEL...!", 0x00
mesg2: .db "MEDIUM LEVEL..!", 0x00
mesg3: .db "HIGH LEVEL...", 0x00
mesg4: .db "NO LEVEL...", 0x00[/CODE]

Ito rin po yung proteus file
You do not have permission to view the full content of this post. Log in or register now.
 
Status
Not open for further replies.

About this Thread

  • 0
    Replies
  • 288
    Views
  • 1
    Participants
Last reply from:
Arcturus

Trending Topics

Online now

Members online
1,066
Guests online
919
Total visitors
1,985

Forum statistics

Threads
2,274,676
Posts
28,957,530
Members
1,233,398
Latest member
hades00
Back
Top