📄 t0.lis
字号:
.module t0.c
.area vector(rom, abs)
.org 14
000E 49C0 rjmp _t0_isr
.area data(ram, con, rel)
0000 _timer_ct::
0000 .blkb 2
.area idata
0000 0000 .word 0
.area data(ram, con, rel)
0002 .dbfile E:\work\avr\icc\cpld\stklcd\t0.c
0002 .dbsym e timer_ct _timer_ct s
0002 _timer_set::
0002 .blkb 2
.area idata
0002 0000 .word 0
.area data(ram, con, rel)
0004 .dbfile E:\work\avr\icc\cpld\stklcd\t0.c
0004 .dbsym e timer_set _timer_set s
.area text(rom, con, rel)
0000 .dbfile E:\work\avr\icc\cpld\stklcd\t0.c
0000 .dbfunc e T0_init _T0_init fV
.even
0000 _T0_init::
0000 .dbline -1
0000 .dbline 62
0000 ; //
0000 ; // File Name: t0.c
0000 ; //
0000 ; // Title: Internal timer 0 implementation
0000 ; //
0000 ; // Description:
0000 ; //
0000 ; // Creation Date: 2/6/00 5:31:06 PM
0000 ; //
0000 ; // By: A.C. Verbeck
0000 ; //
0000 ; // This file is subject to the terms and conditions of the GNU General Public
0000 ; // License. See the file COPYING in the main directory of this archive
0000 ; // for more details.
0000 ; //
0000 ;
0000 ; #include <io8515v.h>
0000 ; #include <stdio.h>
0000 ; #include <macros.h>
0000 ;
0000 ; #include "Basetype.h"
0000 ; #include "t0.h"
0000 ;
0000 ; #pragma interrupt_handler t0_isr:8;
0000 ;
0000 ; //
0000 ; // Local defines
0000 ; //
0000 ; #define MAX_CT 0xFF // Max count that can be assigned
0000 ; #define _1MS 0x3f // 1.008mS delay time
0000 ; #define _2MS 0x7D // 2mS delay time (exact)
0000 ; #define _4MS 0xFA // 4mS delay time (exact)
0000 ;
0000 ; //
0000 ; // Local data
0000 ; //
0000 ; UInt16 timer_ct = 0; // Current timer count
0000 ; UInt16 timer_set = 0; // Timer time out value
0000 ;
0000 ; //
0000 ; // Local functions
0000 ; //
0000 ; static void t0_isr(void);
0000 ;
0000 ; //
0000 ; // Function Name:
0000 ; // T0_init
0000 ; //
0000 ; // Description:
0000 ; // Initialize internal timer 0.
0000 ; // - set divider to ck/64
0000 ; // - set count to 63
0000 ; // - this gives a 1.008mS interrupt interval (992Hz)
0000 ; //
0000 ; // Parameters:
0000 ; // (none)
0000 ; //
0000 ; // Returns:
0000 ; // (nothing)
0000 ; //
0000 ; void T0_init(void)
0000 ; {
0000 .dbline 63
0000 ; CLI(); // Interrupts OFF
0000 F894 cli
0002 .dbline 64
0002 ; TCCR0 = 0x03; // Set divider to ck/64
0002 83E0 ldi R24,3
0004 83BF out 0x33,R24
0006 .dbline 65
0006 ; TCNT0 = (MAX_CT-_1MS); // Set the time out
0006 80EC ldi R24,192
0008 82BF out 0x32,R24
000A .dbline 66
000A ; TIMSK |= 0x02; // Enable the interrupt
000A 89B7 in R24,0x39
000C 8260 ori R24,2
000E 89BF out 0x39,R24
0010 .dbline 68
0010 ;
0010 ; timer_ct = 0; // Init the soft timer
0010 2224 clr R2
0012 3324 clr R3
0014 30920100 sts _timer_ct+1,R3
0018 20920000 sts _timer_ct,R2
001C .dbline 69
001C ; SEI(); // Interrupts ON
001C 7894 sei
001E .dbline -2
001E .dbline 70
001E ; }
001E L1:
001E .dbline 0 ; func end
001E 0895 ret
0020 .dbend
0020 .dbfunc e T0_clear _T0_clear fV
.even
0020 _T0_clear::
0020 .dbline -1
0020 .dbline 73
0020 ;
0020 ; void T0_clear(void)
0020 ; {
0020 .dbline 74
0020 ; timer_ct = 0;
0020 2224 clr R2
0022 3324 clr R3
0024 30920100 sts _timer_ct+1,R3
0028 20920000 sts _timer_ct,R2
002C .dbline -2
002C .dbline 75
002C ; }
002C L2:
002C .dbline 0 ; func end
002C 0895 ret
002E .dbend
002E .dbfunc e T0_set _T0_set fV
002E ; time_out -> R16,R17
.even
002E _T0_set::
002E .dbline -1
002E .dbline 94
002E ;
002E ;
002E ; //
002E ; // Function Name:
002E ; // T0_set
002E ; //
002E ; // Description:
002E ; // Set the next timeout for the internal timer 0.
002E ; // Note that this code works even if the timer
002E ; // "rolls over".
002E ; //
002E ; // Parameters:
002E ; // UInt16 time_out - the wakeup time
002E ; //
002E ; // Returns:
002E ; // (nothing)
002E ; //
002E ; void T0_set(UInt16 time_out)
002E ; {
002E .dbline 95
002E ; CLI(); // Interrupts OFF
002E F894 cli
0030 .dbline 96
0030 ; timer_ct = 0; // Clear the timer count to 0
0030 2224 clr R2
0032 3324 clr R3
0034 30920100 sts _timer_ct+1,R3
0038 20920000 sts _timer_ct,R2
003C .dbline 97
003C ; timer_set = time_out; // Set the new timeout
003C 10930300 sts _timer_set+1,R17
0040 00930200 sts _timer_set,R16
0044 .dbline 98
0044 ; SEI(); // Interrupts ON
0044 7894 sei
0046 .dbline -2
0046 .dbline 99
0046 ; }
0046 L3:
0046 .dbline 0 ; func end
0046 0895 ret
0048 .dbsym r time_out 16 s
0048 .dbend
0048 .dbfunc e T0_get _T0_get fs
.even
0048 _T0_get::
0048 .dbline -1
0048 .dbline 101
0048 ; UInt16 T0_get(void)
0048 ; {
0048 .dbline 102
0048 ; return timer_ct;
0048 00910000 lds R16,_timer_ct
004C 10910100 lds R17,_timer_ct+1
0050 .dbline -2
0050 L4:
0050 .dbline 0 ; func end
0050 0895 ret
0052 .dbend
0052 .dbfunc e T0_enable _T0_enable fV
.even
0052 _T0_enable::
0052 .dbline -1
0052 .dbline 107
0052 ; }
0052 ;
0052 ;
0052 ; void T0_enable(void)
0052 ; {
0052 .dbline 108
0052 ; TIMSK |= 0x02; // Enable the interrupt
0052 89B7 in R24,0x39
0054 8260 ori R24,2
0056 89BF out 0x39,R24
0058 .dbline -2
0058 .dbline 109
0058 ; }
0058 L5:
0058 .dbline 0 ; func end
0058 0895 ret
005A .dbend
005A .dbfunc e T0_disable _T0_disable fV
.even
005A _T0_disable::
005A .dbline -1
005A .dbline 111
005A ; void T0_disable(void)
005A ; {
005A .dbline 112
005A ; TIMSK &= ~0x02; // Disable the interrupt
005A 89B7 in R24,0x39
005C 8D7F andi R24,253
005E 89BF out 0x39,R24
0060 .dbline -2
0060 .dbline 113
0060 ; }
0060 L6:
0060 .dbline 0 ; func end
0060 0895 ret
0062 .dbend
0062 .dbfunc e T0_sleep _T0_sleep fV
0062 ; time_out -> R16,R17
.even
0062 _T0_sleep::
0062 .dbline -1
0062 .dbline 116
0062 ;
0062 ; void T0_sleep(UInt16 time_out)
0062 ; {
0062 .dbline 117
0062 ; CLI(); // Interrupts OFF
0062 F894 cli
0064 .dbline 118
0064 ; timer_ct = 0; // Clear the timer count to 0
0064 2224 clr R2
0066 3324 clr R3
0068 30920100 sts _timer_ct+1,R3
006C 20920000 sts _timer_ct,R2
0070 .dbline 119
0070 ; timer_set = time_out; // Set the new timeout
0070 10930300 sts _timer_set+1,R17
0074 00930200 sts _timer_set,R16
0078 .dbline 120
0078 ; SEI(); // Interrupts ON
0078 7894 sei
007A L8:
007A .dbline 121
007A L9:
007A .dbline 121
007A ; while (timer_ct != timer_set); // Just wait here
007A 20900200 lds R2,_timer_set
007E 30900300 lds R3,_timer_set+1
0082 40900000 lds R4,_timer_ct
0086 50900100 lds R5,_timer_ct+1
008A 4214 cp R4,R2
008C 5304 cpc R5,R3
008E A9F7 brne L8
0090 .dbline -2
0090 .dbline 122
0090 ; }
0090 L7:
0090 .dbline 0 ; func end
0090 0895 ret
0092 .dbsym r time_out 16 s
0092 .dbend
0092 .dbfunc s t0_isr _t0_isr fV
.even
0092 _t0_isr:
0092 8A93 st -y,R24
0094 9A93 st -y,R25
0096 8FB7 in R24,0x3f
0098 8A93 st -y,R24
009A .dbline -1
009A .dbline 125
009A ;
009A ; static void t0_isr(void)
009A ; {
009A .dbline 126
009A ; ++timer_ct; // Boost the software timer
009A 80910000 lds R24,_timer_ct
009E 90910100 lds R25,_timer_ct+1
00A2 0196 adiw R24,1
00A4 90930100 sts _timer_ct+1,R25
00A8 80930000 sts _timer_ct,R24
00AC .dbline 127
00AC ; TCNT0 = (MAX_CT-_1MS); // Set the time out
00AC 80EC ldi R24,192
00AE 82BF out 0x32,R24
00B0 .dbline -2
00B0 .dbline 128
00B0 ; }
00B0 L11:
00B0 8991 ld R24,y+
00B2 8FBF out 0x3f,R24
00B4 9991 ld R25,y+
00B6 8991 ld R24,y+
00B8 .dbline 0 ; func end
00B8 1895 reti
00BA .dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -