You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.7 KiB
60 lines
1.7 KiB
#include "time.h"
|
|
#include "../msp/uartx.h"
|
|
|
|
#define D_TIMER_COUNT(t,clk,timeInUs) (U16)(65536 - 1.0 * (clk) / 1000 * (1.0 * timeInUs / 1000) / t)
|
|
//#define D_TIMER_COUNT(t,clk,timeInUs) (U16)(65536 - (clk) / 1000 * timeInUs / 1000 / t)
|
|
|
|
/*************初始化定时器0由 stc-isp v6.86L定时器计算器生成******************/
|
|
void L0_timer0_Init(void)
|
|
{
|
|
U16 val = D_TIMER_COUNT(12,D_sys_MainFre,D_sys_Jiffies * 1000);
|
|
AUXR &= 0x7F; //定时器时钟12T模式
|
|
TMOD &= 0xF0; //设置定时器模式
|
|
//TL0 = 0x00; //设置定时初值
|
|
//TH0 = 0x4C; //设置定时初值
|
|
TL0 = val; //设置定时初值
|
|
TH0 = val >> 8; //设置定时初值
|
|
TF0 = 0; //清除TF0标志
|
|
TR0 = 1; //定时器0开始计时
|
|
ET0 = 1; //add by cc
|
|
}
|
|
|
|
/******************************END*********************************/
|
|
|
|
|
|
//10---87 10s
|
|
/********************** Timer0中断函数************************/
|
|
/// 和 L0_timer0_Init 关联,需要配置 bsp_config.h中的 D_sys_MainFre
|
|
/// 默认10ms 作为TTSS系统的定时引擎
|
|
void timer0_isrHandle (void) D_SERVE_TIMER0
|
|
{
|
|
U8 i = 0;
|
|
NOP(); NOP(); NOP();
|
|
TF0 = 0;
|
|
#if 0
|
|
/// 65535*65535 /3600/24/365=139nian/s=1.39nian/10ms
|
|
///相当于1.39年后t_10ms 溢出,对于电池供电的系统而言 完全可以满足
|
|
// 4,294,836,225 = 65535*65535 ;3600*24*60*60 = 31,536,000秒/年
|
|
s_nos_tick.t_10ms ++;//D_led_D1_REV(); 20160522 验证
|
|
#else
|
|
//系统时钟
|
|
L1_tick_tick(); ///系统中的1sflag 和以10ms为颗粒的延时使用 为tdelay服务
|
|
|
|
//串口回调
|
|
for(i=0; i< SERIAL_MAX_NUM; i++)
|
|
{
|
|
if(ts_uart[i].tp_handler != NULL)
|
|
{
|
|
ts_uart[i].tp_handler(ts_uart[i].uartx);
|
|
}
|
|
}
|
|
|
|
#endif
|
|
/// BITN_1(DR_who_wakeup, DRB_who_wakeup_timer0);
|
|
NOP(); NOP(); NOP();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|