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
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.
Thanks for the help.
I wasn't aware I could download the Keil family packs so last night I found newer versions of system_stm32f427x.c on GitHub.
That got me past the hard fault and now the SDRAM is working for the first 8MB of 16MB available (accessing the top 8MB causes a hard fault) but I can also see occasional read errors when viewing the RAM contents under debug. The Github FMC setup is quite a bit different to the latest Keil family pack probably due to different SDRAMs used on different eval boards.
I should now have enough to work with and I can tailor the code to suit my SDRAM.
Thanks again for your help.