Hello there,
I have some problem related to HardwareTimer, when i call analogWrite(PB8,x) on blue pill it somehow changes the TIM4 settings, I set the timer interrupt firing frequency of 200Hz, but when i called analogWrite(PB8,x) the interrupt fire at 1kHz, that's not what i want, does anyone know what is the problem?.
I use STM32F103C8 (Blue Pill), STM32Core, PB8 is T4C3.
analogWrite changes HardwareTimer settings
analogWrite changes HardwareTimer settings
That is normal. Analogwrite uses the HardwareTimer and set it to get 1kHz.
To change the freq of the PWM signal use the analogWriteFrequency() before call the analogWrite
Go to full postTo change the freq of the PWM signal use the analogWriteFrequency() before call the analogWrite
Re: analogWrite changes HardwareTimer settings
That is normal. Analogwrite uses the HardwareTimer and set it to get 1kHz.
To change the freq of the PWM signal use the analogWriteFrequency() before call the analogWrite
To change the freq of the PWM signal use the analogWriteFrequency() before call the analogWrite
Re: analogWrite changes HardwareTimer settings
Ah i see, thank you, so i just need to analogWriteFrequency(timer.getOverflow(HERTZ_FORMAT));
Re: analogWrite changes HardwareTimer settings
Code: Select all
analogWriteFrequency(200);
Re: analogWrite changes HardwareTimer settings
My timer overflow value acually is variative, so it needs to adapt to it, if i explicitly call it like that, then it will unsynchronized once the overflow value changed.
Re: analogWrite changes HardwareTimer settings
If you use Timer4 for another stuff, then you should not use the Arduino API analogWrite which reconfigure it.
You can check those examples to configure the PWM as desired:
https://github.com/stm32duino/STM32Exam ... dwareTimer
You can check those examples to configure the PWM as desired:
https://github.com/stm32duino/STM32Exam ... dwareTimer