cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger SPI Read using Timer Update Event

kcire L.
Associate III

Hello,

I am trying to trigger each DMA read of my SPI to happen on update event Trigger output of my Timer but I don't think I have it setup correctly.

I've seen this done using the internal ADC, where you can set the external conversion trigger source to the Timer Trigger output, but I don't know how you can do this with the SPI.

If anyone has any ideas and could explain this I would really appreciate it. I have attached my Timer and SPI CUBE MX settings here.

Thanks very much.

3 REPLIES 3
TDK
Guru

The hardware supports it, but I don't think it's something supported by CubeMX.

Setting the timer update event to trigger the DMA, and having the DMA transfer a dummy byte/word into SPI->DR would do the trick.

HAL_TIM_Base_Start_DMA is close to what you want but the destination is TIM_ARR, not the SPI_DR.

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

So would I need DMA setup for the timer as well as the SPI? Would you happen to be able to show me the lines of code that would be needed for this?

Thanks for the response

Yes, you would need one DMA to write to DR and the other to receive when data comes in.
If you feel a post has answered your question, please click "Accept as Solution".