这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » [求助]请教定时器中断

共1条 1/1 1 跳转至

[求助]请教定时器中断

菜鸟
2005-09-08 00:08:12     打赏
初学ARM,我编程实现每隔30秒向串口发送数据,采用定时器中断,程序如下,但是却不能每隔30十秒发送,请高手们给予指教,点拨点拨我,看我那里编的不对劲,我用的是44BX0,用定时器3,谢谢

int main(void)
{char text[]={"dddddd"};
ARMTargetInit();
Init_Timer3(255,4,65535,0);
while(1){
Uart_SendString(0,text);
Start_Timer3();
INTS_OFF();
SetISR_Interrupt(INT_TIMER3_OFFSET,Timer3_ISR,0);
Open_INT_GLOBAL();
Open_INT(BIT_TIMER3);
INTS_ON(); }
return(0);
}
定时器中断程序:
void Timer3_ISR(void)
{int Timer3INTCount=0;
Timer3INTCount++;
if(Timer3INTCount>=30)
{
rTCON&=~(0x01<<19); //DISABLE AUTO RELOAD
Close_INT(BIT_TIMER3);}
}

void Start_Timer3(void)
{ rTCON|=(0x01<<17);//Manual Update
rTCON&=~(0x01<<18);//Inverter off
rTCON|=(0x01<<16);//Start Timer3
rTCON&=~(0x01<<17);//Must clear Manual update bit

void Init_Timer3(U8 prescaler1,U8 divider3,U16 countb3,U16 compb3)
{ U8 div;
switch(divider3)
{case 2: div=0x00;break;
case 4: div=0x01;break;
case 8: div=0x02;break;
case 16: div=0x03;break;
default: div=0x04;

rTCFG0&=~(0xff<<8);
rTCFG0|=(prescaler1<<8);
rTCFG1&=~(0x0f<<24|0x0f<<12);
rTCFG1|=(div<<12);
rTCMPB3=compb3;
rTCNTB3=countb3;
rTCON|=(0x01<<19);//Auto reload
}

void SetISR_Interrupt(int vector, void (*handler)(), int ExInt)
{
if(vector==EINT4567_OFFSET){
InterruptHandlers[vector] = ExInt4567;
ExInt4567Handlers[ExInt] = handler;
}
else {
InterruptHandlers[vector] = handler;
}
}




关键词: 求助     请教     定时器     中断    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]