代码://ICC-AVR application builder : 2014-7-6 21:54:26
// Target : M128
// Crystal: 7.3728Mhz
#include <iom128v.h>
#include <macros.h>
void port_init(void)
{
PORTA = 0x00;
DDRA = 0xFF;
}
//TIMER1 initialize - prescale:1024
// WGM: 0) Normal, TOP=0xFFFF
// desired value: 1Sec
// actual value: 1.000Sec (0.0%)
void timer1_init(void)
{
TCCR1B = 0x00; //stop
TCNT1H = 0xE3; //setup
TCNT1L = 0xE1;
TCCR1B = 0x05; //start Timer
}
#pragma interrupt_handler timer1_ovf_isr:15
void timer1_ovf_isr(void)
{
//TIMER1 has overflowed
TCNT1H = 0xE3; //reload counter high value
TCNT1L = 0xE1; //reload counter low value
PORTA^=0x01;
}
void main(void)
{
CLI(); //disable all interrupts
port_init();
timer1_init();
MCUCR = 0x00;
TIMSK = 0x04; //timer interrupt sources
SEI(); //re-enable interrupts
while(1)
{;}
}
从 DDRA = 0xFF;出来就卡住,好长时间后回到主函数第一条语句CLI(); //disable all interrupts,port_init();后面的都没有执行,求教
|