tianwen_4524 发表于 2013-9-7 09:17 
你的CpuTimer0Regs的定时中断使能了没啊(CpuTimer0Regs.TCR.bit.TIE = 1),仔细看,肯定哪里漏了什么?? ...
使能了。。。。。。如果没使能,不会出现有时好 有时不好的情况吧。主程序里面CpuTimer0Regs.TCR.bit.TSS = 0;开启了定时器
- void InitCpuTimers(void)
- {
- // CPU Timer 0
- // Initialize address pointers to respective timer registers:
- CpuTimer0.RegsAddr = &CpuTimer0Regs;
- // Initialize timer period to maximum:
- CpuTimer0Regs.PRD.all = 15000;
- // Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
- CpuTimer0Regs.TPR.all = 0;
- CpuTimer0Regs.TPRH.all = 0;
- // Make sure timer is stopped:
- CpuTimer0Regs.TCR.bit.TSS = 1;
- CpuTimer0Regs.TCR.bit.TIF = 0;
- CpuTimer0Regs.TCR.bit.TIE = 1;
- CpuTimer0Regs.TCR.bit.FREE= 0;
- CpuTimer0Regs.TCR.bit.SOFT= 0;
- // Reload all counter register with period value:
- CpuTimer0Regs.TCR.bit.TRB = 1;
- // Reset interrupt counters:
- CpuTimer0.InterruptCount = 0;
- }
|