Firstly - My application has been working for some time and my sample code is also working, but they will not work together. I believe that I have too many variables to co-reside withe the "code in RAM" and the need for a bigger stack so I have come up with two solutions and I would appreciate your opinion. They are based on the premise that the only volatile variable is the one that I am saving in ROM.
1.1 when I need to save a value, call FlashInit() and CopyToRam(), disable the Interrupts and call FlashCmd(). Add a while(1); (wait here forever) and wait for the watchdog to issue a reset. All variables will be re- initialised and the variable saved in ROM will be read out (this happens already).
1.2 Exactly the same as above, except that two instructions are added to FlashCmd() - Enable interrupts and a Software interrupt (SWI) and the SWI will do a jump to the address stored in the RESET vector.
I believe either solution will work, but the second on appears the best.
My second point is really not for you directly and I shall post a more detailed entry in the USBDM forum.
I have been re-designing an new processor into four products (all with 50% of the code being common) that would require approximately 50 000 pieces P/A. I started with a DEMOQE board and then moved to a S08SH4 - based target hardware board with a USBDM. Initially the DEMOQE board worked and I completed the preliminary software design. The two USBDMs (one JS16 and one JM60.) the JS worked most of the time and the JM worked occasionally. I would typically re-load the drivers 4 or 5 times before anything would work. Currently the DEMOQE and the JS16 are not "seen" and the JM60 works with USBDM 4.12, but not with CodeWarrior. In Debug Settings > Connection Type my choices are - GDI Generic, P&E HCS08 FCS, or USB Multilink (none of which I have). If I select P&E HCS08 the debug session starts, but the program loops continuously on a single instruction in the initialisation sequence.
I don't wish to bore you with masses of detail (I will keep that for the other forum), but if I cannot even debug my code I may need to consider another processor. I am just going around and around in circles.