Skip to main content
Associate II
December 13, 2023
Solved

B-G431B-ESC1 HardFault with MCW generated code

  • December 13, 2023
  • 2 replies
  • 1379 views

I generated some code with the default "Electronic speed control on B-G431B-ESC1 kit" project in Motor Control WorkBench.  Then when I flash the default code I get a HardFault when calling `__HAL_FLASH_PREFETCH_BUFFER_ENABLE()` in  `HAL_Init()`:

int main(void)
{
 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();

...

HAL_StatusTypeDef HAL_Init(void)...

#if (PREFETCH_ENABLE != 0U)
 __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
#endif /* PREFETCH_ENABLE */

MC Workbench v6.2

CubeMX version 6.9.2

CubeIDE version 1.14.0

 

    This topic has been closed for replies.
    Best answer by GMA

    Hello,

    I was able to pass the HAL_init step on "ElectronicSpeedControl_ESC-G4" example with MC Workbench v6.2, CubeMX version 6.9.2, CubeIDE version 1.14.0, (Firmware Package Version STM32 FW V1.5.1) and Drive Type LL or HAL.

    Could you please check that via IDE you have access to FLASH registers as below?

    GMA_0-1702476811235.png

     

    2 replies

    GMA
    GMABest answer
    Technical Moderator
    December 13, 2023

    Hello,

    I was able to pass the HAL_init step on "ElectronicSpeedControl_ESC-G4" example with MC Workbench v6.2, CubeMX version 6.9.2, CubeIDE version 1.14.0, (Firmware Package Version STM32 FW V1.5.1) and Drive Type LL or HAL.

    Could you please check that via IDE you have access to FLASH registers as below?

    GMA_0-1702476811235.png

     

    If you agree with the answer, please accept it by clicking on 'Accept as solution'.Best regards.GMA
    Associate II
    December 13, 2023

    I tried regenerating the project and was able to pass this init step without hardfault.  The only other thing I did was update STLink.  Not sure why the problem went away but thank you.

    GMA
    Technical Moderator
    December 14, 2023

    Hello,

    Thank you for your feedback!

    If you agree with the answer, please accept it by clicking on 'Accept as solution'.Best regards.GMA