ch32v307vct6的完全重映射到引腳PE3-PE4-PE5,無法輸出PWM

各位專家您好,我在重映射TIM10的時候,無法輸出PWM

我的函數(shù)如下,請專家指導(dǎo),謝謝。

void?stepper_pwm_init(?void)
{
????GPIO_InitTypeDef????????GPIO_InitStructure={0};
????TIM_OCInitTypeDef???????TIM_OCInitStructure={0};
????TIM_TimeBaseInitTypeDef?TIM_TimeBaseInitStructure={0};
????RCC_APB2PeriphClockCmd(?RCC_APB2Periph_GPIOE?|?RCC_APB2Periph_TIM10?|?RCC_APB2Periph_AFIO,?ENABLE?);
????GPIO_PinRemapConfig(GPIO_FullRemap_TIM10?,?ENABLE);
????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5;
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_AF_PP;
????GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
????GPIO_Init(?GPIOE,?&GPIO_InitStructure?);
????TIM_TimeBaseInitStructure.TIM_Period?=?65536;
????TIM_TimeBaseInitStructure.TIM_Prescaler?=?1439;
????TIM_TimeBaseInitStructure.TIM_ClockDivision?=?TIM_CKD_DIV1;
????TIM_TimeBaseInitStructure.TIM_CounterMode?=?TIM_CounterMode_Up;
????TIM_TimeBaseInit(?TIM10,?&TIM_TimeBaseInitStructure);
#if?(PWM_MODE?==?PWM_MODE1)
????TIM_OCInitStructure.TIM_OCMode?=?TIM_OCMode_PWM1;
#elif?(PWM_MODE?==?PWM_MODE2)
????TIM_OCInitStructure.TIM_OCMode?=?TIM_OCMode_PWM2;

#endif
????TIM_OCInitStructure.TIM_OutputState?=?TIM_OutputState_Enable;
????TIM_OCInitStructure.TIM_Pulse?=?32767;
????TIM_OCInitStructure.TIM_OCPolarity?=?TIM_OCPolarity_High;
????TIM_OC1Init(?TIM10,?&TIM_OCInitStructure?);
????TIM_OC2Init(?TIM10,?&TIM_OCInitStructure?);
????TIM_OC3Init(?TIM10,?&TIM_OCInitStructure?);
????TIM_CtrlPWMOutputs(TIM10,?ENABLE?);
????TIM_OC1PreloadConfig(?TIM10,?TIM_OCPreload_Disable?);
????TIM_OC2PreloadConfig(?TIM10,?TIM_OCPreload_Disable?);
????TIM_OC3PreloadConfig(?TIM10,?TIM_OCPreload_Disable?);
????TIM_ARRPreloadConfig(?TIM10,?ENABLE?);
????TIM_Cmd(?TIM10,?ENABLE?);
}


上面的程序不知道為什么輸入進(jìn)來帶有很多問


上面程序不知道為什么輸入很多問好,麻煩專家參考如下的程序

void?stepper_pwm_init(?void)
{
????GPIO_InitTypeDef????????GPIO_InitStructure={0};
????TIM_OCInitTypeDef???????TIM_OCInitStructure={0};
????TIM_TimeBaseInitTypeDef?TIM_TimeBaseInitStructure={0};
????RCC_APB2PeriphClockCmd(?RCC_APB2Periph_GPIOE?|?RCC_APB2Periph_TIM10?|?RCC_APB2Periph_AFIO,?ENABLE?);
????GPIO_PinRemapConfig(GPIO_FullRemap_TIM10?,?ENABLE);
????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5;
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_AF_PP;
????GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
????GPIO_Init(?GPIOE,?&GPIO_InitStructure?);
????TIM_TimeBaseInitStructure.TIM_Period?=?100;
????TIM_TimeBaseInitStructure.TIM_Prescaler?=?14390;
????TIM_TimeBaseInitStructure.TIM_ClockDivision?=?TIM_CKD_DIV1;
????TIM_TimeBaseInitStructure.TIM_CounterMode?=?TIM_CounterMode_Up;
????TIM_TimeBaseInit(?TIM10,?&TIM_TimeBaseInitStructure);

????TIM_OCInitStructure.TIM_OCMode?=?TIM_OCMode_PWM1;
????TIM_OCInitStructure.TIM_OutputState?=?TIM_OutputState_Enable;
????TIM_OCInitStructure.TIM_Pulse?=?50;
????TIM_OCInitStructure.TIM_OCPolarity?=?TIM_OCPolarity_High;
????TIM_OC1Init(?TIM10,?&TIM_OCInitStructure?);
????TIM_OC2Init(?TIM10,?&TIM_OCInitStructure?);
????TIM_OC3Init(?TIM10,?&TIM_OCInitStructure?);
????TIM_CtrlPWMOutputs(TIM10,?ENABLE?);
????TIM_OC1PreloadConfig(?TIM10,?TIM_OCPreload_Disable?);
????TIM_OC2PreloadConfig(?TIM10,?TIM_OCPreload_Disable?);
????TIM_OC3PreloadConfig(?TIM10,?TIM_OCPreload_Disable?);
????TIM_ARRPreloadConfig(?TIM10,?ENABLE?);
????TIM_ClearFlag(TIM10,?TIM_FLAG_Update);
????TIM10->CNT=0;
????TIM_Cmd(?TIM10,?ENABLE?);
}



