cancel
Showing results for 
Search instead for 
Did you mean: 

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

l-proger
Associate II
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
3 REPLIES 3
l-proger
Associate II
Posted on February 29, 2016 at 15:23

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&currentviews=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 (

Walid FTITI_O
Senior II
Posted on February 29, 2016 at 17:04

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&currentviews=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 (

stm32cube-t
Senior III
Posted on March 22, 2016 at 19:10

Dear user, this is fixed in STM32CubeMX 4.14.