1、宏定义最好是浮点数计算,否则有误差
2、宏定义给出来计算公式别错了,发现错的不少。
#define FOSC 11059200.0f
#define Timer 50000.0f // exampl 1000.0f us为unit
#define TMS 65536-(WORD)((Timer*FOSC)/(1000000.0f*12.0f)) //1ms timer calculation method in 12T mode
赋初值
TL0 = TMS; //initial timer0 low byte
TH0 = TMS >> 8; //initial timer0 high byte