AnsweredAssumed Answered

CubeMx STM32F4 1.11 SPI critical bug introduced in codegenerator

Question asked by adib on Feb 13, 2016
Latest reply on Apr 12, 2016 by STM32Cube-T
Hello,

in the new CubeMx STM32F4 1.11 library there is a new bug introduced.
There is this new feature:
Add new define USE_SPI_CRC for code cleanup when the CRC calculation is disabled.

The codegenerator generates (if CRC is disabled) in file stm32f4_hal_conf.h
#define USE_SPI_CRC                     0U

And the library checks against:
#ifdef USE_SPI_CRC

The problem is that even the USE_SPI_CRC is defined to ZERO, it IS DEFINED.
So that the preprocessor ALWAYS handle #ifdef USE_SPI_CRC as defined.


I see here two solutions:
1) do not define USE_SPI_CRC at all in this case CRC is not used, i.e. comment out the line
2) for testing if the feature should be used rewrite the test to: #if USE_SPI_CRC

I think the 2) is the more robust. (You should not #undef )
1) AND 2) is I thing more optimal.

For now I undef the generated code always after every generation :-(

regards, Adib.





Outcomes