我刚写了一个简单的测试程序,有点疑问就是为什么运行后 在for循环里设断点,程序停不住啊,定时中断里可以。第一次用这个模板,请各位多多指教哦~~ 下面是程序:: #include <hidef.h> /* common defines and macros */ #include <mc9s12dp256.h> /* derivative information */ #pragma LINK_INFO DERIVATIVE "mc9s12dp256b" void Timer0_init(){ TIOS_IOS0 = 1; TSCR1_TEN = 1; TSCR2 = 0x07; TCTL2_OL0 = 0; TCTL2_OM0 = 0; TC0 = 6250;//150ms TIE_C0I = 1; }
void main(void) { /* put your own code here */ uchar i; DDRA = 0xff; PORTA = 0xff; Timer0_init(); EnableInterrupts; for(;;) { i++; if(i==255){ i= 0; } } /* wait forever */ /* please make sure that you never leave this function */ } uchar t = 0; #pragma CODE_SEG NON_BANKED #pragma TRAP_PROC void timer0_interrupt(){ uchar flag; static uint cnt; flag = TFLG1; TC0 = TC0 + 6250; cnt++; if(cnt==10){ t = ~t; PORTA =~ PORTA; }
} #pragma CODE_SEG DEFAULT |