[size=13.3333px]我用STM32定时器3完全重映射到PC6 IO口,配置了一个PWM脉冲,为什么用示波器测不出波形,以下是相关配置代码,求大神们指导!(一定要用到完全重映射)
[size=13.3333px]void TIM3_CH1_Init(u16 arr,u16 psc)
[size=13.3333px]{
[size=13.3333px]
[size=13.3333px]GPIO_InitTypeDef GPIO_InitStructure;
[size=13.3333px]TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
[size=13.3333px]TIM_OCInitTypeDef TIM_OCInitStructure;
[size=13.3333px]//GPIO_AFIODeInit();
[size=13.3333px]RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
[size=13.3333px]RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO, ENABLE);
[size=13.3333px]GPIO_PinRemapConfig(GPIO_FullRemap_TIM3, ENABLE);
[size=13.3333px]
[size=13.3333px]GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
[size=13.3333px]GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
[size=13.3333px]GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
[size=13.3333px]GPIO_Init(GPIOC, &GPIO_InitStructure);
[size=13.3333px]TIM_TimeBaseStructure.TIM_Period = arr;
[size=13.3333px]TIM_TimeBaseStructure.TIM_Prescaler =psc;
[size=13.3333px]TIM_TimeBaseStructure.TIM_ClockDivision = 0;
[size=13.3333px]TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
[size=13.3333px]TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
[size=13.3333px]TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
[size=13.3333px]TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
[size=13.3333px]TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
[size=13.3333px]TIM_OC1Init(TIM3, &TIM_OCInitStructure);
[size=13.3333px]TIM_OC1PreloadConfig(TIM3, TIM_OCPreload_Enable);
[size=13.3333px]TIM_Cmd(TIM3, ENABLE);
[size=13.3333px]}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>