中级会员
- 积分
- 430
- 威望
- 316
- 贡献
- 84
- 兑换币
- 16
- 注册时间
- 2008-3-27
- 在线时间
- 15 小时
|
<>捕捉下降沿的问题:<BR>#include <hidef.h> /* common defines and macros */<BR>#include <mc9s12dg128.h> /* derivative information */<BR>#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"<BR>void SciInit()<BR>{<BR> SCI0BDL=52;// (unsigned char)((16000000UL /* OSC freq */ / 2) / 9600 /* baud rate */ / 16 /*factor*/<BR> SCI0CR1=0; /*normal,no parity*/<BR> SCI0CR2=0X0C; /*RIE=1,TE=1,RE=1*/<BR>}<BR>/*-------发射端程序----------------------*/<BR>void SciTx(unsigned char text)<BR>{<BR> while (!(SCI0SR1&0x80)); /* wait for output buffer empty */<BR> SCI0DRH=0;<BR> SCI0DRL=text;<BR>}<BR>unsigned char PulseCnt;<BR>void main(void)<BR>{<BR> <BR> SciInit();<BR> DDRB=0XFF;<BR> PORTB=0XFF;<BR> asm sei;<BR> TIOS=0X00;<BR> TSCR1=0X80;<BR> TSCR2=0X01;<BR> TCTL4=0X02;<BR> TIE=0X01;<BR> TFLG1=0X01;<BR> //DLYCT=0X03;<BR> PulseCnt=0X00;<BR> <BR> asm cli;<BR> // EnableInterrupts;<BR> for(;;){} //等待中断<BR>}<BR>#pragma CODE_SEG_NEAR_SEG NON_BANKED<BR> <BR> void interrupt IC0_ISR(void) <BR> {<BR> PulseCnt++;<BR> SciTx(PulseCnt);<BR> TFLG1=0X01;<BR> PORTB=~PulseCnt;<BR> }<BR>#pragma CODE_SEG DEFAULT</P><P>这个程序运行到 " for(;;){} //等待中断 " 就跳出,程序能捕捉到下降沿,但是为什么能跳出来,我就搞不清楚了,问了好多人都没能解释,看高手的了!</P> |
|