Flash Programming example on MC9S08GB60

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

Flash Programming example on MC9S08GB60

6,493 Views
henryTwinB
Contributor I
Hello guys,

i got an MC13213SRB which have a MC9S08GB60 MCU core.

i got a job to work with run time programming the flash memory to store some user data.

Could any body suggest a documents or some sample code to do so?

thanks guy!
Labels (1)
0 Kudos
8 Replies

565 Views
henryTwinB
Contributor I
Hey man,

I ve got the flash program byte working during single step operation but it seems that it loops forever when i step-over it or just let the program run at the instant i called the flash program byte routine.

Any idea?

sorry i am referring to the HCS08SGFNVMSSD SGF driver
0 Kudos

565 Views
henryTwinB
Contributor I
Thx guys!!

didnt we have a simple C library to did it?

by the way, let me try than.
0 Kudos

565 Views
J2MEJediMaster
Specialist I
There is an application note that covers flash programming for the MC68HC912BC32. The source code is in assembly, however. Search for AN1828 in the Freescale docs section. I've seen some C code in the forums for flash programming that was posted by an enterprising soul, but it's GT8-specific.

---Tom
0 Kudos

565 Views
Alban
Senior Contributor II

Hi Tom,

HC12 and S08 do not share the same Flash technology and codes are strictly incompatible.

Freescale external web provides Flash drivers for all HC08/S12.
For instance on the S08GB60, you can go to

HCS08SGFNVMSSD
Standard Software Driver for HCS08 SGF Flash
Program/erase software driver for SGF NVM (flash and EEPROM) in HCS08.

It is accessible from the product page.

Alban.

0 Kudos

565 Views
henryTwinB
Contributor I
thanks Alban,
seems the HCS08SGFNVMSSD is great,
i have downloaded it but it didnt include any documents
how can i work with it?

Henry
0 Kudos

565 Views
RockyRoad
Contributor III

Henry -

After you run the installer, the user's manual is in the program directory. On my computer (using the defaults during install) it's in:

C:\Program Files\Motorola SPS\Standard Software SGF Driver v3.0\HCS08

and the file is: UM_HCS08_SGF_SSD.pdf

- Rocky

Message Edited by RockyRoad on 2006-08-23 09:55 AM

0 Kudos

565 Views
glork
Contributor I
Hi henry@twinberries.
Below is a routine for erasing a page of flash or for writing a single byte. My start-up routine copies this from flash to ram.

2561 2561 PROGFLASH:
2562 2562 ; write the command
2563 2563 a00894F C7 1826 sta fcmd
2564 2564 a008952 A6 80 lda #$80
2565 2565 a008954 C7 1825 sta fstat
2566 2566 a008957 9D nop
2567 2567 a008958 9D nop
2568 2568 a008959 9D nop
2569 2569 a00895A 9D nop
2570 2570 a00895B 9D nop
2571 2571 a00895C 9D nop
2572 2572 WFLOOP:
2573 2573 a00895D C6 1825 lda fstat
2574 2574 a008960 A4 30 and #$30
2575 2575 a008962 27 03 beq wfbt1
2576 2576 a008964 CC 8000 jmp cold
2577 2577 WFBT1:
2578 2578 a008967 C6 1825 lda fstat
2579 2579 a00896A 48 lsla
2580 2580 a00896B 2A F0 bpl wfloop
2581 2581 a00896D 4F clra
2582 2582 a00896E 81 rts

Then, while running in flash, if I want to save something to flash I call this routine:

2488 2488 ;**************** SAVEFLASH ****************
2489 2489 ; Save (filterontime) into flash. *
2490 2490 ;*******************************************
2491 2491 ;
2492 2492 SAVEFLASH:
2493 2493 ; disable irqs for now
2494 2494 a0088E8 9B sei
2495 2495 ; check for errors
2496 2496 a0088E9 C6 1825 lda fstat
2497 2497 a0088EC A4 30 and #$30
2498 2498 a0088EE 27 05 beq asfbt1
2499 2499 ; had error(s), try to clr
2500 2500 a0088F0 A6 30 lda #$30
2501 2501 a0088F2 C7 1825 sta fstat
2502 2502 ; then we have to erase
2503 2503 ; our flash buffer @ $d000
2504 2504 ; min erase is 512 bytes
2505 2505 ;
2506 2506 ASFBT1:
2507 2507 a0088F5 C7 D003 sta flashbuf+3 ; any data
2508 2508 a0088F8 A6 40 lda #$40 ; page erase
2509 2509 a0088FA CD 0300 jsr progflash
2510 2510 ; then write the marker
2511 2511 a0088FD A6 A5 lda #$a5
2512 2512 a0088FF C7 D000 sta flashbuf
2513 2513 a008902 A6 20 lda #$20 ; write byte
2514 2514 a008904 CD 0300 jsr progflash
and so on....

This represents a working routine.
BE SURE YOU GET THE FLASH-CLOCK SET UP CORRECTLY.
ron
0 Kudos

565 Views
peg
Senior Contributor IV

Hi Henry,

Do a search on this forum (down the bottom)

This subject has been done to death here, I am sure you will find all you need and then some!

Regards David

 

0 Kudos