@@ -147,12 +147,11 @@ TIM_HandleTypeDef* stm32_initPinPWM(uint32_t PWM_freq, PinMap* timer, uint32_t m
147147 return NULL ;
148148 TIM_HandleTypeDef* handle = stm32_getTimer (timer);
149149 uint32_t channel = STM_PIN_CHANNEL (timer->function );
150- #ifdef SIMPLEFOC_STM32_DEBUG
151- SIMPLEFOC_DEBUG (" STM32-DRV: Configuring timer " , (int )stm32_getTimerNumber (handle->Instance ));
152- SIMPLEFOC_DEBUG (" STM32-DRV: Configuring channel " , (int )channel);
153- #endif
154150 if (handle==NULL ) {
155151 handle = stm32_useTimer (timer);
152+ #ifdef SIMPLEFOC_STM32_DEBUG
153+ SIMPLEFOC_DEBUG (" STM32-DRV: Initializing TIM" , (int )stm32_getTimerNumber (handle->Instance ));
154+ #endif
156155 uint32_t arr = stm32_setClockAndARR (handle, PWM_freq);
157156 if (arr<SIMPLEFOC_STM32_MIN_RESOLUTION) {
158157 SIMPLEFOC_DEBUG (" STM32-DRV: WARN timer resolution too low (<8bit): " , (int )arr+1 );
@@ -162,7 +161,6 @@ TIM_HandleTypeDef* stm32_initPinPWM(uint32_t PWM_freq, PinMap* timer, uint32_t m
162161 SIMPLEFOC_DEBUG (" STM32-DRV: Timer resolution set to: " , (int )arr+1 );
163162 #endif
164163 }
165-
166164 }
167165 TIM_OC_InitTypeDef channelOC;
168166 channelOC.OCMode = TIM_OCMODE_PWM1;
@@ -184,6 +182,11 @@ TIM_HandleTypeDef* stm32_initPinPWM(uint32_t PWM_freq, PinMap* timer, uint32_t m
184182 if (IS_TIM_BREAK_INSTANCE (handle->Instance )) {
185183 __HAL_TIM_MOE_ENABLE (handle);
186184 }
185+ #ifdef SIMPLEFOC_STM32_DEBUG
186+ SimpleFOCDebug::print (" STM32-DRV: Configured TIM" );
187+ SimpleFOCDebug::print ((int )stm32_getTimerNumber (handle->Instance ));
188+ SIMPLEFOC_DEBUG (" _CH" , (int )channel);
189+ #endif
187190 return handle;
188191}
189192
0 commit comments