Od kilku dni męczę ten wyswietlacz, a on nic. Tzn. jak odpowiednio zrobię zwarę to widać dwa rzędy prostokącików, ale nie o to chodzi.
Pod Bascomem nie mogłem, więc spróbowałem w ASM:
Może kod nie jest doskonały. Chodziło mi tylko o wyswietlenie choćby jednej literki!! Sterownik to HD44780. Jeśli ktoś mógłby zweryfikować kod...
PS a jesli ktos ma .hex dla ZL1AVR to też proszę o kontakt.
Pod Bascomem nie mogłem, więc spróbowałem w ASM:
.include "tn2313def.inc"
;*******************************************************
.list
.listmac
;-----------------------------------------------------------------------------
.macro ldz
ldi r30,low(@0)
ldi r31,high(@0)
.endm
;-----------------------------------------------------------------------------
.def acc = r16
.def param = r17
;-----------------------------------------------------------------------------
.dseg
.cseg
;
.org 0
rjmp ResetProcessor ;
;-----------------------------------------------------------------------------
.org INT0addr ;External Interrupt0 Vector ...
reti ;
;-----------------------------------------------------------------------------
.org INT1addr ;External Interrupt1 Vector ...
reti ;
;-----------------------------------------------------------------------------
.org ICP1addr ;Input Capture1 Interrupt Vector ...
reti ;
;-----------------------------------------------------------------------------
.org OC1addr ;Output Compare1A Interrupt Vector ...
reti ;
;-----------------------------------------------------------------------------
.org OVF1addr ;Overflow1 Interrupt Vector Address
reti ;
;-----------------------------------------------------------------------------
.org OVF0addr ;Overflow0 Interrupt Vector Address
reti ;
;-----------------------------------------------------------------------------
.org URXCaddr ;UART Receive Complete Interrupt ...
reti ;
;-----------------------------------------------------------------------------
.org UDREaddr ;UART Data Register Empty Interrupt ...
reti ;
;-----------------------------------------------------------------------------
.org UTXCaddr ;UART Transmit Complete Interrupt ...
reti ;
;-----------------------------------------------------------------------------
.org ACIaddr ;Analog Comparator Interrupt Vector ...
reti ;
;-----------------------------------------------------------------------------
HardwareInit : ;PROCEDURE HardwareInit ;
;**************** ;BEGIN (* HardwareInit *)
ldi acc,0xFF ; [DDRB] := 0xFF ; -> PORT B - output
out DDRB,acc ;
ret ;END (* HardwareInit *) ;
;-----------------------------------------------------------------------------
LongDelay : ;PROCEDURE LongDelay ( ) ;
;**************** ;BEGIN (* LongDelay *)
ldz 0 ;
LoDe_0 : ;
adiw zl,1 ;
mov acc,zl ;
or acc,zh ;
brne LoDe_0 ;
ret ;END (* LongDelay *) ;
;-----------------------------------------------------------------------------
WaitOnStartLCD : ;PROCEDURE WaitOnStartLCD ( ) ;
;**************** ;BEGIN (* WaitOnStartLCD *)
rcall LongDelay ; LongDelay ( ) ;
rcall LongDelay ; LongDelay ( ) ;
rcall LongDelay ; LongDelay ( ) ;
rcall LongDelay ; LongDelay ( ) ;
rcall LongDelay ; LongDelay ( ) ;
rcall LongDelay ; LongDelay ( ) ;
rcall LongDelay ; LongDelay ( ) ;
rcall LongDelay ; LongDelay ( ) ;
ret ;END (* WaitOnStartLCD *) ;
;-----------------------------------------------------------------------------
LCDDelay : ;PROCEDURE LCDDelay ( ) ;
;**************** ;BEGIN (* LCDDelay *)
ldi acc,0x20 ;
Delay_1 : ;
nop ;
dec acc ;
brne Delay_1 ;
ret ;END (* LCDDelay *) ;
;-----------------------------------------------------------------------------
EStrobe : ;PROCEDURE EStrobe ( ) ;
;**************** ;BEGIN (* EStrobe *)
sbi PORTB,3 ; [LCD.E=1] ;
rcall LCDDelay ; LCDDelay ( ) ;
cbi PORTB,3 ; [LCD.E=0] ;
ret ;END (* EStrobe *) ;
;-----------------------------------------------------------------------------
Delay37ms : ;PROCEDURE Delay37ms ( ) ;
;**************** ;BEGIN (* Delay37ms *)
ldi acc,0x80 ;
D37_0 : ;
inc acc ;
brne D37_0 ;
ret ;END (* Delay37ms *) ;
;-----------------------------------------------------------------------------
InitialiseLCD : ;PROCEDURE InitialiseLCD ( ) ;
;**************** ;BEGIN (* InitialiseLCD *)
;1
Sbi PORTB,5
cbi PORTB,2
rcall EStrobe ; EStrobe ( ) ;
;2--------------
rcall Delay37ms ; Delay37ms ( ) ;
Sbi PORTB,5
rcall Estrobe
Cbi Portb,5
Sbi PORTB,7
rcall Estrobe
;3--------------
rcall Delay37ms ; Delay37ms ( ) ;
Cbi Portb,7
Sbi PORTB,5
rcall Estrobe
Cbi Portb,5
Sbi PORTB,7
rcall Estrobe
;4--------------
rcall Delay37ms ; Delay37ms ( ) ;
Cbi Portb,7
rcall Estrobe
Sbi Portb,6
Sbi PORTB,7
rcall Estrobe
;5--------------
rcall Delay37ms ; Delay37ms ( ) ;
Cbi Portb,7
Cbi Portb,6
rcall Estrobe
Sbi PORTB,6
Sbi Portb,5
rcall Estrobe
ret
;-----------------------------------------------------------------------------
Delay_1520u : ;PROCEDURE Delay_1520u ( ) ;
;**************** ;BEGIN (* Delay_1520u *)
ldz 0xF600 ;
D1520_0 : ;
adiw zl,1 ;
mov acc,zl ;
or acc,zh ;
brne D1520_0 ;
ret ;END (* Delay_1520u *) ;
;-----------------------------------------------------------------------------
ResetProcessor : ;
ldi acc,LOW(RAMEND) ;
out SPL,acc ;
Main : ;BEGIN (* Main *)
rcall HardwareInit
sei
rcall WaitOnStartLCD
rcall InitialiseLCD
rcall Estrobe
Sbi Portb,4
rcall Estrobe
rcall Delay_1520u
Sbi PORTB,2
Cbi Portb,4
Sbi Portb,5
Sbi Portb,6
rcall Estrobe
Sbi Portb,4
Cbi Portb,5
Cbi Portb,6
rcall Estrobe
rcall Delay37ms
rcall Delay37ms
rcall Delay37ms
Main_0 : rjmp Main_0 ; HALT ;
.exit
Może kod nie jest doskonały. Chodziło mi tylko o wyswietlenie choćby jednej literki!! Sterownik to HD44780. Jeśli ktoś mógłby zweryfikować kod...
PS a jesli ktos ma .hex dla ZL1AVR to też proszę o kontakt.