智能车制作

标题: 大家帮忙看看为什么不对呢 [打印本页]

作者: angelttlove    时间: 2008-11-14 05:23
标题: 大家帮忙看看为什么不对呢
<>#include &lt;hidef.h&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* common defines and macros */<BR>#include &lt;mc9s12dg128.h&gt;&nbsp;&nbsp;&nbsp;&nbsp; /* derivative information */<BR>#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"</P><P>#define T_count 2000</P><P>static unsigned char GET_pulse;<BR>&nbsp;void ini_pll() {<BR>&nbsp;&nbsp;&nbsp; REFDV =0x01;<BR>&nbsp;&nbsp; SYNR=0x03;<BR>&nbsp;&nbsp; asm{<BR>&nbsp;&nbsp; BRCLR CRGFLG, #$08,*<BR>&nbsp;&nbsp; BSET CLKSEL ,#$80<BR>&nbsp;&nbsp; }<BR>&nbsp;}<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;void ini_pacn0 (){<BR>&nbsp;&nbsp;&nbsp; TCTL4=0X03;<BR>&nbsp;&nbsp;&nbsp; ICPAR=0X01;<BR>&nbsp;&nbsp;&nbsp; PACN0=0Xff;<BR>&nbsp;}<BR>&nbsp; void ini_MDC(){<BR>&nbsp;&nbsp; MCCTL=0xe7;<BR>&nbsp; MCCNT = 2000; //(1/32M)*16*2000= 1ms <BR>&nbsp; MCCTL = MCCTL|0X08;<BR>&nbsp; }<BR>&nbsp; <BR>&nbsp; void delay(int i){<BR>&nbsp;&nbsp;&nbsp;&nbsp; int m,n;<BR>&nbsp;&nbsp;&nbsp;&nbsp; for(m=0;m&lt;i;m++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(n=0;n&lt;1000;n++);<BR>&nbsp; }</P><P>void main(void) {<BR>&nbsp; /* put your own code here */<BR>&nbsp;<BR>&nbsp; DDRB=0XFF;<BR>&nbsp; PORTB=0xaa;<BR>&nbsp; ini_pll();<BR>&nbsp; ini_pacn0();<BR>&nbsp; ini_MDC();<BR>&nbsp; EnableInterrupts;<BR>&nbsp;<BR>&nbsp; for(;;) {<BR>&nbsp;&nbsp; delay(1000);<BR>&nbsp;&nbsp; PORTB=~GET_pulse;<BR>&nbsp;&nbsp; delay(1000);</P><P>&nbsp; } /* wait forever */<BR>&nbsp; /* please make sure that you never leave this function */<BR>}</P><P>#pragma&nbsp;&nbsp;&nbsp; CODE_SEG __NEAR_SEG&nbsp; NON_BANKED<BR>&nbsp;void interrupt 26 MDC_IST(void){<BR>&nbsp;&nbsp;&nbsp; static unsigned int&nbsp; PULSE_count;<BR>&nbsp;&nbsp;&nbsp; MCFLG=0x08;<BR>&nbsp;&nbsp;&nbsp; PULSE_count++;<BR>&nbsp;&nbsp;&nbsp; if(PULSE_count==T_count){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GET_pulse=PACN0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PACN0=0x00;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PULSE_count=0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;}</P><P>我想写一个利用函数发生器的产生脉冲然后 用8位累加器计数的程序 用led灯来显示 <BR>为什么没有反应 大家能不能帮我看看</P><P>&nbsp;</P>
作者: whut_wj    时间: 2008-11-14 06:33
标题: Re:大家帮忙看看为什么不对呢
<>1、GET_pulse有数据没有?</P><P>2、你的那个delay(1000)有点长,改小点.</P>
作者: arbornix    时间: 2008-11-14 07:51
标题: Re:大家帮忙看看为什么不对呢
初始化函数是否应该在最开头???
作者: angelttlove    时间: 2008-11-14 18:41
标题: Re:Re:大家帮忙看看为什么不对呢
<>没有数据 </P><P>有哪个地方的初始化不正确吗</P><P>感觉自己的思路没有问题</P><P>但是。。。</P><P>大家指点一下吧</P>
作者: whut_wj    时间: 2008-11-14 19:53
标题: Re:大家帮忙看看为什么不对呢
<>把各个模块分割下来一个一个试,&nbsp; 一下看不出来什么问题.</P>




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