📄 timer.c
字号:
#pragma REGISTERBANK(0)
#include "Header.H"
//extern bit PIN_SIGIND;
volatile unsigned char jiffies = 0;
bit timerbh_pending = 0;
#if 1
static volatile unsigned char xjiffies = 0;
struct time_val xtime = { 0, 0, 0 };
#endif
#define INIT_T0 (65536L - (F_OSC/12)/HZ)
#define MAX_T0 10
static unsigned char t0_count = MAX_T0;
void timer_bh(void)
{
extern void check_key(void);
while (xjiffies != jiffies) {
xjiffies++;
xtime.msec10 += 100/HZ;
t0_count--;
}
while (xtime.msec10 >= 100) {
xtime.sec++;
xtime.msec10 -= 100;
}
while (xtime.sec >= 60) {
xtime.min++;
xtime.sec -= 60;
}
check_key();
}
void timer_init(void)
{
TH0 = (unsigned char)(INIT_T0>>8);
TL0 = (unsigned char)INIT_T0;
TR0 = 1;
ET0 = 1;
HZ_IND = 1;// Default PAL System
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -