头像-314309

3ea6ff782c3aa7b2

个人成就

获得 0 次赞

帮助过2人

PWM输出至电机 使用逻辑分析仪得到的方波波形不稳定

void Moter_IOs_Init(void)    { GPIO_InitTypeDef  GPIO_InitStructure;   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA ENABLE);      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz   GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;   GPIO_Init(GPIOA &GPIO_InitStructure);    GPIO_ResetBits(GPIOAGPIO_Pin_7);   } void TIM13_PWM_Init(u32 arru32 psc) { GPIO_InitTypeDef GPIO_InitStructure; TIM_TimebaseInitTypeDef  TIM_TimebaseStructure; TIM_OCInitTypeDef  TIM_OCInitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM13ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA ENABLE);    GPIO_PinAFConfig(GPIOAGPIO_PinSource6GPIO_AF_TIM13); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;       GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;       GPIO_Init(GPIOA&GPIO_InitStructure);                 TIM_TimebaseStructure.TIM_Prescaler=psc;   TIM_TimebaseStructure.TIM_CounterMode=TIM_CounterMode_Up; TIM_TimebaseStructure.TIM_Period=arr;   TIM_TimebaseStructure.TIM_ClockDivision=TIM_CKD_DIV1; TIM_TimebaseInit(TIM13&TIM_TimebaseStructure); TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;   TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;     TIM_OCInitStructure.TIM_Pulse = 0; TIM_OC1Init(TIM13 &TIM_OCInitStructure); TIM_OC1PreloadConfig(TIM13 TIM_OCPreload_Enable);   TIM_ARRPreloadConfig(TIM13ENABLE); TIM_Cmd(TIM13 ENABLE);       } u8 key; int main (void) {         delay_init(72);     Moter_IOs_Init();     TIM13_PWM_Init(1999941);     PS2_Init();     PS2_SetInit();                                while(1)     {                          PS2_ClearData();             PS2_ReadData();              k = (((PS2_AnologData(PSS_LY))/5)*400);            if(k>20000)          {            k=20000;          }           TIM_SetCompare1(TIM13k);             delay_ms(50);      } } 

CCS5.5怎样进行工程移植

CCS5.5怎样进行工程移植?​