STM32F429 CubeMX Generated Project with DATA_IN_ExtSDRAM HardFault
- February 10, 2020
- 1 reply
- 1535 views
Hi
(edit: added working project - search FINDME to see notes on changes to get it working)
I have a project which works (and has been working for a year) but to get it working I had to work out an initialisation sequence that worked. I'm trying to tidy up and decided to start with a clean CubeMX project.
CubeMX and relevant schematic pages attached.
Problem is I need to SystemInit the SDRAM so that the project statics can go in there as they are too large for the on-chip RAM. To achieve this I use DATA_IN_ExtSDRAM (set as a Keil define) and, in Keil, enabled RAM1 as default (0xC100 0000 size 0x300 0000). I do not check NoInit. I edit the startup to move the stack to onchip to avoid Keil moving it to RAM1.
I find that the generated code causes Hard Fault when branching to _main
Anyone have any idea why? It is a pretty basic example. Am I missing a setting in Cube?
I can fix the problem by initialising the clock before SystemInit_ExtMemCtl (). However, I do this by calling SystemClock_Config() as it is the only code provided: this uses HAL code and HAL code is not yet initialised so it is a worry and I will need to write my own routine (but why?).
It just all seems "wrong": CubeMX should be generating working code so I wonder if I am missing some setting?
Other, CubeMX code does not create code to initialise both my SDRAM, only the first bank (eg FMC_Bank5_6->SDCR[0] and not FMC_Bank5_6->SDCR[1], too).
Other, startup is CubeMX code and I lose my edits every time.
Thanks
Mark
p.s. ignore the VDDA not tied to VDD issue if you notice it.... mod on PCBA for that.
