Skip to main content
PGama
Associate II
December 30, 2019
Question

In STM32F303RE my customer is trying to use 3 timers but problem is happening with using them at the same time as it is real time application

  • December 30, 2019
  • 6 replies
  • 1227 views

I am using TIM1&TIM8 for PWM generation and using TIM15 for PWM input capture mode, individually if I check in IAR TIM1&TIM8 WORK properly for PWM generation, and TIM15 properly in input capture mode, but if I use them all together after the first iteration of PWM input capture of TIM15, as soon as I initialize TIM1 or TIM8 processor goes to hard fault

In the same code if I comment TIM1 and TIM8, TIM15 works properly in input capture mode

And if I comment TIM15 other two work properly

This topic has been closed for replies.

6 replies

S.Ma
Principal
December 30, 2019

Increase the stack size maybe?

I assume that all interrupt service routine can coexist, clear the pending interrupt and have been put on same priority level and they don't use HAL_Delay() within them

All these for sanity check

oeliks
Associate III
December 30, 2019

You mean HAL_Delay(); in interrupt handler?

S.Ma
Principal
December 30, 2019

Interrupt handler should be as brief as possible and only manage what is critical, so so printf, no delays.

The embedded MCU art is to well understand all the interrupt max latency and duration and make sure there is no weak race condition which could occur once overnight. Usually there is no tool for this kind of profiling and this is what is the trickiest to manage.

Anyway, I really feel you should check what is the stack size used in the project.

Tesla DeLorean
Guru
December 30, 2019

Pretty sure the HW works correctly. More probable you have some blocking or deadlocking issue on the SW side.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
waclawek.jan
Super User
December 30, 2019

Debug the hardfault, track back from the stack content and the fault registers, where did the fault happen.

The technique to do this has been discussed here many times, search perhaps for "hardfault handler" in Clive's posts.

JW

berendi
Principal
December 31, 2019

Hardfault indicates a software problem, most likely uninitialized, corrupted or otherwise improperly used pointers, maybe stack overflow.

You have the code, we don't. How could we guess?