M8定时器1溢出中断号是9?但是当我无意中把中断号写成了15,似乎也能进中断,接PC0和PC1的LED会交替闪烁,怎么可能呢?求解释,程序如下,用的是ICCAVR。
#include <iom8v.h>
#include <macros.h>
unsigned char i=0;
void timer1_init(void)
{
TCNT1H = 0XCF;//TC1赋处初值
TCNT1L = 0X2C;
TCCR1B = (1<<CS11)|(1<<CS10);//64分频 0X03;
TIMSK = (1<<TOIE1); //使能TC1溢出中断
}
#pragma interrupt_handler TC1_serve:9
void TC1_serve(void)
{
CLI();
i++;
TCNT1H = 0XCF;
TCNT1L = 0X2C;
if(i<10) PORTC=(0<<PORTC0)|(1<<PORTC1); //PC0和PC1交替闪烁
else PORTC = (1<<PORTC0)|(0<<PORTC1);
if(i==20)i=0;
SEI();
}
void portc_init(void)
{
DDRC = 0xFF;//端口PC全部配置为输出
PORTC = 0xFF;//初始输出为1
}
main()
{
CLI();
timer1_init();
portc_init();
SEI();
}
|