cancel
Showing results for 
Search instead for 
Did you mean: 

SPI data transfer using DMA with a L6470 dSPIN device

goeckeritz
Associate II
Posted on April 22, 2014 at 14:24

Hey everyone,

I am using a STM32F0-Discovery with a L6470 stepper driver IC attached. As a sofwtare basis I currently use ChibiOS. I am able to command the L6470 utilizing the DMA controller for SPI data transfer but I see some glitches on the lines. This is due to the CS pin toggeling after each single byte has been sent. If I was able to send all command bytes, e.g. run command has 4 bytes, in a row transmission would be done way more efficent and quicker.

To overcome this issue I thought of having the DMA shifting out the 4 bytes (to stick with the example) but to somehow hook into the stream, each time a single byte has been shifted out, toggeling the CS pin and then let the DMA run again. Let me put it the other way, DMA should handle the toggeling of a single GPIO pin as well as shifting out bsytes over SPI. Is that possible?

Which other solution might be applicable to the combo of two ST devices, what did the designers have in mind? Solution now is, to do polled SPI data exchange - without DMA, then :(

Any comment is highly appreciated.

Regards

#stm32 #l6470
2 REPLIES 2
Posted on April 22, 2014 at 15:51

I think toggling means something different to you, as far as I can tell it expects -CS to assert per byte, this is somewhat of a minority expectation of multi-byte SPI devices, and the ST implementation for SPI/NSS on the STM32 is not particularly flexible.

If you don't like spinning in loops, consider using an interrupt driven approach. The complexity of adding DMA for 4 bytes seems a bit high for any perceivable gain it brings.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
goeckeritz
Associate II
Posted on April 24, 2014 at 09:41

Well, when talking about toggelingI think of changing the state of a pin twice, so one sees e.g. a high-low-high level change over time when measuring the pin state.

Actually I was able to get to a sufficient solution after rereading the Programming Manual, Reference Manual and the datasheet of the STM32F051. I now use the NSS pulse mode and SlaveSelect pin (NSS) operated by hardware. So I had to init the NSS pin als alternate function 0, earlier I used the NSS pin as GPIO output and pulled high and low per software. As a sidenote, one has to use the SPI_X related fixed NSS pin then, which I already did.

See here a saleae screenshot of a 4 byte consecutive byte transfer that now is L6470 compatible and quick, I guess the fastest L6470 allows.

0690X00000604xRQAQ.png

Thanks for your thoughts.

Cheers