>下边是我写的一个16位自由计数器溢出中断的程序,但是不能触发中断,请高手不吝赐教</P><P><FONT color=#3c3cc4>#include <hidef.h> /* common defines and macros */<BR>#include <mc9s12dg128.h> /* derivative information */</FONT></P><P><BR><FONT color=#3c3cc4>#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"</FONT></P><P><FONT color=#3c3cc4>void main(void)<BR>{<BR> DDRB=0xff; // PTB as output <BR> TSCR1 = 0x10; // enable timer TCNT <BR> TSCR2 = 0x07; // TCNT prescaler setup<BR> TIE=0x00;<BR> TIOS=0x00;<BR> PORTB=0xff; // LEDs off <BR> EnableInterrupts;//开中断<BR> for (;;);<BR>}<BR>#pragma CODE_SEG NON_BANKED <BR>void interrupt 16 TCNT_ISR(void)</FONT></P><P><FONT color=#3c3cc4>{<BR> DisableInterrupts; //关中断 <BR> PORTB++;//PORTB自增<BR> EnableInterrupts<BR>}</FONT> </P>
>已解决</P><P><FONT color=#2b2bd5>void main(void)<BR>{<BR> DDRB=0xff; // PTB as output <BR> TSCR1 = 0x80; // enable timer TCNT <BR> TSCR2 = 0x87; // TCNT prescaler setup<BR> PORTB=0xff; // LEDs off <BR> EnableInterrupts;//开中断<BR> for (;;) {<BR> }<BR>}<BR>#pragma CODE_SEG NON_BANKED <BR>void interrupt 16 TCNT_ISR(void)</FONT></P><P><FONT color=#2b2bd5>{<BR> DisableInterrupts; //关中断 <BR> PORTB++;//PORTB自增<BR> TFLG2=0x80;<BR> EnableInterrupts<BR>} </FONT></P>
>我的BLOG上应该是有ECT的程序的,</P><P><A target=_blank href="http://blog.eccn.com/u/107300/index.htm">http://blog.eccn.com/u/107300/index.htm</A></P>| 欢迎光临 智能车制作 (http://www.znczz.com/) | Powered by Discuz! X3.2 |