cancel
Showing results for 
Search instead for 
Did you mean: 

SPI HW NSS Incompatibility between STM32H7 and STM32F4

HAlzo
Senior

Hello ,

I am migrating code from STM32H7 to STM32F4

I face the following problems with SPI,

1-Hardware output NSS pulses is activated only with HAL_SPI_Init/HAL_SPI_DeInit.

2-There should be a pull up on the NSS in order to reach 3.3V and it can't work with default push-pull configuration.

3-Can't find a mode for pulsated NSS like that in STM32H7

What I meas by pulsated NSS is that the NSS is released after each SPI byte/halfword , automatically in burst transmission and DMA modes.

This way the SPI DMA is almost useless ,because I need to monitor the end of SPI transmission in order to release and reassert NSS manually.

How can I overcome this problem?

3 REPLIES 3

> How can I overcome this problem?

As you found out, the 'F4 does not have the NSS Pulsing feature, this appeared in the STM32 somewhat later than the 'F4.

As a workaround, at the cost of several pins and one or two timers, you can generate NSS framing using timers; the details depend on your application.

JW

HAlzo
Senior

There are two problems in this proposal

1-how to sync timer with DMA

2-in DMA mode without pulsating NSS , the clock is contiues and there's no time between each send byte and the next to pulsate NSS

next picture shows the required behavior as it runs on STM32H743

0693W000004I7xWQAS.png

next picture shows what happen without pulsating NSS

there's no time between bytes to intorduce NSS pulse manually using timer or GPIO

0693W000004I7yyQAC.png

The only solution which I have now is using SW NSS and send SPI data byte by byte -No DMA and no Bursts- but the problems is that it's much s;lower and the overhead on controller as shown in next picture

0693W000004I81dQAC.png

The simplest solution is to feed the SPI Tx from DMA triggered by a channel of the same timer which generates the framing. Care must be taken if there's significant load on the given DMA and related buses.

A more secure but also more complex solution, at the cost of two timers and some pins is, to generate both SCK and framing by the timers, and feed them back to SPI, which is run as a slave.

A mix of these two approaches might be possible, or other solutions too. You have to have a good command of the timers and SPI; this is not something simply clickable in CubeMX.

You may want to have a look and at the TI mode - it's not the same as pulsing between frames, but maybe it fits your slaves' requirements (of which you've told us nothing yet).

Or simply drop the 'F4 and have a look at some other more modern family.

JW