Can code be executed while programming flash in AW60?

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

Can code be executed while programming flash in AW60?

Jump to solution
2,911 Views
rollingstone
Contributor I

Hi,

 

I'm using MC9S08AW60, trying to use emulated EEPROM, but i'm wondering when programming or erasing flash memory, can the code be executed at the same time?

 

I found in AN3822 says:

"The MC9S08LG32/16 is a Freescale 8-bit microcontroller that contains two flash arrays. Program and erase operations can be conducted on one array while executing code from the other."

 

Does it mean if only one flash array exists, program and executing code can't be at the same time?

 

And can anyone tell me how many flash arrays is there in AW60?

 

Thanks!!

Labels (1)
0 Kudos
Reply
1 Solution
1,019 Views
kef
Specialist I
rollingstone , it is not possible to start flash command and immediately halt CPU until flash comman is done. CPU will keep running. And since flash memory is going to disappear for a while, CPU will read broken code/instructions and go into the weeds.

View solution in original post

0 Kudos
Reply
8 Replies
1,019 Views
kef
Specialist I
Flash memory is not readable while any flash command is in progress, also while FCNFG KEYACC bit is set. Not readable means processor can't execute code, read data, also can't fetch interrupt vectors. Before starting any flash command (clearing FCBEF bit) or setting KEYACC bit, you should disable interrupts and jump to and stay in RAM (or EEPROM, or second flash array, or any other readable memory) while FCCF is cleared and while KEYACC is set.
0 Kudos
Reply
1,019 Views
rollingstone
Contributor I

 

Hi Kef,

 

 Thanks for your reply!

 

So, is there another flash array in AW60? I can't find any description about it in the datasheet.

 

And how to "Stay in RAM"? 

 

Is it the case  that after lauch command through FCBEF, the processor just hang up there and resume to execute after command completion?

 

Thanks!

0 Kudos
Reply
1,019 Views
kef
Specialist I

Processor hangs because it can't read code memory. "Stay in RAM" means execute code from RAM. CPU program counter always should point to readable memory. And flash is not readable while flash command is in progress.

Don't know how many flash arrays AW60 has. It is simplier to use small portion of RAM to hold small routine that writes one to FCBEF flag and waits until FCCF. It is the same for all (or almost all) FSL MCUs and doesn't depend on how many arrays etc.

0 Kudos
Reply
1,019 Views
rollingstone
Contributor I

Hi Kef,

 

Is it necessary to place code into RAM? I mean if not, just let the processor hang at the place of launch flash command, after the command completed and flash is readable again, the processor will continue to execute.

 

If we put code into RAM, flash operation just run as a background command, but we can't jump anywhere else or service interrupts, am i right?

So usually what should we do in this code? Just wait FCCF to be set or do something else like feeding watchdog?

 

Thanks!

0 Kudos
Reply
1,019 Views
peg
Senior Contributor IV

Hello,

 

Yes you need to place some code in ram which will also actually DO the programming and wait. Then it would normally jump back into flash and continue.

You cannot just let it hang and then recover!

 

0 Kudos
Reply
1,019 Views
rollingstone
Contributor I

Hi Peg,

 

Would you explain why can't we let it hang and recover?  What will happen if we do that way?

 

 

Thanks!

0 Kudos
Reply
1,020 Views
kef
Specialist I
rollingstone , it is not possible to start flash command and immediately halt CPU until flash comman is done. CPU will keep running. And since flash memory is going to disappear for a while, CPU will read broken code/instructions and go into the weeds.
0 Kudos
Reply
1,019 Views
rollingstone
Contributor I

 

Hi Kef,

 

Thanks for your infomation, it's helpful!

 

 

 Regards,

 

0 Kudos
Reply