Code: Select all
#include <Arduino.h>
HardwareTimer timer1(TIM1);
HardwareTimer timer8(TIM8);
void setup() {
Serial.begin(115200);
delay(3000) ; // monitor
// this works
timer1.setMode(1, TIMER_OUTPUT_COMPARE_PWM1, PA8); // PA8's AF6 is TIM1_CH1
timer1.setPrescaleFactor(170 - 1); //
TIM1->ARR = 200 ; /// timer1.setOverflow(200); //
TIM1->CCR1 = 50 ; /// timer1.setCaptureCompare(1, 50); // TIM1_CH1
timer1.resume();
// this doesn't work ...
timer8.setMode(1, TIMER_OUTPUT_COMPARE_PWM1, PB6); // PB6's AF5 is TIM8_CH1
timer8.setPrescaleFactor(170 - 1); //
TIM8->ARR = 200 ; /// timer8.setOverflow(200); //
TIM8->CCR1 = 25 ; /// timer8.setCaptureCompare(1, 25); // TIM8_CH1
timer8.resume();
// ... unless the pin AF is set manualy
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_6, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetAFPin_0_7(GPIOB, LL_GPIO_PIN_6, GPIO_AF5_TIM8);
}
void loop() {
Serial.print("o");
delay(50) ;
}