|
假如是M16,外部晶振为4MHz,
然后现在要2ms延时。CTC模式,1/64分频
下面是用iccavr application builder 生成的代码:
void timer0_init(void)
{
TCCR0 = 0x00; //stop
TCNT0 = 0x83; //set count
OCR0 = 0x7D; //set compare
TCCR0 = 0x0B; //start timer
}
但是书上的却是:
TCCR0 = 0X0B;
TCNT0 = 0X00;
OCR0 = 0X7C;
TIMSK = 0X02;
application builder为什么会给TCNT0赋值?而且貌似还比OCR0的值大。
求解?
|
|