cancel
Showing results for 
Search instead for 
Did you mean: 

Interrupt service routine inconsistency

Woelki
Associate

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.

 

 

1 REPLY 1
TDK
Super User

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.

If you feel a post has answered your question, please click "Accept as Solution".