$map
$regfile = "m328pdef.dat"
$crystal = 8000000
$hwstack = 32
$swstack = 48
$framesize = 16
$baud = 9600
Dim I As Byte
Dim I1 As Byte
Dim B1 As Byte
Dim A As Byte
Dim Lcd_string As String * 16
Dim Character(17) As Byte At Lcd_string Overlay
Dim Bx As Byte
Dim A1 As Byte , Strlen As Byte
Dim Hb As Byte , Lb As Byte , Cx As Byte
''Declare Sub Send(byval Bx As Byte)
Declare Sub Text(byval Lcdstring As String)
Config Portb.2 = Output
Set Alias Portb.2
Waitms 200
Gosub Init
Gosub Cls1
Do
'Print "_x3=" ; Character(a1)
'text("#AbC:1234567890*")
End
Loop
Sub Text(byval Lcdstring As String)
Strlen = Len(lcdstring)
Lcd_string = Lcdstring
For A1 = 1 To Strlen
Cx = Character(a1)
Gosub Convert
Next
End Sub
Convert:
Hb.1 = Cx.7
Hb.2 = Cx.6
Hb.3 = Cx.5
Hb.4 = Cx.4
Gosub Preout_txt_h
Lb.1 = Cx.3
Lb.2 = Cx.2
Lb.3 = Cx.1
Lb.4 = Cx.0
Gosub Preout_txt_l
Return
Preout_txt_h:
Bx = 96 : Gosub Send
Bx = Hb + 96 : Gosub Send
Bx = Hb + 64 : Gosub Send
Return
Preout_txt_l:
Bx = 96 : Gosub Send
Bx = Lb + 96 : Gosub Send
Bx = Lb + 64 : Gosub Send
Return
Preout_cmd:
Bx = 32 : Gosub Send
Bx = B1 + 32 : Gosub Send
Bx = B1 : Gosub Send
Return
'**********************************подпрограмма отправки в НС595*****************************'
'Sub Send(byval Bx As Byte)
Send:
For I = 0 To 7
A = Bx.i
Esli0:
lds R16 , {A}
cpi R16 , 0
BREQ send0
rjmp Esli1:
Send0:
cbi PORTB,PB2
ldi r18, 40
L1:
dec r18
brne L1
sbi PORTB,PB2
ldi r18, 93
L2:
Dec R18
brne L2
nop
Esli1:
lds R16 , {A}
cpi R16 , 1
BREQ send1
rjmp Выход
Send1:
cbi PORTB,PB2
sbi PORTB,PB2
lpm
lpm
rjmp Выход:
Выход:
Next I
'<latch>'
cbi PORTB,PB2
Wait200:
ldi r18, 3
ldi r19, 19
L3:
dec r19
brne L3
dec r18
brne L3
sbi PORTB,PB2
Wait300:
ldi r18, 4
ldi r19, 29
L4:
dec r19
brne L4
dec r18
brne L4
'<latch>'
'End Sub
Return
'**********************************подпрограмма отправки в НС595*****************************'
Cls1:
Restore Data_cls 'point to stored data
For I1 = 1 To 2 'for number of data items
Read B1
Gosub Preout_cmd
RCALL Waitms2
Next I1
Return
Init:
Restore Data_init 'point to stored data
For I1 = 1 To 10 'for number of data items
Read B1
Gosub Preout_cmd
RCALL Waitms2
Next I1
Return
Waitms2:
ldi r18, 21
ldi r19, 199
L5:
dec r19
brne L5
dec r18
brne L5
ret
Data_init:
Data 24 , 24 , 24 , 8 , 8 , 2 , 0 , 30 , 0 , 4
Data_cls:
Data 0 , 16