2024-06-18 11:57 PM
Hello,
I am building a time critical application with SPI output communication using DMA circular buffer
I need to output data at a very precise frequency that is a multiple of 0.125 ns. Normally it should be 4us but It would need to be sometime 3.9us or 3.8.
For the moment I use SPI1 as Master with 64 MHz and a prescaler of 256 to get 4us data pulse.
Quick question:
Can I use a timer to clock the SPI ? in that case does it mean that I have to change it to slave mode ? Can I init transfer in slave mode and trigger DMA transmit buffer still in circular mode ?
That way I can define the period if the timer and adjust the output frequency of the SPI clock
Is there any exemple of this (if it make sens)
Thanks
Vincent
Solved! Go to Solution.
2024-06-19 01:49 AM
> Can I use a timer to clock the SPI ?
Yes, if you connect SCK to timer output externally.
> in that case does it mean that I have to change it to slave mode ?
Yes.
> Can I init transfer in slave mode and trigger DMA transmit buffer still in circular mode ?
Yes, but the SPI Tx won't start upon the DMA transfer. You have to be careful to start DMA before the timer, so that the SPI dta register has been written, i.e. Tx buffer already has the data, at the moment when the clocks start.
You have to manage NSS, too (either external or, probably better, internal).
> Is there any exemple of this
I don't think so.
JW
2024-06-19 01:49 AM
> Can I use a timer to clock the SPI ?
Yes, if you connect SCK to timer output externally.
> in that case does it mean that I have to change it to slave mode ?
Yes.
> Can I init transfer in slave mode and trigger DMA transmit buffer still in circular mode ?
Yes, but the SPI Tx won't start upon the DMA transfer. You have to be careful to start DMA before the timer, so that the SPI dta register has been written, i.e. Tx buffer already has the data, at the moment when the clocks start.
You have to manage NSS, too (either external or, probably better, internal).
> Is there any exemple of this
I don't think so.
JW
2024-06-19 05:12 AM
Thanks Jan,
This is a bit what I thought, I will give it a try
Vincent