智能车制作

标题: 关于定时器中断的 [打印本页]

作者: starlovejie    时间: 2008-10-30 05:24
标题: 关于定时器中断的
<><BR>时钟初始化<BR>void Init(void)<BR>{<BR>REFDV=0x01; /* initiate PLL clock */<BR>SYNR =0x02; /* system clock 24M */<BR>//while (!(CRGFLG &amp; 0x08)){} /* wait untill steady */<BR>CLKSEL=0x80; /* 选定所相环时钟 */<BR>FCLKDIV=0x49; /* 使FLASH 和 EEPROM */<BR>/* 的擦除操作工作频率在200HZ左右 */<BR>ECLKDIV=0x49;<BR>ECT_Init() ;<BR>}<BR>//*中断初始*//</P><P>void ECT_Init(void) <BR>{<BR>&nbsp;&nbsp; TSCR2_PR&nbsp;&nbsp; = 7;&nbsp; <BR>&nbsp;&nbsp; TSCR2_TOI&nbsp; = 1;&nbsp; //timer overflow interrupt enable<BR>&nbsp;&nbsp; TSCR1_TEN&nbsp; = 1;&nbsp; //timer enable<BR>}<BR>void main(void) {<BR>&nbsp; Init();<BR>EnableInterrupts;</P><P>&nbsp; for(;;)<BR>{}<BR>}<BR>void Int_TimerOverFlow(void)<BR>{<BR>&nbsp;&nbsp; TFLG2_TOF&nbsp; = 1;&nbsp; //clear timer overflow flag<BR>&nbsp;&nbsp; //用户自己的代码<BR>&nbsp;&nbsp; n=n-1;<BR>}<BR>我的程序大概是这样的,我该如何设置初始值 才能实现 一秒中断一次 然后n自减1<BR>或者大家有没有好点的实现1秒中断一次的方法 希望能分享一下,先谢谢大家了! </P>
作者: whut_wj    时间: 2008-10-30 06:23
标题: Re:关于定时器中断的
<>又是定时的,呵呵,我发的那个测速的有定时模块,MDC写的,还可以用实时中断RTI.</P><P>都有例子的,你仔细找找吧.</P>
作者: starlovejie    时间: 2008-10-30 06:29
标题: Re:关于定时器中断的
恩 好的 我看看啊 谢谢




欢迎光临 智能车制作 (http://111.231.132.190/) Powered by Discuz! X3.2