AnsweredAssumed Answered

cubemx 4.13.0 STM32F4 what's wrong with SPI RX DMA?

Question asked by serb.sergey on Feb 29, 2016
Latest reply on Mar 22, 2016 by STM32Cube-T
Hello!

After upgrading to latest version of cubemx (to 4.13.0) and updating HAL library to v1.11.0 my SPI code is broken in strage way - NSS pin state is igneored!

My test setup:
STM32F429VGT6 168 MHz core clock,
SPI2 Receive only slave, Hardware NSS,
NSS pin is always with "High level" (logical 1) so SPI slave should Never receive anything! Initialization code is generated with CubeMX 4.13.0.

128 bytes buffer is allocated  globally
__ALIGN_BEGIN uint8_t buffer[128] __ALIGN_END;

Then after all peripherials initialization I fill that buffer with test values
std::fill(std::begin(buffer), std::end(buffer), 0x77);

And here is the bug
HAL_SPI_Receive_DMA(&hspi2, &buffer[0], sizeof(buffer));
 
for(;;){} //infinite loop

I never change the condition of SPI NSS pin, it's always has value 1 and DMA should not receive anything! But it is receiving 128 zero bytes!!! Why?? (I can pause execution and look at buffer values, they are rewritten with zeroes + DMA conversion complete callback is called!).  It is looks like NSS pin is in software mode, but i checked it for 100500 times in CubeMX and in generated code - it is configured exactly as hardware input pin!

If i disconnect SCK pin then nothing is received, buffer is not overwritten. 

So it looks like NSS hardware mode is ignored. How can i fix it?

Outcomes