?? timer.lis
字號:
.module Timer.c
.area vector(rom, abs)
.org 14
000E 19C0 rjmp _Timer0OverInter
.area data(ram, con, rel)
0000 _LightCount::
0000 .blkb 2
.area idata
0000 0000 .word 0
.area data(ram, con, rel)
0002 .dbfile E:\羅鵬\工作資料\工作記錄\CAN\程序\完成版本\Timer.c
0002 .dbsym e LightCount _LightCount i
0002 _KeyTime::
0002 .blkb 1
.area idata
0002 00 .byte 0
.area data(ram, con, rel)
0003 .dbfile E:\羅鵬\工作資料\工作記錄\CAN\程序\完成版本\Timer.c
0003 .dbsym e KeyTime _KeyTime c
0003 _KeyStatus::
0003 .blkb 1
.area idata
0003 00 .byte 0
.area data(ram, con, rel)
0004 .dbfile E:\羅鵬\工作資料\工作記錄\CAN\程序\完成版本\Timer.c
0004 .dbsym e KeyStatus _KeyStatus c
.area text(rom, con, rel)
0000 .dbfile E:\羅鵬\工作資料\工作記錄\CAN\程序\完成版本\Timer.c
0000 .dbfunc e KeyInput _KeyInput fc
0000 ; KeyData -> R20
0000 ; BitData -> R20
.even
0000 _KeyInput::
0000 00D0 rcall push_gset1
0002 402F mov R20,R16
0004 .dbline -1
0004 .dbline 15
0004 ; #include "iom8515v.h"
0004 ; #include "macros.h"
0004 ; #include "MAIN.h"
0004 ;
0004 ;
0004 ; #pragma interrupt_handler Timer0OverInter:8
0004 ; uint LightCount=0;
0004 ; uchar KeyTime=0;
0004 ; uchar Key1,Key2,Key3;
0004 ; uchar KeyStatus=0;
0004 ; /*****************************************
0004 ; 讀按鍵輸入口子程序
0004 ; ******************************************/
0004 ; uchar KeyInput(uchar BitData)
0004 ; {
0004 .dbline 17
0004 ; uchar KeyData;
0004 ; KeyData=(PIND &= (1 << BitData ));
0004 01E0 ldi R16,1
0006 142F mov R17,R20
0008 00D0 rcall lsl8
000A 20B2 in R2,0x10
000C 2022 and R2,R16
000E 20BA out 0x10,R2
0010 422D mov R20,R2
0012 .dbline 18
0012 ; if(KeyData == 0)
0012 2220 tst R2
0014 11F4 brne L2
0016 .dbline 19
0016 ; return(1);
0016 01E0 ldi R16,1
0018 01C0 rjmp L1
001A L2:
001A .dbline 21
001A ; else
001A ; return(0);
001A 0027 clr R16
001C .dbline -2
001C L1:
001C 00D0 rcall pop_gset1
001E .dbline 0 ; func end
001E 0895 ret
0020 .dbsym r KeyData 20 c
0020 .dbsym r BitData 20 c
0020 .dbend
0020 .dbfunc e Timer0Ini _Timer0Ini fV
.even
0020 _Timer0Ini::
0020 .dbline -1
0020 .dbline 25
0020 ; }
0020 ;
0020 ; void Timer0Ini(void)
0020 ; {
0020 .dbline 26
0020 ; TCCR0 = 0x00;
0020 2224 clr R2
0022 23BE out 0x33,R2
0024 .dbline 27
0024 ; TCNT0 = 0xC2; //定時1ms
0024 82EC ldi R24,194
0026 82BF out 0x32,R24
0028 .dbline 28
0028 ; TCCR0 = 0x04; //256分頻
0028 84E0 ldi R24,4
002A 83BF out 0x33,R24
002C .dbline 29
002C ; TIMSK = 0x02; //開定時器0溢出中斷
002C 82E0 ldi R24,2
002E 89BF out 0x39,R24
0030 .dbline -2
0030 L4:
0030 .dbline 0 ; func end
0030 0895 ret
0032 .dbend
0032 .dbfunc e Timer0OverInter _Timer0OverInter fV
.even
0032 _Timer0OverInter::
0032 2A92 st -y,R2
0034 3A92 st -y,R3
0036 8A93 st -y,R24
0038 9A93 st -y,R25
003A EA93 st -y,R30
003C 2FB6 in R2,0x3f
003E 2A92 st -y,R2
0040 .dbline -1
0040 .dbline 33
0040 ; }
0040 ;
0040 ; void Timer0OverInter(void)
0040 ; {
0040 .dbline 34
0040 ; TCNT0 = 0xC2; //恢復定時器初值
0040 82EC ldi R24,194
0042 82BF out 0x32,R24
0044 .dbline 35
0044 ; KeyTime++; //按鍵間隔時間計數器累加
0044 80910200 lds R24,_KeyTime
0048 8F5F subi R24,255 ; addi 1
004A 80930200 sts _KeyTime,R24
004E .dbline 36
004E ; LightCount++;
004E 80910000 lds R24,_LightCount
0052 90910100 lds R25,_LightCount+1
0056 0196 adiw R24,1
0058 90930100 sts _LightCount+1,R25
005C 80930000 sts _LightCount,R24
0060 .dbline 37
0060 ; if(KeyTime == 6) //取6ms的時間間隔
0060 80910200 lds R24,_KeyTime
0064 8630 cpi R24,6
0066 F1F4 brne L6
0068 .dbline 38
0068 ; {
0068 .dbline 39
0068 ; KeyTime=0;
0068 2224 clr R2
006A 20920200 sts _KeyTime,R2
006E .dbline 40
006E ; if((Key1 == 0) && (Key2 == 1) && (Key3 == 1))
006E 20900200 lds R2,_Key1
0072 2220 tst R2
0074 61F4 brne L8
0076 80910100 lds R24,_Key2
007A 8130 cpi R24,1
007C 41F4 brne L8
007E 80910000 lds R24,_Key3
0082 8130 cpi R24,1
0084 21F4 brne L8
0086 .dbline 42
0086 ; //如果按鍵的前后三次狀態分別是0、1、1的話,則認為有鍵按下
0086 ; KeyStatus=1; //置位狀態標志
0086 81E0 ldi R24,1
0088 80930300 sts _KeyStatus,R24
008C 03C0 rjmp L9
008E L8:
008E .dbline 44
008E ; else
008E ; KeyStatus=0; //否則清0狀態標志
008E 2224 clr R2
0090 20920300 sts _KeyStatus,R2
0094 L9:
0094 .dbline 45
0094 ; Key1=Key2;
0094 20900100 lds R2,_Key2
0098 20920200 sts _Key1,R2
009C .dbline 46
009C ; Key2=Key3;
009C 20900000 lds R2,_Key3
00A0 20920100 sts _Key2,R2
00A4 .dbline 47
00A4 ; }
00A4 L6:
00A4 .dbline 58
00A4 80910000 lds R24,_LightCount
00A8 90910100 lds R25,_LightCount+1
00AC 883E cpi R24,232
00AE E3E0 ldi R30,3
00B0 9E07 cpc R25,R30
00B2 51F4 brne L10
00B4 .dbline 59
00B4 .dbline 60
00B4 80E1 ldi R24,16
00B6 22B2 in R2,0x12
00B8 2826 eor R2,R24
00BA 22BA out 0x12,R2
00BC .dbline 61
00BC 2224 clr R2
00BE 3324 clr R3
00C0 30920100 sts _LightCount+1,R3
00C4 20920000 sts _LightCount,R2
00C8 .dbline 62
00C8 L10:
00C8 .dbline -2
00C8 L5:
00C8 2990 ld R2,y+
00CA 2FBE out 0x3f,R2
00CC E991 ld R30,y+
00CE 9991 ld R25,y+
00D0 8991 ld R24,y+
00D2 3990 ld R3,y+
00D4 2990 ld R2,y+
00D6 .dbline 0 ; func end
00D6 1895 reti
00D8 .dbend
.area bss(ram, con, rel)
0000 .dbfile E:\羅鵬\工作資料\工作記錄\CAN\程序\完成版本\Timer.c
0000 _Key3::
0000 .blkb 1
0001 .dbsym e Key3 _Key3 c
0001 _Key2::
0001 .blkb 1
0002 .dbsym e Key2 _Key2 c
0002 _Key1::
0002 .blkb 1
0003 .dbsym e Key1 _Key1 c
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -