Skip to content

Commit 2aa8531

Browse files
committed
HardwareTimer: specific F1 GPIO needs Alternate Function configuration
Fixes #1036
1 parent 6ef6b0d commit 2aa8531

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Diff for: cores/arduino/HardwareTimer.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -668,17 +668,15 @@ void HardwareTimer::setMode(uint32_t channel, TimerModes_t mode, PinName pin)
668668

669669
if (pin != NC) {
670670
if ((int)get_pwm_channel(pin) == timChannel) {
671+
/* Configure PWM GPIO pins */
672+
pinmap_pinout(pin, PinMap_PWM);
671673
#if defined(STM32F1xx)
672674
if ((mode == TIMER_INPUT_CAPTURE_RISING) || (mode == TIMER_INPUT_CAPTURE_FALLING) \
673675
|| (mode == TIMER_INPUT_CAPTURE_BOTHEDGE) || (mode == TIMER_INPUT_FREQ_DUTY_MEASUREMENT)) {
674676
// on F1 family, input alternate function must configure GPIO in input mode
675-
pinMode(pin, INPUT);
676-
} else
677-
#endif
678-
{
679-
/* Configure PWM GPIO pins */
680-
pinmap_pinout(pin, PinMap_PWM);
677+
pinMode(pinNametoDigitalPin(pin), INPUT);
681678
}
679+
#endif
682680
} else {
683681
// Pin doesn't match with timer output channels
684682
Error_Handler();

0 commit comments

Comments
 (0)