Re: 请教一个奇怪的中断服务程序问题
|
||||
---|---|---|---|---|
新會員
|
懂了,谢谢指教!
發表於: 2009/5/22 16:39
|
|||
|
请教一个奇怪的中断服务程序问题
|
||||
---|---|---|---|---|
新會員
|
诚心请教:开了定时器中断,如果没写中断服务子程序的话,会出现什么情况?以下是我的程序,实际测试中发现上述情况下片子会复位,LED灯会闪烁。
测试条件为: 单片机——dsPIC30F4011 看门狗——关闭,掉电复位——关闭。 #include <p30f4011.h> #define LED _LATC14 _FOSC(CSW_FSCM_OFF & XT_PLL4); //XT为4*PLL振荡器,失效保险时钟关闭 _FWDT(WDT_OFF & WDTPSA_512 & WDTPSB_1); //禁止看门狗定时器,复位时间2ms*512*1=1.024s _FBORPOR( PBOR_OFF & MCLR_EN & //禁止掉电复位,使能MCLR复位 RST_PWMPIN & PWMxH_ACT_HI & PWMxL_ACT_HI); //PWM模块控制复位时引脚状态,输出高电平有效 _FGS(CODE_PROT_OFF); void Init ( void ) { uint tttry; /* IO端口初始化 */ TRISB = 0x01FF; //RB设置为输入 TRISC = 0xA000; //RC14设置为输出,RC13,RC15设置为输入 LED=0; //RC14输出低电平 for(tttry=1000;tttry>=1;tttry--); TRISD = 0x000F; //RD0~RD3设置为输入 TRISE = 0x0100; //RE8设置为输入,RE0~RE5设置为输出 TRISF = 0x001D; //RF1,RF5,RF6设置为输出,其余引脚为输入 _LATF6=0; //RF6引脚输出低电平 /* 定时器1初始化 */ T1CON=0; //关闭定时器1 TMR1=0; //定时器计数寄存器清零 PR1=25000; //计数至PR1溢出,溢出间隔为25000*1/4*8us=50ms T1CON=0x8010; //定时器开,预分频比1:8,内部时钟,FOSC/4=4MHz/4=1MHz _T1IP=4; //中断优先级为4 _T1IF=0; //清中断标志 _T1IE=1; //使能定时器1中断 } void __attribute__((__interrupt__)) _T1Interrupt(void) { _T1IF=0; //清中断标志位 LED_timer++; if(LED_timer>=20) { LED_timer=0; } return; } int main ( void ) { Init(); while(1) { LED=1; } while(1){} }
發表於: 2009/5/22 9:38
|
|||
|