?? 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 最小節(jié)拍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 最小節(jié)拍1us
TCNT1 = (65535 - 50000); //50ms中斷一次
TIMSK |=(1<<TOIE1); //enable the t0 overflow intterrupt
#endif
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -