Flashing Code vs running in RAM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flashing Code vs running in RAM

2,186 Views
PopsStack
Contributor I
I have code which uses most of the pins of the 52223 for GPIO, which I am using to control a graphics controller for an LCD.
 
My code works well running in RAM and the LCD comes alive without a problem. Now that I am going to run some graphics routines I need to run this code in FLASH. I managed ot get a small test routine to run in FLASH, without any changes to the stationery routines such as  mcf5222x_init().
 
In my graphics project I have commented out the Edge Port setup in mcf5222x_init () as I am using some of the IRQ lines as GPIO (IRQ 1, 3, 4, 5). I am only using the TX and RX lines of UART0 so have commented out the setup of the other lines in mcf5222x_uart_init() as the CTS etc are used as GPIO lines.
 
This code compiles and runs perfectly in RAM under Debug mode - BUT when written to the FLASH I get all sorts of problems.
 
The PIT timer works but when my counter indicates a timeout I get:-
 
Access error -- PC = 0x001D36 Attempted to write to write protected space coming out on my monitor.
 
At startup the code does not even get the LCD alive so I am obviously doing something wrong.
 
I am still trying to fathom out the Debugging using FLASH so any help here would be appreciated.
 
Is there something obvious that I am doing wrong with the stationery that is causing it to go tilt when running in FLASH??
 
Kind regards
 
PS
 
 
 
 
Labels (1)
0 Kudos
3 Replies

394 Views
PopsStack
Contributor I
Thanks for the input but I am a little confused. I thought the setup, using hte same.cfg file will do the trick.
 
Using the setup as it in the Debug Settings shows reference to the same .cfg file and when I used a small example to FLASH it worked as it did in RAM. The larger program works in RAM but seems to bomb out in the init section when I ruch it in FLASH.
 
Please forgive my stupidity but how would I include the .cfg at the beginning of my code.
 
Regards
 
PS
0 Kudos

394 Views
Black
Contributor I

When running in stand alone mode without the debugger, the .cfg file is not executed on the target board.

I suggest creating a stationery project for your 52223 evaluation board for an example of board initialization. The stationery project has the minimal setup and code to get your evaluation board up and running.

In this stationery project for the internal flash target of the project please pay special attention to the MCF52223_sysinit.s file. In this file there is the _asm_startmeup section that is the main entry point upon hard reset.  The memory map is setup based on linker file definitions and then the higher level system initialization routine is called. After that it jumps to main. Then in the M52223EVB_sysinit.c file there is the SYSTEM_SysInit routine. Out of reset, the low-level assembly code calls this routine to initialize the MCF52223 modules for the M522223EVB board. So these would be the places to add your board initialization sequence.

I hope this helps. 

0 Kudos

394 Views
Black
Contributor I
The same board initialization that you have in the .cfg file in the project's CF Debugger Settings panel for the RAM target has to be done in the stand-alone version of the project (ROM version), but from within source code. The .cfg file is only executed on the target board at the beginning of a debug session. So please add in your project ROM version source code the initialization from the .cfg file that works.
 
Also please have "Verify Memory Writes" checked in the project's CF Debugger Settings panel for the RAM target to insure that the code is properly downloaded on the board RAM memory.
 
Regards,
Black
0 Kudos