cancel
Showing results for 
Search instead for 
Did you mean: 

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

HDevi.1
Associate II

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

5 REPLIES 5
TDK
Guru

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
Associate II

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!

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

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

KnarfB
Principal III

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