@@ -681,23 +681,29 @@ void* _configure8PWM(long pwm_frequency, float dead_zone)
681
681
__HAL_RCC_TIM1_CLK_ENABLE ();
682
682
__HAL_RCC_TIM8_CLK_ENABLE ();
683
683
684
- // Configure GPIO pins for STSPIN32G4 internal FET driver
685
-
686
- __HAL_RCC_GPIOE_CLK_ENABLE (); // enable GPIO clock
687
- GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_8 | GPIO_PIN_11 | GPIO_PIN_10 | GPIO_PIN_13 | GPIO_PIN_12;
688
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; // alternate function mode with push-pull output
684
+ // Configure PE8, PE9, PE10, PE11, PE12, PE13 as TIM1 channels
685
+ GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
686
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
689
687
GPIO_InitStruct.Pull = GPIO_NOPULL;
690
688
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
691
689
GPIO_InitStruct.Alternate = GPIO_AF6_TIM1;
692
- HAL_GPIO_Init (GPIOE, &GPIO_InitStruct);
690
+ HAL_GPIO_Init (GPIOE, &GPIO_InitStruct);
693
691
694
- // Configure TIM8 pins for alternate function mode with push-pull output
695
- GPIO_InitStruct.Pin = GPIO_PIN_14 | GPIO_PIN_0;
692
+ // Configure PA14 and PB0 as TIM8 channels
693
+ __HAL_RCC_GPIOA_CLK_ENABLE ();
694
+ __HAL_RCC_GPIOB_CLK_ENABLE ();
695
+ GPIO_InitStruct.Pin = GPIO_PIN_14;
696
696
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
697
697
GPIO_InitStruct.Pull = GPIO_NOPULL;
698
- GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
698
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
699
+ GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
699
700
HAL_GPIO_Init (GPIOA, &GPIO_InitStruct);
700
- HAL_GPIO_Init (GPIOB, &GPIO_InitStruct);
701
+ GPIO_InitStruct.Pin = GPIO_PIN_0;
702
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
703
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
704
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
705
+ GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
706
+ HAL_GPIO_Init (GPIOB, &GPIO_InitStruct);
701
707
702
708
703
709
0 commit comments