大家好:
本人第一次使用HC908JK8MCU
经过多方面的学习,现在程序终于可以运行起来。
显示,AD采集,数据处理都没有问题了!
但是,一个最重要的问题一只困扰着我。
我使用了定时器淤出中断,可程序就是进不了中断处理程序!
采用USB-MON08 Rev D 进行在线调试!
我的程序如下: void InitTimer(void) //初始化定时器1---晶振频率=8MHZ,总线频率=2MHZ,分频因子=64,预置值=1250,=40毫秒一次中断 { T1SC=0b01100110; //01100110允许溢出中断、 //不启动计数、分频因子=64 T1CNTH=0; //计数器初值清0 T1CNTL=0; T1MODH=0x02; //设20毫秒产生1次溢出中断 T1MODL=0x71; //模数寄存器设定值 //中断频率:2000000/64*625 = 50Hz T1SC_TOF=0; } #pragma CODE_SEG NON_BANKED #pragma TRAP_PROC //*定时器20Ms中断一次*/ interrupt void Timer_ISR(void) { T1SC_TOF=0; SecData++; //秒,分,时,开始计时 TimBuf[0]++; if(TimBuf[0]>=60) { TimBuf[0]=0; if(TimBuf[1]>=60) { TimBuf[1]=0; if(TimBuf[2]>=24) { TimBuf[2]=0; } } } } #pragma CODE_SEG DEFAULT void main(void) { DisableInterrupts; /* 关中断 */ InitMcu(); InitDataCmd(); EnableInterrupts; /* 开中断 */ for(;;) { //KeyParse();//-------------键盘采集 LcdBuf[0]=0x01; LcdBuf[1]=0x00; LcdBuf[2]=0x00;//状态显示 LcdBuf[3]=0x00; LcdBuf[4]=0xAa;//状态显示 LcdBuf[5]=0x08;//状态显示 AdParse();//-------------- FridgeStCon();//---------- LcdShowCmd();//----------- //__RESET_WATCHDOG();//-----feeds the dog } }
另:
/* This is a linker parameter file for the JK8 */
NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */
SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */ ROM = READ_ONLY 0xDC00 TO 0xFBFF; Z_RAM = READ_WRITE 0x0060 TO 0x0090; RAM = READ_WRITE 0x00a0 TO 0x015F; END
PLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */ DEFAULT_RAM INTO RAM; DEFAULT_ROM, ROM_VAR, STRINGS INTO ROM; /* In case you want to use as well, be sure the option -OnB=b is passed to the compiler. */ _DATA_ZEROPAGE, MY_ZEROPAGE INTO Z_RAM; END
STACKSIZE 0x30
VECTOR 0 _Startup /* Reset vector: this is the default entry point for an application. */ VECTOR 2 IRQ1_ISR VECTOR 6 Timer_ISR
另MAP中断分配:
********************************************************************************************* VECTOR-ALLOCATION SECTION Address InitValue InitFunction --------------------------------------------------------------------------------------------- 0xFFF2 0xE7A4 Timer_ISR 0xFFFA 0xE78E IRQ1_ISR 0xFFFE 0xDC8C _Startup |