AnsweredAssumed Answered

STM32F103RET6 PWM

Question asked by ephraimoved on Apr 25, 2017
Latest reply on Apr 26, 2017 by Clive One

Dear Sir .

 

I am configuring A8,A9,A10,A11 for PWM OUTPUT.

I don't get an pwm output on PA9 , 

If I configure PA9 as output , Than I can toggle it.

 

Attached some code

 

/* Configure PWM Outputs */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);

 

// Enable TIM1 clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);

// Time Base configuration
TIM_TimeBaseStructure.TIM_Prescaler = 0x0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = 0x3FF; // 10 bit
TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0x0;
TIM_TimeBaseInit(TIM1 , &TIM_TimeBaseStructure);


// Channel 1,2 Configuration in PWM mode
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;
TIM_OCInitStructure.TIM_Pulse = 0x3ff;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low;
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;


TIM_OC1Init(TIM1,&TIM_OCInitStructure);


TIM_OCInitStructure.TIM_Pulse = 0x100;
TIM_OC2Init(TIM1,&TIM_OCInitStructure);

TIM_OCInitStructure.TIM_Pulse = 0x200;
TIM_OC3Init(TIM1,&TIM_OCInitStructure);

TIM_OCInitStructure.TIM_Pulse = 0x2ff;
TIM_OC4Init(TIM1,&TIM_OCInitStructure);

// TIM1 counter enable
TIM_Cmd(TIM1,ENABLE);

// Main Output Enable
TIM_CtrlPWMOutputs(TIM1,ENABLE);

 

 

Please Advise

Outcomes