用的是MC9S12DP256B,想弄个最简单的小程序,来看看程序是否已经正常下载到片子里了。
让小灯闪烁
程序如下:
#include <hidef.h> /* common defines and macros */ #include <mc9s12dP256.h> /* derivative information */ //unsigned int cross,crossTime; #pragma LINK_INFO DERIVATIVE "mc9s12dp256b"
unsigned char flag=0,time_count=0;
void PORT_Init(void){ DDRK=0x08;  ORTK_BIT3=0; //灯亮 }
void ECT_Init(void) { TSCR2_PR = 7; //prescale factor is 8, bus clock/128=8Mhz/8 TSCR2_TOI = 1; //timer overflow interrupt enable TCNT = 0x0040; TSCR1_TEN = 1; //timer enable }
#pragma CODE_SEG NON_BANKED #pragma TRAP_PROC
void Int_TimerOverFlow(void){ TCNT = 0x0040; time_count++; if (time_count>50) {time_count=0;flag=~flag;} TFLG2_TOF = 1; //clear timer overflow flag } #pragma CODE_SEG DEFAULT
void main(void) { PORT_Init(); ECT_Init(); EnableInterrupts; while(1){ if(flag==0){ DDRK=0x08; PORTK_BIT3=0;//灯亮 } else{ DDRK=0x08; PORTK_BIT3=1;//灯灭 } } }
下载完之后,小灯一直亮,没有变化,咋回事呢?
PS:中断向量地址也已经在prm中声明了 VECTOR ADDRESS 0XFFDE Int_TimerOverFlow
各位帮忙指点指点吧
在Full Chip Simulation中正常,时钟有变化 但下载后,就没有变化了,是不是还是硬件的原因呢???
[此贴子已经被作者于2006-8-30 9:39:09编辑过] |