Unable to erase flash HC08

I am unable to erase flash pages on an HC08QT4. I follow the application note on the topic, AN2346, by having the flash program copy itself to RAM and run from there.

The chip is running mono8 and Metrowerks is the IDE. The erase gets lost on the 'write to any address in the flash page' part of the erase routine, which is coded as 'sta ,x'. Seems simple enough, but doesn't work. Metrowerks shows an error message of 'unable to go into background mode' instead of 'stepped' when I single step though. Just running it sends it off into the weeds (doesn't recover) and going back after reset shows the flash was not erased.

I also tried using a store A to an address, skipping the instruction, stepping through, running the code without the IDE then going back to check. I am stuck. Read everything I could find, no help.

There is an erase routine in ROM but I have the chipset with the error that erases your reset vector if the ROM routine is called. Plan A was to code my own flash erase routine following the application notes. Plan B is get help from this group. Plan C is buy a new board without the chipset error and call a correct ROM routine. I just hate spending money though, especially when it's my own money.

I am able to write to flash calling the ROM routine. Stepping through sends the processor into the weeds again, but the flash is programmed.

I disable interrupts on the calling of the RAM routine, I could try leaving interrupts enabled but that's probably not a good idea. The mono8 uses SWI's so maybe the interrupt disable is preventing it from working correctly, but running without the mono8/IDE should have worked correctly.

Any ideas???

Reply to
js1180
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.