//========timer5.h============================================= #ifndef _TIMER5_H_ #define _TIMER5_H_ //#include "timer5.h" //==timer5 define===== #define TIM5_DIV1 (0<<4) #define TIM5_DIV8 (1<<4) #define TIM5_DIV64 (2<<4) #define TIM5_DIV256 (3<<4) //#define TIMER5_ENB Bank1;T5CON |= (1<<1);Bank0 //开T5计数 //#define TIMER5_DIS Bank1;T5CON &= ~(1<<1);Bank0 #define ClrTF5 T5CON &= ~(1<<7) #define TIMER5_IE_ENB IEN0 |= (1<<1) //开T5中断 #define TIMER5_IE_DIS IEN0 &= ~(1<<1) //关T5中断 //============================== extern void Init_Timer5(uint8 Pscr,uint16 Tcon) ; extern void Timer5_Enb(uint8 EN) ; #endif //========timer5.c============================================== #include "global.h" #include "timer5.h" //#define Init_Timer5_CALL //************************************* // 函数名称:Init_Timer5 // 函数功能:TIM5初始化 // 入口参数:计数个数 分频值 // 出口参数:无 //*************************************** #ifdef Init_Timer5_CALL void Init_Timer5(uint8 Pscr,uint16 Tcon) { Bank1; T5CON = 0X00 ; T5CON |= Pscr ; TL5 = (65536-Tcon)&0X00FF ; TH5 = (65536-Tcon)>>8 ; SWTHL &= ~(1<<1) ; //读TH5 TL5时返回 它的计数值 T5CON |= (1<<1) ; //开T5计数 Bank0; } #endif //Init_Timer5_CALL
中颖SH79F1616 timer5初始化程序,布布扣,bubuko.com
时间: 2024-10-31 19:33:38