Message Edited by MichaelA on 03-08-200611:31 AM
Thanks CompilerGuru. I was able to alter the code with the tips from your previous post and all is working fairly smoothly now. I guess the flash functions that I was using is for the HCS12 where you can access the paged memory with the logical address (but in the HCS12X, doing it with the global addressing did the trick).
However, now I'm having two other problems with getting this bootloader to work.
One is that I can't seem to program the vector table. It erases just fine, but when the S-Record that defines the values for the vector table, it does not program it as it should (but the other S1 records for local addresses 0xC000 program correctly). Is there something special about the vector table and programming it? Also, when I program using the bootloader, it for some reason secures the device (when I try to reset the controller using the debugger, is gives a message about the device being secured - not sure what I'm doing to make that happen). Note that when I look at the global address 7FFF10'G, it is programmed correctly, but in the local address FF10'L it is not. Is the vector table somehow not linked to the global address space like the rest of the FF page?
The other problem is the actual running of the code. I'm loading a simple program that turns some LEDs on - the program starts at 0xC000 with the Start12.c code from CodeWarrior. The bootloader is programmed at 0x4000, and jumps to 0xC000 once the S-Record file is loaded. However, the startup code runs differently from the bootloader programmed application, and the CodeWarrior loaded application (the LED application works fine when loaded from CodeWarrior, but the code trails off in the Start12.c where it tries to copy initialization data from ROM to RAM when loaded using the S-Records through the bootloader).
Anyway, thanks for the responses.
- Michael
Message Edited by MichaelA on 03-14-200612:43 PM
Hey Daniel,
Thanks for the response. I was able to get it to work by getting rid of that (*address) = 0xFFFF;/* Dummy store to page to be erased */ line. I still don't know what the original purpose of this line was in the application note that I got the code from.
But now I have a problem with programming the paged flash. When the compiler optimizes the following line with its _LOAD_FAR_16 subroutine (where it then goes into a _GET_PAGE_REG subroutine, it seems to mess up the PPAGE register and the program wanders off and crashes. There a way to tell the compiler to not use these subroutines? Here are the lines its using it on:
if(*far_address != 0xFFFF) {return Flash_Not_Erased;}
far_address is an unsigned int *far (address in the form of 0xPPLLLL, PP = page, LLLL = local address, ie 0x8000-0xBFFF).
What's bothersome is that works great when programming a local address, but anything paged, the code wanders off in these compiler subroutines.
- Michael
Message Edited by CompilerGuru on 03-11-200603:22 PM
Also, when stepping through the code in the Flash_Erase_Sector function with the 0xE08000 address, the debugger gives the follow error after executing this line:
(*address) = 0xFFFF;/* Dummy store to page to be erased */
"While in RUN mode, the emulator can only execute the STOP and RESET commands."
After this, the program quits and I have to actually close the debugger to be able to reload another program from CW.