TIMER

#define _ISR_STARTADDRESS 0x33ffff00
#define pIsr_Timer (*(unsigned *)(_ISR_STARTADDRESS+0x48))   //中断向量的地址

2440 (Timer0):

void Timer_Init()
{
  rINTMSK &=(~1<<10);   // 打开中断
  pIsr_Timer = (U32)MyTimer;
  rTCFG0 &= ~0xff;
 rTCFG0 |= 15;           //prescaler = 15+1
 rTCFG1 &= ~0xf;
 rTCFG1 |= 2;            //mux = 1/8
 rTCNTB0 = (PCLK>>7)/1000-1;
 rTCMPB0 = rTCNTB0>>1;  // 50%
 rTCON &= ~0x1f;
 rTCON |= 0xb;   //disable deadzone, auto-reload, inv-off, update TCNTB0&TCMPB0, start timer 0
 rTCON &= ~2;   //clear manual update bit
}

void __irq MyTimer()
{
dosomething();
}
MMU_Init();必须在main中添加,弄了好久 后来发现someone的blog。。。

你可能感兴趣的:(TIMER)