Question
TIM2 PWM is not working on P-Nucleo-wb55
I have set the TIM2 with the following code:
__HAL_RCC_TIM2_CLK_ENABLE();
htim2.Instance = TIM2;
htim2.Init.Prescaler = 0;
htim2.Init.Period = 80;
htim2.Init.RepetitionCounter = 0;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
HAL_TIM_PWM_Init(&htim2);
TIM_OC_InitTypeDef tim2OC1;
TIM_OC_InitTypeDef tim2OC2;
tim2OC1.OCMode = TIM_OCMODE_PWM1;
tim2OC1.Pulse = 20;
tim2OC1.OCPolarity = TIM_OCPOLARITY_HIGH;
tim2OC1.OCFastMode = TIM_OCFAST_DISABLE;
tim2OC1.OCNPolarity = TIM_OCNPOLARITY_HIGH;
HAL_TIM_PWM_ConfigChannel(&htim2, &tim2OC1, TIM_CHANNEL_1);
tim2OC2.OCMode = TIM_OCMODE_PWM1;
tim2OC2.Pulse = 40;
tim2OC2.OCPolarity = TIM_OCPOLARITY_HIGH;
tim2OC2.OCFastMode = TIM_OCFAST_DISABLE;
tim2OC2.OCNPolarity = TIM_OCNPOLARITY_HIGH;
tim2OC2.OCIdleState = TIM_OCIDLESTATE_RESET;
tim2OC2.OCNIdleState = TIM_OCNIDLESTATE_RESET;
HAL_TIM_PWM_ConfigChannel(&htim2, &tim2OC2, TIM_CHANNEL_2);
HAL_TIM_Base_Start(&htim2);
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1);
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2);
__HAL_RCC_GPIOA_CLK_ENABLE();The timer is working fine and in the debugging mode I find the value of counter increasing normally but when I connect the scope to the channel_1 pin PA_0 ==> A3 on the board no PWM out of the controller I checked with channel_2 also.
I also tried the code generated from Cube IDE mx with adding the TIM Start and PWM Start in the main but with no result.
So what's wrong ?