/**
* 文件名:timer.h
*/
#ifndef _TIMER_H
#define _TIMER_H
#define SYS_MCLK 11059200 //系统主时钟
#define FOSC 11059200 //晶振频率
#define USING_T0
#define USING_STC15_T2
#ifdef USING_T0
extern uint8_t tmr0LowByte, tmr0HighByte;
void tmr0_init(uint8_t ms);
#endif
#ifdef USING_T1
extern uint8_t tmr1LowByte, tmr1HighByte;
void tmr1_init(uint8_t ms);
#endif
#ifdef USING_T2
void tmr2_init(uint8_t ms);
#endif
#ifdef USING_STC15_T2
void stc15_tmr2_init(uint8_t ms);
#endif
#endif
/**
* 文件名:timer.c
*/
#include <stc15f2k60s2.h>
#include "stdint.h"
#include "timer.h"
/**
* 定时器0
*/
#ifdef USING_T0
uint8_t tmr0LowByte, tmr0HighByte;
void tmr0_init(uint8_t ms) { //!!8bits
uint32_t tmp; //小心溢出
tmp = ms * SYS_MCLK / 12 / 1000;
tmp = 65536 - tmp;
tmr0Lo