Skip to main content
HDevi.1
Associate II
March 10, 2022
Question

STM32L431RB Timer15 1 microsec interrupt generation. Is there anything incorrect with my timer15 peripheral configuration?

  • March 10, 2022
  • 5 replies
  • 2225 views

The APBCLK/AHBCLK is 80MHz.

when I toggle the GPIO in the callback, the scope trace gives me interrupt generation of 2.3 usec instead of 1usec. Is there any timing limitation for interrupt generation?

0693W00000Kc7oiQAB.png0693W00000Kc7iLQAR.png

This topic has been closed for replies.

5 replies

TDK
March 10, 2022

Your CPU is overloaded. A 1MHz interrupt at 80 MHz clock gives 80 cycles per interrupt, which, if you're using HAL, is certainly not enough. Even without HAL it can be marginal depending on what you're doing.

There's no limitation to interrupt generation. But you can only run code so fast.

"If you feel a post has answered your question, please click ""Accept as Solution""."
HDevi.1
HDevi.1Author
Associate II
March 10, 2022

Thanks for the reply.

So, In order to generate 1 us interrupt what parameter settings you would recommend? Or if it's not correct to generate 1 us interrupt hwta would be your recommendation period with less than 100us?

Thanks!

TDK
March 10, 2022

Your code is generating interrupts every 1us. But your cpu isn't keeping up with them. Looks like ~430kHz is the max you can do with your current code.

Lower the rate of generation so your CPU can keep up. Generally, 10kHz interrupt rate is fine. 100kHz might be fine with small code. All depends on what you're doing in the IRQ, of course.

"If you feel a post has answered your question, please click ""Accept as Solution""."
S.Ma
Principal
March 11, 2022

Use hw assist to relax the timings, or use FPGA. 1us interrupt is like 1000 heart beats per minutes stress.

KnarfB
Super User
March 11, 2022

If this is just for testing, as the pin name suggests, use the raw interrupt handler (generated in *_it.c file) with highest compiler optimization (no stack frame) instead of the HAL wrapper. The fastest way to waggle a pin is configuring it as EVENTOUT and issue a __SEV() instruction, not using GPIO at all.

hth

KnarfB