📄 timertick.lst
字号:
C51 COMPILER V7.00 TIMERTICK 01/05/2004 23:20:12 PAGE 1
C51 COMPILER V7.00, COMPILATION OF MODULE TIMERTICK
OBJECT MODULE PLACED IN TIMERTICK.OBJ
COMPILER INVOKED BY: F:\Keil\C51\BIN\C51.EXE TIMERTICK.C LARGE BROWSE INTVECTOR(0X8000) DEBUG OBJECTEXTEND TABS(2)
stmt level source
1 /*
2 Copyright (C) 2003 Bart Bilos <boombox666@yahoo.com>.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 */
19
20 /*
21 Timer library, basically functions to see how much time has elapsed
22 since boot of the program, handy to use to calculate timeouts and
23 benchmarks.
24 */
25
26 #include <Dallas\REG320.H>
27 #include "timertick.h"
28
29 // how many units since boot
30 unsigned int timeunits=UNIT_SEC;
31 unsigned long int seconds=0;
32
33 // ISR for timer ticker
34 void int1(void) interrupt 1 using 3 {
35 1 timeunits--;
36 1 if(timeunits==0){
37 2 timeunits=UNIT_SEC;
38 2 seconds++;
39 2 }
40 1 }
41
42 void inittimer(void) {
43 1 // timer mode 1 reload mode
44 1 TMOD = (TMOD & 0xF0) | (0x02);
45 1 // cycle count
46 1 TL0 = 0xFF - CYCLE_COUNT;
47 1 // cycle count
48 1 TH0 = 0xFF - CYCLE_COUNT;
49 1 // timer 0 on
50 1 TR0 = 1;
51 1 // allow interrupts from timer 0
52 1 IE = IE | 0x82;
53 1 }
54
55 // return amount of seconds elapsed since init of timer
C51 COMPILER V7.00 TIMERTICK 01/05/2004 23:20:12 PAGE 2
56 long int getseconds(void) {
57 1 return seconds;
58 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 118 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 6 ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -