中级会员
- 积分
- 487
- 威望
- 242
- 贡献
- 137
- 兑换币
- 118
- 注册时间
- 2012-10-24
- 在线时间
- 54 小时
|
3#
楼主 |
发表于 2013-1-28 09:45:42
|
只看该作者
冰葑世纪 发表于 2013-1-27 22:06
中值取决与你的舵机的安装方法,具体还得用不断缩小范围的方法来调。
可能是程序的错?舵机只往一个方向转,占空比调多少都是那样.这是舵机的初始化,有没有什么错误的地方
void FTM1_init(void)
{
SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;
PORTB_PCR0 = PORT_PCR_MUX(0x3)| PORT_PCR_DSE_MASK;; // FTM is alt3 function for this pin
SIM_SCGC6|=SIM_SCGC6_FTM1_MASK; //使能FTM1时钟
FTM1_C0SC |= FTM_CnSC_ELSB_MASK;
FTM1_C0SC &= ~FTM_CnSC_ELSA_MASK;
FTM1_C0SC |= FTM_CnSC_MSB_MASK;
FTM1_SC = FTM_SC_PS(6) | FTM_SC_CLKS(1);
FTM1_MODE &= ~3; //BIT0 FTM Enable
FTM1_OUTMASK &= ~3; //0 Channel output is not masked. It continues to operate normally.
FTM1_COMBINE=0; //Function for Linked Channels (FTMx_COMBINE)
FTM1_OUTINIT=0;
FTM1_EXTTRIG=0;
FTM1_POL=0;
FTM1_QDCTRL &=~FTM_QDCTRL_QUADEN_MASK;
FTM1_INVCTRL=0; //反转控制
FTM1_SWOCTRL=0; //软件输出控制F TM Software Output Control (FTMx_SWOCTRL)
FTM1_PWMLOAD=0; //FTM PWM Load
FTM1_CNTIN=0; //Counter Initial Value
FTM1_MOD=19531; //Modulo value,The EPWM period is determined by (MOD - CNTIN + 0x0001)
//采用龙丘时钟初始化函数,可以得到2分频的频率,系统60M频率时,PWM频率是30M,以此类推
//PMW频率=X系统频率/2/(2^FTM1_SC_PS)/FTM1_MOD=125000000/2/(2^6)/19531=50HZ
FTM1_C0V=1484; //设置 the pulse width(duty cycle) is determined by (CnV - CNTIN).
FTM1_C1V=1484;
FTM1_CNT=0; //只有低16位可用
}
|
|