Help! TIM3 hardware timer is running 10* faster than configured

Post here all questions related to STM32 core if you can't find a relevant section!
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: Help! TIM3 hardware timer is running 10* faster than configured

Post by Bambo »

So i found out that it was actually a call to HAL_SAI_Receive() which is blocking the ISR routine making it run continuously so the main loop() wasn't called. HAL_SAI_Receive() takes 3000us to complete when it should take much much less time.
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: Help! TIM3 hardware timer is running 10* faster than configured

Post by Bambo »

Turns out, it was because i set the HardwareTimer to TIM3 when i think it's being used by a serial port somewhere. Switching it to TIM6 fixed it.
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: Help! TIM3 hardware timer is running 10* faster than configured

Post by Bambo »

@ABOSTM

How can i determine what TIM's are in use? I'm using HardwareSerial and HardwareTimer at the same time and they are conflicting.

Configuring the hardware timer at TIM6 i get an assertion thrown in file stm32l4xx_hal_tim.c line 3427?

Thanks - Richard
mlundin
Posts: 94
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 6
Location: Sweden

Re: Help! TIM3 hardware timer is running 10* faster than configured

Post by mlundin »

Just a comment, nowhere in the previous posts did you mention the call to HAL_SAI_Receive() inside the timer callback.

How do you expect folks to give sensible help???

As far as I know the serial port drivers dont use any hardware timers. It might be some other code running that has not been mentioned.
ABOSTM
Posts: 60
Joined: Wed Jan 08, 2020 8:40 am
Answers: 7

Re: Help! TIM3 hardware timer is running 10* faster than configured

Post by ABOSTM »

I'm using HardwareSerial and HardwareTimer at the same time and they are conflicting.
No !! HardwareSerial and HardwareTimer are not conflicting: HardwareSerial is using UART or USART peripheral, whereas HardwareTimer is using TIM peripheral.
Maybe you mean SoftwareSerial.

==========================================================
How can i determine what TIM's are in use?
Some Timer maybe used by Tone and servo, the instance used is defined in your variant.h
for example : https://github.com/stm32duino/Arduino_C ... 2RE.h#L115
Also SoftwareSerial may use a Timer, default instance used will be determined depending on availability of instance and what we think as being the best choice (based on lack of features and compare channels). see https://github.com/stm32duino/Arduino_C ... al.cpp#L43
Nevertheless as stated in comment : It's best to define TIMER_SERIAL in variant.h

And also analogWrite(pin, value) may also use a timer: if DAC is not present on the pin, but TIM capability is present on this pin then PWM will be generated with dutycycle corresponding to value. Instance of timer used will be determined by PinMap_PWM[] (former PinMap_TIM[]) in PeripheralPins.c.

============================================================
Configuring the hardware timer at TIM6 i get an assertion thrown in file stm32l4xx_hal_tim.c line 3427?
as stated in https://github.com/stm32duino/wiki/wiki ... troduction
... The use of this library suppose you have some basic knowledge of STM32 hardware timer architecture. First of all remind that all timers are not equivalent and doesn't support the same features. Please refer to the Reference Manual of your MCU.

Looking at Reference Manual you will se that TIM6 doesn't have Output capabilities !
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: Help! TIM3 hardware timer is running 10* faster than configured

Post by Bambo »

I turned the timer off and thought it was working :twisted: managed to get a sketch to reproduce it though, just gotta figure out whats wrong with this SAI configuration :?:
Post Reply

Return to “General discussion”