2020-02-10 08:38 AM
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.
2020-02-14 12:53 PM
CubeMX generating incorrect code was the problem. Basically the SDCR was incorrectly generated. Fixing all this I no longer need to call HAL code which is not initialised: ie set the clock before ExtMem and call MX_FMC_Init after it.
Apart from the incorrect code generated there are these issues:
(a) no code to initialise both banks of SD
(b) startup_ not in the file in a way that allows edit of the SP and HEAP and regeneration of code
(c) again, user edit and regen is not accomodated for the System_ file
(d) import of an existing IOC does not work (yes, I can import but gen code and regen then does not work as it should)
(e) working with CubeMX with Middleware and other parts from Keil is a real, true, 100% pain