📄 timer.lst
字号:
C51 COMPILER V6.20c TIMER 04/15/2004 12:59:25 PAGE 1
C51 COMPILER V6.20c, COMPILATION OF MODULE TIMER
OBJECT MODULE PLACED IN .\Output\Timer.obj
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE Code\Timer.c OPTIMIZE(9,SPEED) BROWSE DEBUG OBJECTEXTEND PRINT(.\Output\Tim
-er.lst) OBJECT(.\Output\Timer.obj)
stmt level source
1 #define __TIMER__
2
3 #include "reg52.h"
4 #include "Header\Lcd_main.h"
5 #include "Header\Lcd_auto.h"
6
7 /////////////////////////////////////////////////////////////
8 // Interrupt Service Routine for Timer0 (Fired every 20ms) //
9 /////////////////////////////////////////////////////////////
10 void IntProc_Timer0(void) interrupt 1
11 {
12 1 #if (MCU_TYPE != MCU_STD8051)
static unsigned char ucTimerCounter = 0;
#endif
15 1
16 1 #if (IRPOLLING)
static unsigned char ucIR_Seq = 0xff;
static unsigned char ucTimerCnt = 0x00;
TL0 = TIME0_COUNTER_LBYTE; // Reload Timer0 low-byte
TH0 = TIME0_COUNTER_HBYTE; // Reload Timer0 high-byte
if (ucIR_State)
{
if (bIR_GPIO)
{
ucIR_Seq = (ucIR_Seq << 1) | 0x01;
if ((0xff == ucIR_Seq) && (ucIR_State & 0xfe))
{
ucIR_State = 0; // Command timeout; Back to idle state
((unsigned int *)ucIR_Cmd)[0] = 0;
}
}
else
{
if (1 < ucIR_State)
{
if (ucIR_Seq & 0x01)
{
((unsigned int *)ucIR_Cmd)[0] = (((unsigned int *)ucIR_Cmd)[0] << 1)
| (0x07 != (ucIR_Seq & 0x07) ? 1 : 0);
if (23 == ++ucIR_State && CUSTOM_CODE != ((unsigned int *)ucIR_Cmd)[0])
{
ucIR_State = 0; // Customer code error; Back to idle state
((unsigned int *)ucIR_Cmd)[0] = 0;
}
else if (39 == ucIR_State)
{
ucIR_State = 0; // Command complete; Back to idle state
C51 COMPILER V6.20c TIMER 04/15/2004 12:59:25 PAGE 2
ucIR_Cmd[1] = 8; // Set command timer to 8 (7*20 = 140ms)
}
}
else if (0x00 == (ucIR_Seq & 0xfe))
{
ucIR_State = 0; // Command crashed; Back to idle state
((unsigned int *)ucIR_Cmd)[0] = 0;
}
}
else // ucIR_State is 1
{
if (0xff == ucIR_Seq)
{
ucIR_State = 0x07; // Start to decode new command and clear old command
((unsigned int *)ucIR_Cmd)[0] = 0;
}
else
{
ucIR_State = 0; // Fire repeat command and reset to idle
ucIR_Cmd[1] = ucIR_Cmd[0] ? 8 : 0;
}
}
ucIR_Seq = ucIR_Seq << 1;
}
}
else
{
ucIR_Seq = (ucIR_Seq << 1) | bIR_GPIO;
if (0x07 == ucIR_Seq) ucIR_State = 1; // Leader code detected
}
if (54 <= ++ucTimerCnt) // 0.375ms * 54 = 20.25ms passed
{
ucTimerCnt = 0;
bNotify_Timer0_Int = 1; // Post Timer0's timeout message
if (usOSD_Timer) usOSD_Timer -= 1; // For OSD Timeout
// Clear command after 144ms if not repeat code
if (0 == ucIR_State)
{
if (ucIR_Cmd[1] && 0 == --ucIR_Cmd[1]) ucIR_Cmd[0] = 0;
}
}
#if (MCU_TYPE != MCU_STD8051)
if (3 <= ++ucTimerCounter)
{
ucTimerCounter = 0;
bNotify_Timer0_Int = 1; // Post Timer0's timeout message
}
#endif
C51 COMPILER V6.20c TIMER 04/15/2004 12:59:25 PAGE 3
#else // if not IRPOLLING
118 1
119 1 #if (MCU_TYPE == MCU_STD8051)
120 1
121 1 TL0 = TIME0_COUNTER_LBYTE; // Reload Timer0 low-byte
122 1 TH0 = TIME0_COUNTER_HBYTE; // Reload Timer0 high-byte
123 1
124 1 bNotify_Timer0_Int = 1; // Post Timer0's timeout message
125 1
126 1 if (usOSD_Timer) usOSD_Timer -= 1; // For OSD Timeout
127 1
128 1 #else
TL0 = TIME1_COUNTER_LBYTE; // Reload Timer1 low-byte
TH0 = TIME1_COUNTER_HBYTE; // Reload Timer1 hifh-byte
TR0 = 1; // Stop Timer1
bNotify_Timer1_Int = 1; // Post Timer1's timeout message
if (20 <= ++ucTimerCounter)
{
ucTimerCounter = 0;
bNotify_Timer0_Int = 1; // Post Timer0's timeout message
if (usOSD_Timer) usOSD_Timer -= 1; // For OSD Timeout
}
#endif
144 1
145 1 #endif
146 1 }
147
148 ///////////////////////////////////////////////////////////////////////
149 // Interrupt Service Routine for Timer1 (Fired in 1ms after restart) //
150 ///////////////////////////////////////////////////////////////////////
151 #if (MCU_TYPE == MCU_STD8051) // Use the standard 8052 MCU
152
153 void IntProc_Timer1(void) interrupt 3
154 {
155 1 TR1 = 0; // Stop Timer1
156 1 TL1 = TIME1_COUNTER_LBYTE; // Reload Timer1 low-byte
157 1
158 1 TH1 = (bAutoInProgress == 1) ? TIME1_COUNTER_HHBYTE : TIME1_COUNTER_HBYTE; // Reload Timer1 hifh-byte
159 1
160 1 bNotify_Timer1_Int = 1; // Post Timer1's timeout message
161 1 }
162
163 /////////////////////////////////////////////////////////////////////////////////
164 // Function Routines
165 /////////////////////////////////////////////////////////////////////////////////
166 void Delay_Xms(unsigned char x) // For delay 0 ~ 255 ms
167 {
168 1 if (x)
169 1 {
170 2 bNotify_Timer1_Int = 0; // Clear timer1's timeout message
171 2
172 2 TR1 = 1; // Start timer1
173 2
174 2 while (1)
175 2 {
176 3 if (bNotify_Timer1_Int)
177 3 {
178 4 bNotify_Timer1_Int = 0; // Clear timer1's timeout message
C51 COMPILER V6.20c TIMER 04/15/2004 12:59:25 PAGE 4
179 4
180 4 if (--x) TR1 = 1; // Restart timer1 if not timeout
181 4 else return; // Timeout for X ms.
182 4 }
183 3 }
184 2 }
185 1 }
186
187 #else // Use just one timer
/////////////////////////////////////////////////////////////////////////////////
// Function Routines
/////////////////////////////////////////////////////////////////////////////////
void Delay_Xms(unsigned char x) // For delay 0 ~ 255 ms
{
if (x)
{
bNotify_Timer1_Int = 0; // Clear timer1's timeout message
while (1)
{
if (bNotify_Timer1_Int)
{
bNotify_Timer1_Int = 0; // Clear timer1's timeout message
if (0 == --x) return; // Timeout for X ms.
}
}
}
}
#endif
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 89 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = 2 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -