//初始化电机1_FTM void PWM_Motor_q(uint16_t PWM_L1,uint16_t PWM_L2) { FTM_InitTypeDef FTM_InitStruct1; FTM_InitStruct1.Frequency = 1000; // 1KHZ FTM_InitStruct1.FTMxMAP = FTM0_CH5_PD5; //FTM0_CH0 PC1引脚 FTM_InitStruct1.FTM_Mode = FTM_Mode_EdgeAligned; //边沿对齐模式 FTM_InitStruct1.InitalDuty = PWM_L1; //初始化后产生40%的占空比 FTM_Init(&FTM_InitStruct1); FTM_InitStruct1.InitalDuty = PWM_L2; //初始化后产生40%的占空比 FTM_InitStruct1.FTMxMAP = FTM0_CH7_PD7; FTM_Init(&FTM_InitStruct1); } //初始化电机2_FTM void PWM_Motor_w(uint16_t PWM_R1,uint16_t PWM_R2) { FTM_InitTypeDef FTM_InitStruct1; FTM_InitStruct1.Frequency = 1000; // 1KHZ FTM_InitStruct1.FTMxMAP = FTM0_CH4_PD4; //FTM0_CH0 PC1引脚 FTM_InitStruct1.FTM_Mode = FTM_Mode_EdgeAligned; //边沿对齐模式 FTM_InitStruct1.InitalDuty = PWM_R1; //初始化后产生40%的占空比 FTM_Init(&FTM_InitStruct1); FTM_InitStruct1.InitalDuty = PWM_R2; //初始化后产生40%的占空比 FTM_InitStruct1.FTMxMAP = FTM0_CH6_PD6; FTM_Init(&FTM_InitStruct1); } //初始化舵机_FTM void steer(uint16_t PWM_steer) //steering engine PTC1 { FTM_InitTypeDef FTM_InitStruct2; FTM_InitStruct2.Frequency = 50; // 50HZ FTM_InitStruct2.FTMxMAP = FTM0_CH0_PC1; //FTM0_CH0 PC1引脚 FTM_InitStruct2.FTM_Mode = FTM_Mode_EdgeAligned; //边沿对齐模式 FTM_InitStruct2.InitalDuty = PWM_steer; //初始化后产生40%的占空比 FTM_Init(&FTM_InitStruct2); } 如果代码这么写,初始化之后舵机就和频率和电机的一样了。 我想让舵机频率和电机频率不同 请问该怎么写? |
欢迎光临 智能车制作 (http://dns.znczz.com/) | Powered by Discuz! X3.2 |