要用freescale codewarrior ide写一个定时中断程序,是用mc9s12dt128b,但是我不知道怎么设置定时器

要用freescale codewarrior ide写一个定时中断程序,是用mc9s12dt128b,但是我不知道怎么设置定时器,达到每隔一段时间就执行中断的目的。下面是我写的部分代码
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
int count=0;
void Init (void) {
DisableInterrupts;
}
void main(void) {
/* put your own code here */
Init();
EnableInterrupts;
for(;;) {
_FEED_COP(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave main */
}

#pragma CODE_SEG_NEAR_SEG NON BLANKED
interrupt 16 void RTInt (void) {
count++;
}
#pragma CODE_SEG DEFAULT

希望有人告诉我:
1、如何设置定时器的寄存器
或者2、在数据手册中关于设置定时器的介绍在哪里
百度没分了,请高手无私帮助

芯片选择mc9s12dg128b,mc9s12dt128b这个芯片好像有点问题。
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */

#include "main_asm.h" /* interface to the assembly module */

int count = 0;

void main(void) {
/* put your own code here */

MCCTL = 0xce;//控制寄存器设置:开中断,启动减数定时
MCCNT = 0x40;//定时器初值
//MCFLG = 0x00;
TSCR1 = 0x90;//定时器启动;当定时器初值装入时,溢出标志清零
TSCR2 = 0x03;//关闭TCNT中断
EnableInterrupts;

asm_main(); /* call the assembly function */

for(;;) {
_FEED_COP(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave main */
}

void TimerOverflow(void){//定时器中断服务程序
DisableInterrupts;
count++;
MCCNT = 0x40;//定时器初值
EnableInterrupts;
}
注:在project.prm中末尾添加:VECTOR ADDRESS 0xFFCA TimerOverflow
温馨提示:答案为网友推荐,仅供参考
相似回答