Reprogramming/ Erasing flash while running code from it on HCS12!

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

Reprogramming/ Erasing flash while running code from it on HCS12!

3,087 Views
raghav_sarma
Contributor I
Hallo everyone,
 
Is it possible to write to / erase Flash memory while running code from Flash at the same time? Do you have to make sure that the Flash memory being erased /reprogrammed ids on a different block / page?
 
Cheers,
Raghav
0 Kudos
Reply
4 Replies

1,345 Views
mke_et
Contributor IV
There are actually multiple issues...

One is that the 'bank' you are programming will 'disappear' when you try to program anything else in the same bank. That means that yes, you can program a different bank that what you are executing in. But that brings up another issue...

If you have your top page at C000 in real space, and the next page at 4000, where do your put the next page? At 8000. So, you can put a lower page with programming code at 8000 and you 'could' get at the top two pages from the other bank, but how do get to other pages and keep your code visible somewhere to execute from?

And then there's the issue of interrupts... Gotta remember where all your vectors are gonna go while that entire bank is invisible...

The easiest way to do this is to get your routines working from one page to a page in another bank, then transfer them to RAM and modify them so they work 'anywhere'...

Unless you have a specific configuration you plan on using and ONLY that configuration. Which is not a bad thing. In my case, for my interactive stuff, I made my program call routines that sat at 4000 and 'switched in' the target page at 8000 to do any writes and/or management of my flash. I just picked the pages I used so that they wouldn't collide and would abide by the rules above.

Mike
0 Kudos
Reply

1,345 Views
Lundin
Senior Contributor IV
It isn't possible unless the code is running from another bank, meaning that you'd need a S12 with more than 64k memory, since one flash bank equals 64k.

I also think I read somewhere that the C and GC families doesn't come with more than 1 bank (correct me if I'm wrong) even if you pick a mcu with lets say 96k flash. If that's true you'd need to pick one of the older families as well.
0 Kudos
Reply

1,345 Views
raghav_sarma
Contributor I

Thanks Lundin,

I'm using the MC9S12DT128 - it has 128 k flash. The documentation says that it has two 64 k  blocks.

How can I define / assign memory regions in the 2nd block of flash? I'd like to define a memory region in the second block like this in the prm file.

ROM_CALS = READ_ONLY  0xF200 TO 0xFEFF; /* in block 2 */

/*because the program is in block 1(default)*/

Cheers,

Raghav

 

 

Message Edited by raghav_sarma on 2006-12-1901:55 PM

0 Kudos
Reply

1,345 Views
Lundin
Senior Contributor IV
Yep, it is possible to do it on DT128, I've done that myself. You must place code / const data in paged memory in order to use the second bank.

On DT128, the pages are as follows:

Bank 0:
Non-paged flash 4000-7FFF and C000-FFFF.
Pages 3C, 3D

Bank 1:
Pages 38, 39, 3A, 3B
0 Kudos
Reply