Skip to content

Commit

Permalink
Fix PWM_TIM initialization.
Browse files Browse the repository at this point in the history
All structure members need to be initialized otherwise they contain garbage
  • Loading branch information
dzid26 committed Sep 27, 2024
1 parent 18e010c commit 41d82a1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion firmware/src/BSP/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ static void A4950_init(void)
tim_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
tim_OCInitStructure.TIM_OutputNState = TIM_OutputState_Disable;
tim_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
tim_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low;
tim_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset; //Motor coasting when idle is set to reset
tim_OCInitStructure.TIM_OCNIdleState = TIM_OCNIdleState_Reset;
tim_OCInitStructure.TIM_Pulse = 0;
Expand All @@ -214,7 +215,7 @@ static void A4950_init(void)
TIM_OC2Init(PWM_TIM, &tim_OCInitStructure); //CH2
TIM_OC3Init(PWM_TIM, &tim_OCInitStructure); //CH3
TIM_OC4Init(PWM_TIM, &tim_OCInitStructure); //CH4

TIM_OC1PreloadConfig(PWM_TIM, TIM_OCPreload_Disable);
TIM_OC2PreloadConfig(PWM_TIM, TIM_OCPreload_Disable);
TIM_OC3PreloadConfig(PWM_TIM, TIM_OCPreload_Disable);
Expand Down

0 comments on commit 41d82a1

Please sign in to comment.