@@ -147,12 +147,11 @@ TIM_HandleTypeDef* stm32_initPinPWM(uint32_t PWM_freq, PinMap* timer, uint32_t m
147
147
return NULL ;
148
148
TIM_HandleTypeDef* handle = stm32_getTimer (timer);
149
149
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
154
150
if (handle==NULL ) {
155
151
handle = stm32_useTimer (timer);
152
+ #ifdef SIMPLEFOC_STM32_DEBUG
153
+ SIMPLEFOC_DEBUG (" STM32-DRV: Initializing TIM" , (int )stm32_getTimerNumber (handle->Instance ));
154
+ #endif
156
155
uint32_t arr = stm32_setClockAndARR (handle, PWM_freq);
157
156
if (arr<SIMPLEFOC_STM32_MIN_RESOLUTION) {
158
157
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
162
161
SIMPLEFOC_DEBUG (" STM32-DRV: Timer resolution set to: " , (int )arr+1 );
163
162
#endif
164
163
}
165
-
166
164
}
167
165
TIM_OC_InitTypeDef channelOC;
168
166
channelOC.OCMode = TIM_OCMODE_PWM1;
@@ -184,6 +182,11 @@ TIM_HandleTypeDef* stm32_initPinPWM(uint32_t PWM_freq, PinMap* timer, uint32_t m
184
182
if (IS_TIM_BREAK_INSTANCE (handle->Instance )) {
185
183
__HAL_TIM_MOE_ENABLE (handle);
186
184
}
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
187
190
return handle;
188
191
}
189
192
0 commit comments