智能车制作

标题: 关于PWM的级联 [打印本页]

作者: ahgydxmas    时间: 2008-4-5 00:47
标题: 关于PWM的级联
<>我的这个级联程序对吗?怎么下载后舵机不能正常运转?如错,能否指出来,谢谢各位了</P><P>&nbsp;#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>&nbsp;void main(void)<BR>{ <BR>&nbsp; PWME=0X00;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //禁止PWM输出<BR>&nbsp; PWMCTL=0XF0;&nbsp;&nbsp;&nbsp; //通道级联模式<BR>&nbsp; PWMPRCLK=0X33;&nbsp; //时钟A,B8分频 <BR>&nbsp; PWMCLK=0X0A;&nbsp;&nbsp;&nbsp; //通道01时钟源为1MHZ&nbsp; PP01:舵机 <BR>&nbsp; PWMSCLB=0X80;&nbsp;&nbsp; //时钟SB为1MHz/128/2 <BR>&nbsp; PWMPOL=0XFF;&nbsp;&nbsp;//通道0输出波形开始极性为1&nbsp; <BR>&nbsp; PWMCAE=0x00;&nbsp;&nbsp;&nbsp; //左对齐输出模式&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; PWMPER01=10000; //设定舵机输出周期10ms <BR>&nbsp; PWMDTY01=1520;&nbsp;&nbsp; //占空比初始为1520us&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; <BR>&nbsp; PWME=0X03;&nbsp;&nbsp;&nbsp;//通道01使能&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; while(1)<BR>&nbsp; {<BR>&nbsp; }<BR>} </P>




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