Skip to main content
Visitor II
December 9, 2025
Question

Interrupt service routine inconsistency

  • December 9, 2025
  • 1 reply
  • 91 views

Hi,

My problem is, that i want to trigger an SPI reading event, on an master timer repetition event. I registered the HAL_HRTIM_RepetitionEventCallback and start the SPI, within this function. The first problem is, that there is always a delay, that seems way too big, to start the peripheral at a CPU clock 0f 170MHZ. On the other side, that delay is not consistent, making it even harder to work with. 

Woelki_0-1765274522205.png

This is a waveform i get. In pink is the clk line of the SPI, you can see, that for whatever reason sometimes 4 transmissions take place, eventhough only one dataframe was set up. When the light blue line goes high, the SPI should be triggered by the according ISR. I´m not sure, what im doing wrong, but i even set the HRTIM interrupts to the highest priority to service earlier. 

Woelki_1-1765274857830.png

Here is my SPI setup. As i only want to recieve data, im using master recieve. I also tried full duplex and then i can get rid of the multiple data frames sent, but i thought this would then include dummy bytes sent and make the delay until reception longer.

 

 

    This topic has been closed for replies.

    1 reply

    Super User
    December 10, 2025

    What delay is “too big”? Consider doing this using DMA rather than code in an interrupt.

    Set up SPI in full duplex mode and write to TX to trigger a transaction. Using receive only mode may get additional clocks. Read from RX using DMA.