- 阅读权限
- 100
- UID
- 45
- 帖子
- 31
- 精华
- 0
- 注册时间
- 2013-2-27
- 在线时间
- 29 小时
- UID
- 45
- 帖子
- 31
- 精华
- 0
- 注册时间
- 2013-2-27
- 在线时间
- 29 小时
|
'当A1=0,A0=0时,PA口被选择;
'当A1=0,A0=1时,PB口被选择;
'当A1=1,A0=0时,PC口被选择;
'当A1=1.A0=1时,控制寄存器被选择.
'CS:芯片选择信号线,当这个输入引脚为低电平时,即/CS=0时,表示芯片被选中,允许8255与CPU进行通讯;/CS=1时,8255无法与CPU做数据传输.
'RD:读信号线,当这个输入引脚为低跳变沿时,即/RD产生一个低脉冲且/CS=0时,允许8255通过数据总线向CPU发送数据或状态信息,即CPU从8255读取信息或数据。
'WR:写入信号,当这个输入引脚为低跳变沿时,即/WR产生一个低脉冲且/CS=0时,允许CPU将数据或控制字写入8255
$regfile = "m8515.dat"
$crystal = 2000000
Config Timer1 = Timer , Prescale = 64
Timer1 = 64599
Ddre = &B00000010
Porte.1 = 1
Ddra = &B11111111
Porta = &B11111111
Scun Alias Porte.1
Scun = 1
A0 Alias Porta.0
A1 Alias Porta.1
Cs Alias Porta.2
Sj Alias Porta
Config Pind.6 = Output
Config Pind.7 = Output
Wr Alias Portd.6
Wr = 1
Rd Alias Portd.7
Rd = 1
Cs = 0
'数码馆显示变量
Dim H As Byte
Dim M As Byte
Dim D As Byte
H = 13
M = 2
D = 14
Dim Hg As Byte
Dim Hs As Byte
Dim Mg As Byte
Dim Ms As Byte
Dim Dg As Byte
Dim Ds As Byte
'定时器
Dim Dsq As Byte
'按键
Dim Aj As Byte
'装入数组
Dim I As Byte
On Ovf1 Timer1_isr
Enable Timer1
Start Timer1
Enable Interrupts
'''''''''''''''''''''''''''''''
Dim A(10) As Byte
Restore Daima
For I = 1 To 10
Read A(i)
Next
'-----------------------------------------------------------------
Do
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Hg = H Mod 10
Hg = Hg + 1
Hs = H / 10
Hs = Hs + 1
Gosub Wei
Sj = &B00000010
Gosub Xie
'Waitms 10
Gosub Shuju
Sj = A(hg)
Gosub Xie
Waitms 5
Gosub Wei
Sj = &B00000001
Gosub Xie
'Waitms 10
Gosub Shuju
Sj = A(hs)
Gosub Xie
Waitms 5
'''''''''''''''''''''''''''''''''
Mg = M Mod 10
Mg = Mg + 1
Ms = M / 10
Ms = Ms + 1
Gosub Wei
Sj = &B00001000
Gosub Xie
'Waitms 10
Gosub Shuju
Sj = A(ms)
Gosub Xie
Waitms 5
Gosub Wei
Sj = &B00010000
Gosub Xie
'Waitms 10
Gosub Shuju
Sj = A(mg)
Gosub Xie
Waitms 5
''''''''''''''''''''''''''''''
Dg = D Mod 10
Dg = Dg + 1
Ds = D / 10
Ds = Ds + 1
Gosub Wei
Sj = &B01000000
Gosub Xie
'Waitms 10
Gosub Shuju
Sj = A(ds)
Gosub Xie
Waitms 5
Gosub Wei
Sj = &B10000000
Gosub Xie
'Waitms 10
Gosub Shuju
Sj = A(dg)
Gosub Xie
Waitms 5
''''''''''''''''''''''''''''''''''
Gosub Wei
Sj = &B00000100
Gosub Xie
'Waitms 10
Gosub Shuju
Sj = &B10111111
Gosub Xie
Waitms 5
'''''''''''''''''''''''''''''
Gosub Wei
Sj = &B00100000
Gosub Xie
'Waitms 10
Gosub Shuju
Sj = &B10111111
Gosub Xie
Waitms 5
Gosub Du
Loop
End
Shuju:
'
Wr = 1
Sj = &B11111111
A1 = 0
A0 = 0
Cs = 0
Scun = 1
Scun = 0
Waitus 5
Wr = 0
Return
Wei:
Wr = 1
Sj = &B00000000
A1 = 0
A0 = 1
Cs = 0
'Waitus 30
Scun = 1
Scun = 0
Waitus 5
Wr = 0
'Waitus 10
'Scun = 1
'Cs = 0
Return
Xie:
'Cs = 0
Wr = 1
Wr = 0
Waitus 5
'Wr = 1
Return
'==================================================================================
Du:
'读C 口数据的子程序
Sj = &B11111111
A1 = 1
A0 = 0
Cs = 0
Wr = 1
Scun = 1
Scun = 0
'以上选中C口
Waitus 5
'Scun = 1
Ddra = &B00000000
Sj = &B11111111
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Rd = 0
Waitus 20
Aj = Pina
Rd = 1
If Aj = &B11111110 Then
Start Timer1
End If
If Dsq > 6 And Aj = &B11111110 Then
Incr H
Dsq = 0
Stop Timer1
End If
If Aj = &B11111011 Then
Start Timer1
End If
If Dsq > 6 And Aj = &B11111011 Then
Incr M
Stop Timer1
Dsq = 0
End If
If Aj = &B11101111 Then
Start Timer1
End If
If Dsq > 6 And Aj = &B11101111 Then
Incr D
Stop Timer1
Dsq = 0
End If
Ddra = &B11111111
Return
Timer1_isr:
Timer1 = 64599
Incr Dsq
Return
Daima:
Data &B11000000 , &B11111001 , &B10100100 , &B10110000 , &B10011001
Data &B10010010 , &B10000010 , &B11111000 , &B10000000 , &B10011000
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
|