您好,PE3、4、5是作為互補(bǔ)通道使用的,若要PWM輸出,配置使用獨(dú)立的比較捕獲通道即可,可以配置使用截圖圈出的引腳。

image.png


老師您好,非常感謝,根據(jù)指導(dǎo),有一些進(jìn)展,現(xiàn)在 正向 PWM有輸出PD1-PD3-PD5閃爍, 但是負(fù)向的PWM還是沒變化,也就是PE3\PE4\PE5無變化,我的初始化程序如下,請您再指導(dǎo)下哈,謝謝。

void?stepper_pwm_init(?void)
{
????GPIO_InitTypeDef????????GPIO_InitStructure={0};
????TIM_OCInitTypeDef???????TIM_OCInitStructure={0};
????TIM_TimeBaseInitTypeDef?TIM_TimeBaseInitStructure={0};

????RCC_APB2PeriphClockCmd(?RCC_APB2Periph_GPIOE?|?RCC_APB2Periph_TIM10?|?RCC_APB2Periph_AFIO,?ENABLE?);
????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5;
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_AF_PP;
????GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
????GPIO_Init(GPIOE,?&GPIO_InitStructure?);

????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_1|GPIO_Pin_3|GPIO_Pin_5;
????GPIO_Init(?GPIOD,?&GPIO_InitStructure?);

????GPIO_PinRemapConfig(GPIO_FullRemap_TIM10?,?ENABLE);
????TIM_TimeBaseInitStructure.TIM_Period?=?65535;
????TIM_TimeBaseInitStructure.TIM_Prescaler?=?1439;
????TIM_TimeBaseInitStructure.TIM_ClockDivision?=?TIM_CKD_DIV1;
????TIM_TimeBaseInitStructure.TIM_CounterMode?=?TIM_CounterMode_Up;
????TIM_TimeBaseInit(?TIM10,?&TIM_TimeBaseInitStructure);

????TIM_OCInitStructure.TIM_OCMode?=?TIM_OCMode_PWM1;
????TIM_OCInitStructure.TIM_OutputState?=?TIM_OutputState_Enable;
????TIM_OCInitStructure.TIM_OutputNState?=?TIM_OutputState_Enable;
????TIM_OCInitStructure.TIM_Pulse?=?32767;
????TIM_OCInitStructure.TIM_OCNPolarity=TIM_OCPolarity_Low;
????TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_High;
????TIM_OCInitStructure.TIM_OCIdleState=TIM_OCIdleState_Set;
????TIM_OCInitStructure.TIM_OCNIdleState=TIM_OCIdleState_Reset;
????TIM_OC1Init(?TIM10,?&TIM_OCInitStructure?);
????TIM_OC2Init(?TIM10,?&TIM_OCInitStructure?);
????TIM_OC3Init(?TIM10,?&TIM_OCInitStructure?);
????TIM_CtrlPWMOutputs(TIM10,?ENABLE?);
????TIM_OC1PreloadConfig(?TIM10,?TIM_OCPreload_Disable?);
????TIM_OC2PreloadConfig(?TIM10,?TIM_OCPreload_Disable?);
????TIM_OC3PreloadConfig(?TIM10,?TIM_OCPreload_Disable?);
????TIM_ARRPreloadConfig(?TIM10,?DISABLE?);
????TIM10->CNT=0;
????TIM_Cmd(?TIM10,?ENABLE?);
}



您好,PE3、4、5是互補(bǔ)通道,程序中要進(jìn)行互補(bǔ)通道的配置,EVT有對應(yīng)的例程,可以參考一下。


只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频