📄 watchdogrtc.lst
字号:
C51 COMPILER V7.05 WATCHDOGRTC 04/13/2004 13:35:28 PAGE 1
C51 COMPILER V7.05, COMPILATION OF MODULE WATCHDOGRTC
OBJECT MODULE PLACED IN watchdogrtc.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE watchdogrtc.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 //watchdogrtc.c - code recommendation for C header file
2 /***********************************************************************
3 MODULE: Watchdog and Real Time Clock Common Code
4 VERSION: 1.00
5 CONTAINS: Routines for controlling the Watchdog and Real Time Clock/
6 System Timer common interrupt on the Philips P89LPC932
7 COPYRIGHT: Embedded Systems Academy, Inc. - www.esacademy.com
8 LICENSE: May be freely used in commercial and non-commercial code
9 without royalties provided this copyright notice remains
10 in this file and unaltered
11 WARNING: IF THIS FILE IS REGENERATED BY CODE ARCHITECT ANY CHANGES
12 MADE WILL BE LOST. WHERE POSSIBLE USE ONLY CODE ARCHITECT
13 TO CHANGE THE CONTENTS OF THIS FILE
14 GENERATED: On "Feb 24 2004" at "16:21:01" by Code Architect 2.03
15 ***********************************************************************/
16
17 // SFR description needs to be included
18 #include<REG922.h>
19 extern bit T_flag ;
20 /***********************************************************************
21 DESC: Initializes and enables Watchdog and Real Time Clock interrupt
22 RETURNS: Nothing
23 CAUTION: Set EA to 1 to enable interrupts after calling
24 ************************************************************************/
25 void watchdogrtc_isrinit(void)
26 {
27 1 // set isr priority to 0
28 1 IP0 &= 0xBF;
29 1 IP0H &= 0xBF;
30 1
31 1 // enable interrupt
32 1 EWDRT = 1;
33 1 }
34
35 /***********************************************************************
36 DESC: Watchdog and Real Time Clock Interrupt Service Routine
37 RETURNS: Nothing
38 CAUTION: RTC or Watchdog initialization functions must be called and EA
39 must be set to 1 to enable interrupts
40 ************************************************************************/
41 void watchdogrtc_isr(void) interrupt 10 using 1
42 {
43 1 // check if interrupt caused by real time clock
44 1 if (RTCCON & 0x80)
45 1 {
46 2 // clear RTCF interrupt flag
47 2 RTCCON &= ~0x80;
48 2 T_flag=1;
49 2
50 2 }
51 1 // check if interrupt caused by watchdog
52 1 if (WDCON & 0x02)
53 1 {
54 2 // clear WDOTF interrupt flag
55 2 WDCON &= ~0x02;
C51 COMPILER V7.05 WATCHDOGRTC 04/13/2004 13:35:28 PAGE 2
56 2 }
57 1 }
58
59
60
61 /***********************************************************************
62 DESC: Initializes the watchdog as a Watchdog Timer
63 Uses Watchdog clock at 400kHz as a clock source
64 Resets the device if not fed within 998.888 ms
65 RETURNS: Nothing
66 ************************************************************************/
67 void watchdog_init
68 (
69 void
70 )
71 {
72 1 bit eacopy;
73 1
74 1 // init reload value and prescaler
75 1 // select Watchdog clock at 400kHz
76 1 // start watchdog
77 1 WDL = 0xC2;
78 1 eacopy = EA;
79 1 EA = 0;
80 1 WDCON = 0xC5;
81 1 WFEED1 = 0xA5;
82 1 WFEED2 = 0x5A;
83 1 EA = eacopy;
84 1
85 1 }
86
87 /***********************************************************************
88 DESC: Feeds the Watchdog to stop the device from resetting
89 RETURNS: Nothing
90 CAUTION: watchdog_init must be called first
91 ************************************************************************/
92 void watchdog_feed
93 (
94 void
95 )
96 {
97 1 bit eacopy;
98 1
99 1 // disable interrupts
100 1 eacopy = EA;
101 1 EA = 0;
102 1 // feed the watchdog
103 1 WFEED1 = 0xA5;
104 1 WFEED2 = 0x5A;
105 1 // restore interrupts
106 1 EA = eacopy;
107 1 }
108
109 /***********************************************************************
110 DESC: Starts the Watchdog
111 RETURNS: Nothing
112 CAUTION: watchdog_init must be called first
113 ************************************************************************/
114 void watchdog_start
115 (
116 void
117 )
C51 COMPILER V7.05 WATCHDOGRTC 04/13/2004 13:35:28 PAGE 3
118 {
119 1 bit eacopy;
120 1
121 1 // disable interrupts
122 1 eacopy = EA;
123 1 EA = 0;
124 1 // start the watchdog
125 1 WDCON |= 0x04;
126 1 // feed the watchdog
127 1 WFEED1 = 0xA5;
128 1 WFEED2 = 0x5A;
129 1 // restore interrupts
130 1 EA = eacopy;
131 1 }
132
133
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 92 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- 3
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -