This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Hard fault in SystemInit_ExtMemCtl()

Hi

I hope someone here can help guide me.

I'm using a custom designed board which uses the same SDRAM memory configuration as the ST32429I-EVAL board.

In the Keil file system_stm32f427x.c I have uncommented

#define DATA_IN_ExtSRAM


so that the procedure SystemInit_ExtMemCtl() is called.

The very first line of this procedure is

/* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
RCC->AHB1ENR   = 0x00000078;

This line causes a hard fault after jumping back to system_stm32f427x.s and then trying to jump to __main.
If I comment that line out then the code jumps to __main with no problems.

The strange thing is, if I add a breakpoint to the line right after

// RCC->AHB1ENR   = 0x00000078;


and then change the RCC->AHB1ENR register manually so GPIOD, GPIOE, GPIOF and GPIOG interface clocks are enabled the code runs fine into __main.

Even though the code now runs I haven't got the external RAM to work yet so this may be part of a bigger problem or a configuration problem.

I'm using an old version of uVision V4.71.2.0 so does anyone know if there were bugs in the Keil provided system_stm32f427x.s and system_stm32f427x.c files?

Any help would be appreciated.

Thanks

Parents
  • It seems that you have quite an old system file for STM32F4 series.

    Latest system file from STM32F4 Device Family pack V2.13.0 (http://www.keil.com/dd2/pack/) has an updated SystemInit_ExtMemCtl() function.

    The RCC AHB1 clock register needs to be or-ed (not just overwritten).

    /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
    RCC->AHB1ENR |= 0x00000078;
    

    That should behave similar as when you have manually enabled the clocks in the register.

    I suggest you use the updated system file since it might solve also other potential issues.

Reply
  • It seems that you have quite an old system file for STM32F4 series.

    Latest system file from STM32F4 Device Family pack V2.13.0 (http://www.keil.com/dd2/pack/) has an updated SystemInit_ExtMemCtl() function.

    The RCC AHB1 clock register needs to be or-ed (not just overwritten).

    /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
    RCC->AHB1ENR |= 0x00000078;
    

    That should behave similar as when you have manually enabled the clocks in the register.

    I suggest you use the updated system file since it might solve also other potential issues.

Children