2016-02-29 05:46 AM
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
2016-02-29 06:23 AM
Ok, I found source of bug in discussion [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/%5bbug%5d%20GPIO%20setting%20for%20SPIx_NSS%20pin&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&TopicsView=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx¤tviews=25][bug] GPIO setting for SPIx_NSS pin ST should test it's releases better before shipping them to users. This is too fat bug (
2016-02-29 08:04 AM
Hi serb.sergey,
Thank you for your feedback and contribution. I will report this to our CubeMX team for checking.-Hannibal-
Ok, I found source of bug in discussion [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/%5bbug%5d%20GPIO%20setting%20for%20SPIx_NSS%20pin&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&TopicsView=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx¤tviews=25][bug] GPIO setting for SPIx_NSS pin ST should test it's releases better before shipping them to users. This is too fat bug (
2016-03-22 11:10 AM
Dear user, this is fixed in STM32CubeMX 4.14.