- 阅读权限
- 10
- UID
- 398
- 帖子
- 13
- 精华
- 0
- 注册时间
- 2013-5-18
- 在线时间
- 3 小时
- UID
- 398
- 帖子
- 13
- 精华
- 0
- 注册时间
- 2013-5-18
- 在线时间
- 3 小时
|
$regfile = "m8def.dat"
$crystal = 1000000
$baud = 9600
Config Timer0 = Timer , Prescale = 8 '定义T0为定时器,8分频
On Timer0 T0_interrupt '定时器T0溢出指向T0_interrupt中断程序
Config Portd = Output 'PORTD口定义为输出,控制各段
Config Portc = Output 'PORTC口定义为输出,控制公共端
Leds Alias Portd 'PORTD口别名定义为Leds
Ledv Alias Portc 'PORTC口别名定义为Ledv
'Dim Digital As Word '定义变量
Dim Led_code(10)as Byte
Dim Led_seg(4)as Byte
Dim Led_disp(4) As Byte
Dim Temp As Byte
Dim I As Byte
Enable Interrupts '全局中断使能
Enable Timer0 '定时器中断使能
Restore Digital_code
For I = 1 To 10
Read Led_code(i)
Next
Restore Digtal_seg
For I = 1 To 4
Read Led_seg(i)
Next
Do
Idle '单片机进入空闲状态
Loop
End
T0_interrupt: 'Timer0中断执行程序
Led_disp(1) = 1
Led_disp(2) = 2
Led_disp(3) = 3
Led_disp(4) = 4
For I = 1 To 4
Ledv = &H00
Leds = &HFF
Temp = Led_disp(i)
Leds = Lookup(temp , Digital_code)
Ledv = Led_seg(i)
Next
Return
Digital_code:
Data &B11000000 , &B11111001 , &B10100100 , &B10110000 , &B10011001
Data &B10010010 , &B10000010 , &B11111000 , &B10000000 , &B10010000
Digtal_seg:
Data &B00000001 , &B00000010 , &B00000100 , &B00001000
|
|