cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103C8T6 SPI capabilities

JShel.1
Associate II

I've been trying to use SPI on the STM32F103C8T6 for a project I've been working on for a while now. I still can't figure out how to buffer data using SPI to an array in a continuous stream.

This stream is continuous because there is no pause or break between 8-bit data transmissions/receptions like there are on USART. The data speed is ~4MHz. I also want it to use DMA (like the HAL_SPI_Receive_DMA function) because I don't want it to interrupt other critical code being executed.

I read the reference manual and ST says the max SPI speed is 18MHz, so unless the HAL library isn't built for continuous data streams, it shouldn't be a problem.

Continuous data stream output would also be useful for someone who wants to use SPI as a crude DAC via pulse density modulation (instead of using PWM.)

2 REPLIES 2

You did not tell us, master or slave.

Regardless, you simply set up the DMA channel respective to given SPI Rx or Tx, as circular, set the pointers, size, enable half-complete and complete interrupt of DMA, and start it. Everything needed is in the DMA (and SPI) chapters of RM.

Since then, it's just matter of whether your software can source/sink fresh data to/from the memory buffers, fast enough.

JW

Thank you for clarification of the setup- I definitely missed one of those steps. I assumed I could just use the HAL function as-is without setting up the DMA in its respective STMCubeIDE category (I'm inexperienced with it still.)

I am using SPI as slave (external clock,) but I think regardless if master/slave configuration will be similar.