Erasing Flash Causes Processor Reset = MC9S08AC128

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

Erasing Flash Causes Processor Reset = MC9S08AC128

2,314 Views
Davo
Contributor II

I'm programming the flash from user code in an MC9S08AC128. Byte programming works OK, but when I page erase the flash the processor resets.  I am using the DoOnStack routines provided by Freescale in the HCS08Family Reference Manual.

 

I first tried using my own routines first before trying the Freescale routines. They also byte programmed well, but also caused the processor to crash on Page Erase.

 

I have used these routines before on other processors (SH8 and QG8), and they worked OK.  I've tried diabling the COP watchdog on the AC128, but this didn't help.

 

Perhaps this is related to the paging feature in the AC128.  I have tried page erasing in Page 0 and 1. 

 

Help appreciated.

 

Any help appreciated.

 

Added p/n to subject.

Message Edited by NLFSJ on 2009-08-25 10:52 AM
Labels (1)
0 Kudos
Reply
5 Replies

642 Views
RSteger
Contributor II

Davo:

 

Here's a list of possible causes on the back of my mind for a hang-up or reset while erasing flash:

 

- COP watchdog (you have already ruled this out)

- Runaway code or illegal operation encountered (Freescale routines probably don't have this problem)

- Stack overflow (is the stack size large enough?)

- The flash array you are erasing is accessed while the erase operation is running. This could be caused by an interrupt.

- Low voltage detect reset, or running the MCU on an out of spec voltage.

 

I hope this helps.

 

Regards,

Ron

0 Kudos
Reply

642 Views
mcs908ac128
Contributor I
I am facing the same problem but I have a little bit more informantion on it. I am running on RAM and after some work I discovered the runaway happens just after reading FSTAT register to check the command end of execution. From the debugger, if I put a break just after reading the register (LDA FSTAT), the first reading of course flags it is not finished, but the second it is Ok and making the program running from that point nothing wrong happens and the flash sector is erased. I thought it was a time delay problem but it does not seem to be because I could not find a reasonable delay to make it work. My point is: Is there anyone who has already REALLY tested this operation on a real component ( I mean a real MC9S08AC128, not other in the 8 bit S family) with successful results??
0 Kudos
Reply

642 Views
kef
Specialist I

mcs908ac128, are you really executing your flash burning code from RAM? Did you verify that CPU program counter (PC) really points to RAM? Also please double check that writing one to FCBEF flag happens when PC already points to RAM.

 

0 Kudos
Reply

642 Views
mcs908ac128
Contributor I

Kef,

 

Yes, I am really running the code from RAM. I am using the procedure to load the code onto stack and them making it run from there. As I said before, putting a break point just after reading FSTAT (LDA FSTAT) everything goes fine (first reading gets 0x00 and running again the next loop gets 0x40 and no runaway happens). If I remove the break and try to execute the same procedure the software runs away. If I try to run this code straight from flash, first reading gets an access error flag (0x10)... Also, in either cases I have observed 1K of flash is erased not 512 bytes as mentioned in the data sheet. I suggest someone to try erasing and programming the flash using the AC DEMOKIT. I am pretty sure the same result will be gotten!!! If not, please just make available the piece of code that really works on MC9S08AC128...

0 Kudos
Reply

642 Views
Davo
Contributor II

I wonder how much experience there is with the AC128.  For example the technical data sheet in section 4.5.1 says that the flash page size is 512 bytes. However section 4.5.3.2.4 says the sector erase operation will erase all addresses in a 1 Kbyte sector of Flash memory. Freescale technical support actually tested this and acknowledged there was a documentation error and that it is 512 bytes. This has not been picked up in more than a year since the datasheet was last released.

 

I have a logged a request with the Freescale Technical Support team. I am waiting for them to verify that their test code runs on an AC128.

0 Kudos
Reply