Page 1 of 1

STM32_FLASHBITS Error

Posted: Tue Dec 03, 2013 10:27 am
by alexblack
Hi, sometimes I like to overclock the MCUs and found the errornous settings of STM32_FLASHBITS:

Code: Select all

os/hal/platforms/STM32F4xx/hal_lld.h
...
1617 /**
1618  * @brief   Flash settings.
1619  */
1620 #if (STM32_HCLK <= STM32_0WS_THRESHOLD) || defined(__DOXYGEN__)
1621 #define STM32_FLASHBITS             0x00000000
1622 #elif STM32_HCLK <= STM32_1WS_THRESHOLD
1623 #define STM32_FLASHBITS             0x00000001
1624 #elif STM32_HCLK <= STM32_2WS_THRESHOLD
1625 #define STM32_FLASHBITS             0x00000002
1626 #elif STM32_HCLK <= STM32_3WS_THRESHOLD
1627 #define STM32_FLASHBITS             0x00000003
1628 #elif STM32_HCLK <= STM32_4WS_THRESHOLD
1629 #define STM32_FLASHBITS             0x00000004
1630 #elif STM32_HCLK <= STM32_5WS_THRESHOLD
1631 #define STM32_FLASHBITS             0x00000005
1632 #elif STM32_HCLK <= STM32_6WS_THRESHOLD
1633 #define STM32_FLASHBITS             0x00000006
1634 #elif STM32_HCLK <= STM32_7WS_THRESHOLD
1635 #define STM32_FLASHBITS             0x00000007
1636 #else
1637 #define STM32_FLASHBITS             0x00000008
1638 #endif
...

In line 1637 the value 0x00000008 of STM32_FLASHBITS is out of valid range from 0 to 7. Although in normal situation this value not used but in my case this was the rison the MCU locks!
By the way, STM processors excellent overclocked and has a lot of hidden abilities!

Re: STM32_FLASHBITS Error

Posted: Tue Dec 03, 2013 11:00 am
by Giovanni
Hi,

8-15 wait states are possible on STM32F401/42x/43x devices. That condition should never happen on 40x devices.

Giovanni

Re: STM32_FLASHBITS Error

Posted: Tue Dec 03, 2013 11:10 am
by alexblack
I used STM32F207 and if I used HCLK greater then 120MHz it was happen! Eventually this branch is present for some reason.