cancel
Showing results for 
Search instead for 
Did you mean: 

SPI1 DMA INTERRUPT AFTER EACH BYTE TRANSMISSION

JHERI
Senior

Hello Guys

The IC I am communicating with via my Nucleo STM32F446 board uses SPI and require a Chip Select Low before each SPI byte transmitted, then CHIP SELECT high for x time and then low again for next byte.

So I am using SPI via DMA which is designed to send larger blocks of data, but is very weak in the control of CS / NSS

is there anyway I can cause an spi DMA interrupt after every byte tx via spi so I can control the Chip Select lines manually via a GPIO pin

Thank you for any help and info

6 REPLIES 6
S.Ma
Principal

I've seen such weird sensor using NSS pulse more. Maybe the SPI TI Mode could achieve that, otherwise, DMA won't help.

If a device needs NSS pulse every byte, transmission speed is probably not critical isn't it?

The SPI peripheral was very poorly designed,

I don't think DMA helps at all here, if you get an interrupt for every byte you'd be just as efficient managing it with IRQs.

The other alternative is to drive the pins from a pattern buffer, but you have to construct the buffer, and deal with the RAM it would consume.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I'd pull this out using a timer, one channel to generate NSS at its output, other to trigger DMA transfers to SPI.

In some newer STM32 (e.g. the 'F7s) SPI modules can do this natively, called "NSS pulse mode", controlled by NSSP bit.

JW

JHERI
Senior

Hi guys thanks for your replies

totally amazed that the SPI and DMA is designed so poorly whereby you can not control the action of either NSS or stand alone as GPIO CS pin

crazy, do ST designers not understand when working with SPI slave chips and devices, you require full control over the CS lines ??? enabling, disabling, timing of CS rising and falling, etc

It would seem that I can not send out an array of data via the DMA on the SPI due to not having CS pin control !!!

So there are no benefits to using the DMA spi mode even with using interrupt wich is still poor!!, you should not need to use interrupts to control the CS pin, it should be automatic !!! with the pre set timings and parameters configured

It also looks like even in SPI stand alone mode I will have to send out one byte at a time, rarely rarely POOR!!

I want to send an array of data but need to rise and lower the CS pin in between each byte.... such a simple thing that seems so hard to do on the ST32 ???

I'm just truly amazed that the SPI engine is designed so bad, not happy ;-(

Insted of complaining, you might be already doing what I recommended you. That allows you to use DMA to transmit through SPI, and simultaneously have full control over a pin to be used as CS.

Also, please, don't capitalize the initial post's title. In the internet world, it's considered shouting, and that's inappropriate in most cases.

JW

JHERI
Senior

Not really shouting or complaining just totally amazed at the lack of foresight and design skills from this range of arms and yes the SPI module design is POOR !!! (not shouting !!) for the lack of control of CS line

The SPI interface has been around many many years and CS lines for enabling IC's are nothing new, back in the 1990s developing with the various micros never ran in to issues like this. so yes a little narked !

waclawek.jan ....... Sometimes when there is frustration and incompetence it's GOOD yes GOOD to have a little shout, to clear the mind ! and its far from inappropriate ! it's not swearing and helping my mind body and soul to get the frustration off ones chest!

thanking for you feedback but It sounds all very complicated and very resourceful in hardware and code just to simply control one chip select pin which should be done automatically if the designs of the SPI were right in the beginning. so not really sure your suggestion is the right way forward for me, though as previously stated thank you!

I will keep it simple in code and transmit one byte at time via normal SPI mode as these are the only real options available due to already being told that the SPI design is really bad from a highly respected community member Clive Two.Zero