Question
cubemx 4.13.0 STM32F4 what's wrong with SPI RX DMA?
Posted on February 29, 2016 at 14:46
Hello!
After upgrading to latest version of cubemx (to 4.0) and updating HAL library to v1.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.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 notreceive
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?
#!stm32-!cubemx-!spi-!bug