智能车制作

标题: 模数递减计数器调试问题 [打印本页]

作者: sunyb    时间: 2012-7-9 11:46
标题: 模数递减计数器调试问题
#include <hidef.h>      /* common defines and macros */
#include "derivative.h"      /* derivative-specific definitions */


void PLL_init(void){
  REFDV=1;
  SYNR=1;
  while(!(CRGFLG&0X08));
  CLKSEL=0X80;
  
  SCI0BDL=0X68;
  SCI0BDH=0X00;
  SCI0CR1=0X00;   //波特率设置
  SCI0CR2=0X2C;

}


long counter=0;

void main(void)
{
DisableInterrupts;
PLL_init();
MCCTL_MCEN=0;
MCCTL_MCZI=1;
MCCTL_MODMC=1;
MCCTL_MCPR1=1;
MCCTL_MCPR0=1;
MCCNT=0XAAAA;
MCCTL_RDMCL=0;
TSCR1=0X80;
TSCR2=0X00;  
MCCTL_MCEN=1;   

EnableInterrupts;

for(;;){}
}

#pragma CODE_SEG __NEAR_SEG NON_BANKED


interrupt void MDC(void)
{
counter++;
if(counter<=10)
PORTB=0X01;
if((counter>10)&&(counter<=20))
{
PORTB=0X02;
MCCNT=0X2222;
}
if((counter>20)&&(counter<=30))
{
PORTB=0X04;
MCCNT=0X4444;
}
if((counter>30)&&(counter<=40))
{
PORTB=0X08;
MCCNT=0X8888;
}
if((counter>40)&&(counter<=50))
{
PORTB=0X10;
MCCNT=0XDDDD;
}
if(counter>50)
counter=0;
MCFLG_MCZF=1;
}

#pragma CODE_SEG DEFAULT // Define Program ROM and Interrupt Vectors,Return Default Area

现在先不管后面的中断程序,
问题是中断进不去,for语句执行一次就 不知道跑哪里去了?求解
作者: sunyb    时间: 2012-7-9 14:22
问题已经解决,是中断入口写错了




欢迎光临 智能车制作 (http://111.231.132.190/) Powered by Discuz! X3.2