cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX standard config for MasterKeepIOState when SPI Mode 3 and Software NSS

tizdipietro
Associate III

It seems like CubeMX sets this default value 

hspi1.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;

 when doing software NSS and SPI Mode 3 like:

  hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
  hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
  hspi1.Init.NSS = SPI_NSS_SOFT;

 This results in a non working SPI at least on STM32H652 (did not check the signals with Oscilloscope, but I assume the CLK and/or MOSI float back to an undefined value after the first transaction, breaking the next one). This can be fixed by doing:

hspi1.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_ENABLE;

 Wouldn't it be recommended CubeMX defaults the IO_STATE_ENABLE in this case?

 

This one Bit just cost me 5 Hours of headache :\

1 REPLY 1
AScha.3
Super User

>It seems like CubeMX sets this default value 

You seem to be right. :)

But no matter, Cube setting this on or off, i will always be wrong, if someone expects it just the other way.

So setting will always be "wrong" for some users.

 

>This one Bit just cost me 5 Hours of headache :\

Me...nothing, as i always just take a short look at all (!) settings in a peripheral, maybe there are some, i just want in a different setting. This is anyway very recommended, at least to read, what the settings are you "take" .

So i think, nothing to change or improve in Cube settings here.

 

If you feel a post has answered your question, please click "Accept as Solution".