📄 cpu.c
字号:
/*****************************************************************
** Project: 充电器
** file : cpu.c
** date : 20081205
** author:
** version: v1.0
** description: 底层硬件初始化
** ---------------------------------------------------------------
** date :
** author:
** version:
** description:
******************************************************************/
#include "main.h"
void TimerInit(void)
{
#if defined (__AVR_ATmega48__) || defined(__AVR_ATmega88__)
/*t0 initailize*/
TCCR0B = 0x00; //stop
//TCCR0 |= (1<<CS02)|(1<<CS00); //1024 div
TCCR0B = (1<<CS02); //256 div
TCNT0 = T0_BGN_VAL; //load the bgein val
TIMSK0 |=(1<<TOIE0); //enable the t0 overflow intterrupt
/*t1 intialize*/
TCCR1B = 0x00; //stop
TCCR1B |= (1<<CS11); //8分频 1MHZ 最小节拍1us
TCNT1 = (65535 - 50000); //50ms中断一次
TIMSK1 |=(1<<TOIE1); //enable the t0 overflow intterrupt
#elif defined (__AVR_ATmega8__)
/*t0 initailize*/
TCCR0 = 0x00; //stop
//TCCR0 |= (1<<CS02)|(1<<CS00); //1024 div
TCCR0 = (1<<CS02); //256 div
TCNT0 = T0_BGN_VAL; //load the bgein val
TIMSK |=(1<<TOIE0); //enable the t0 overflow intterrupt
/*t1 intialize*/
TCCR1B = 0x00; //stop
TCCR1B |= (1<<CS11); //8分频 1MHZ 最小节拍1us
TCNT1 = (65535 - 50000); //50ms中断一次
TIMSK |=(1<<TOIE1); //enable the t0 overflow intterrupt
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -