📄 timer.h
字号:
#ifndef TIMER_H
#define TIMER_H
//#include "reg51rb2.h"
#include "reg420.h"
// for 11.0592Hz, X2mode, one instruction takes 1/(11.0592/6) uS
// so for 1ms timer, value-load = 1000*(11.0592/6) = 1843 (0x0733)
// if not in X2mode, value-load = 1000*(11.0592/12) = 921 (0x0399)
// THL = 0x10000-0x0733 = 0xf8cd (in X2mode)
// THL = 0x10000-0x0399 = 0xfc67 (in standard mode)
// for 32MHz(X4 mode), one instruction takes 1/8 uS (original clock is 8MHz)
// so for 1ms timer, value-load = 1000*(8/12) = 666 (0x029a)
// THL = 0x10000-0x029a = 0xfd66
// for 22.1184MHz(X1 mode), one instruction takes 1/22.1184 uS
// so for 1ms timer, value-load = 1000*(22.1184/12) = 1843 ( 0x733)
// THL = 0x10000 - 0x0733 = 0xF8cd
// for 26MHz(X1 mode), one instruction takes 1/26 uS
// so for 1ms timer, value-load = 1000*(26/12) = 2167 ( 0x877)
// THL = 0x10000 - 0x0877 = 0xF789
#define RELOADVALH 0Xf9 // less than 1 ms for 22.2281MHz
#define RELOADVALL 0X8d
//#define RELOADVALH 0Xf8 // less than 1 ms for 26MHz
//#define RELOADVALL 0Xb7
#define HOST_SEND_DATA_FLAG (event & 0x01)
#define CLR_HOST_SEND_DATA_FLAG (event &= 0xfe)
unsigned char data frm_count,frm_count1, tic_flag;
unsigned int data buf_idx,usb_snd_idx;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -