cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Rx via DMA... SCLK generation?

mreed
Associate III
Posted on May 19, 2014 at 21:41

I'm wanting to update a product that has a SPI device on the same channel as the UART.  Currently the SPI device uses DMA - it sends 1 byte and receives a packet of info.  On the UART we only send data.

I would like to split the DMA up and use one channel for the UART and one for the SPI, but I've been told we can't because the SPI will not generate the clock unless it is sending out data (currently a bunch of '0's).

I am considering switching the SPI to Rx only after the 1 byte command is sent.

Does anyone have any experience with this or suggestions?  Just want to get all the info I can before I start ripping software apart.

-Matt

#dma #spi #spi-usart
4 REPLIES 4
Posted on May 20, 2014 at 00:07

You're kind of stuck pumping data out to generate the clock.

Pick the interface with the lowest bandwidth, and service that with interrupts.

I'd review the reference manual, but you don't mention a specific STM32 family, USART or SPI channel.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
jpeacock2399
Associate II
Posted on May 20, 2014 at 00:59

Instead of SPI try running the USART in synchronous mode, generate the clock out from the baud rate.  That way both devices can share the same RX and TX pins, and the same DMA channels.  After all, SPI really isn't anything more than a 1960's vintage synchronous serial port, other than finer control over clock phase and trigger.

  Jack Peacock

mreed
Associate III
Posted on May 20, 2014 at 14:52

Thanks for the feedback Clive!

We have three different products that use the same library - STM32L151, STM32F103 and

STM32F427.  The first two are the same DMA, the 427 is slightly different but doable.

I found that while the SPI device will dump around 376 bytes, it does it rarely.  So I can easily switch over to the UART and just service the SPI when necessary.

-Matt

mreed
Associate III
Posted on May 20, 2014 at 14:53

Thanks for the feedback Jack.  But we can't change the hardware.

-Matt