timer.lst
来自「世纪民生公司的带网络功能的单片机CS6209开发http服务器的演示源代码。」· LST 代码 · 共 250 行 · 第 1/2 页
LST
250 行
114 /* Arguments : *
115 /* None. *
116 /* *
C51 COMPILER V7.50 TIMER 10/12/2006 15:31:40 PAGE 3
117 /* Return : None. *
118 /* *
119 /* *
120 /* Comment : *
121 /* This is the scheduler ISR. It is called at a rate *
122 /* determined by the timer settings in the 'init' function. *
123 /* *
124 /* This version is triggered by Timer 2 interrupts: *
125 /* timer is automatically reloaded. *
126 /* *
127 /************************************************************************/
128 void Timer2_Update(void) interrupt INTERRUPT_Timer_2_Overflow
129 {
130 1
131 1 T2CON&=0x7F;
132 1
133 1 tickcount ++;
134 1
135 1 }
136
137
138 /************************************************************************
139 /* Function Name : timer_reset *
140 /* *
141 /* Arguments : *
142 /* None. *
143 /* *
144 /* Return : None. *
145 /* *
146 /* *
147 /* Comment : *
148 /* This function reset the 'tickcount' to 0. *
149 /* *
150 /************************************************************************/
151 void timer_reset (void)
152 {
153 1
154 1 /* protect with critical section*/
155 1 Disable_interrupt() ;
156 1
157 1 tickcount = 0L;
158 1
159 1 Enable_interrupt() ;
160 1 }
161 /************************************************************************
162 /* Function Name : mstime *
163 /* *
164 /* Arguments : *
165 /* None. *
166 /* *
167 /* Return : *
168 /* The current 'tickcount' . *
169 /* *
170 /* *
171 /* Comment : *
172 /* This function return the value of tickcount. *
173 /* *
174 /************************************************************************/
175 unsigned long mstime ()
176 {
177 1 unsigned long tim;
178 1
C51 COMPILER V7.50 TIMER 10/12/2006 15:31:40 PAGE 4
179 1 // protect with critical section
180 1 Disable_interrupt() ;
181 1
182 1 tim = tickcount;
183 1
184 1 Enable_interrupt() ;
185 1
186 1 return (tim);
187 1
188 1 }
189
190 /************************************************************************
191 /* Function Name : timeout *
192 /* *
193 /* Arguments : *
194 /* unsigned long *varp :Point to a value of start time. *
195 /* It will be update if timeout. *
196 unsigned int tout : Timeout value *
197 /* Return : *
198 /* Return 1 if timeout. *
199 /* *
200 /* Comment : *
201 /* Check for timeout using the given tick counter and timeout *
202 /* value. Force timeout if timeout value is zero.This function *
203 /* will be called by TCP/IP stack. *
204 /* *
205 /* *
206 /************************************************************************/
207 unsigned char timeout (unsigned long *varp, unsigned int tout)
208 {
209 1 unsigned long diff;
210 1
211 1 diff = tickcount - *varp;
212 1 if (!tout || diff >= tout)
213 1 {
214 2 *varp = tickcount;
215 2 return 1;
216 2 }
217 1 return 0;
218 1 }
219
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 226 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 5 9
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 + =
减小字号Ctrl + -
显示快捷键?