HCS08 SGF Driver Rountines

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

HCS08 SGF Driver Rountines

3,027 Views
FC
Contributor III
I am trying to use the HCS08 SGF flash driver routines, but would like some input to copy the HighVoltage function from flash to ram.  Is there a way to dynamically copy it and save ram when no flash programming is needed?
 
Thanks
Labels (1)
0 Kudos
5 Replies

425 Views
rocco
Senior Contributor II
Hi, FC:

I have done it two ways.

In one application, programming the flash and having the firmware operating was mutually exclusive. So I used equates to overlay my operating data with the flash-programming routines and data. So the flash routines had no ram footprint at all, except when in programming mode.

In another application, I had a page of flash dedicated to operating parameters. These had to be changed occasionally while the firmware was running. For this, I used code from an app-note, which pushed the routine onto the stack, and ran it there. I will try to find that app-note.
0 Kudos

425 Views
FC
Contributor III
Hi Rocco,
 
For basic flash programming, the driver needs only 1 routine in ram and only uses 25 bytes.
Here is what I did:
 
Added a segment in the PRM file for the routine:
SEGMENTS
RAM1                     =  READ_ONLY    0x0100 TO 0x0125;
END
 
PLACEMENT
FLASH_ROUTINES                      INTO  RAM1; 
END
 
Put ORG $100 within the assembly source file for the assembly routine supplied with the driver
ORG   $100
 XDEF HighVoltage
 
Put a #prama in the header of the assembly routine
#pragma CODE_SEG FLASH_ROUTINES
UINT8 HighVoltage (void);
#pragma CODE_SEG DEFAULT
 
The srecord is supplied for the assembly file.  Is there way link the srecord and place it in RAM1 rather than ORG $100? 
 
Thanks
0 Kudos

425 Views
bigmac
Specialist III
Hello FC,
 
It is unclear what you are trying to achieve with the use of the SGF flash driver routines.  I initially suspected you required to store data in flash during normal operation of your firmware program - is this the situation?
 
On this assumption, your program would need to store the high voltage routine in flash, and then provide a simple routine to copy this code to RAM just prior to any data flash programming.  So the S19 file should not use address location 0x0100 (start of RAM1 segment) for the placement of any code, because it is not a flash block, and is volatile.  ORG $100 would only define the start address when the high voltage routine commences execution.
 
   XDEF  HighVoltage  ; Provide label visibility outside current file
   ORG   $100
HighVoltage:          ; Define label

or alternatively,

HighVoltage  equ  $100

Here is a snippet of code for the copy process, where flash location HVcode contains the code to be executed from RAM -

HVcode:
       dc.b             ; Sequence of bytes for HighVoltage routine
; etc.

Copy_code:
       ldhx  #25        ; Number of bytes to copy
loop1: lda   HVcode-1,x
       sta   HighVoltage-1,x
       dbnzx loop1
       rts

Regards,
Mac

 

0 Kudos

425 Views
fleik
Contributor I
Hi,
I'm pretty late on this thread, but I just wanted to place a working project that does it for future reference...
Here's a project for a GB/GT S08, that stores the flash program routines in Flash, but has a copydown in the Start08.c that copies this function into RAM.  It also modifies the PRM so that the debug info for the flash routines are now linked to the RAM location where it was sent to..
the project was built for CW 5.1, but shouldn't be hard to modify it for later versions.
 
hope this helps!
 
Message Edited by t.dowe on 2009-10-27 12:03 PM
0 Kudos

425 Views
rocco
Senior Contributor II

Hi again:

The app-note is old, as it was originally written for the GP32. It copies the high-voltage routines onto the stack, and runs them there. For the GP32, it needs 80 bytes of stack. It will probably be less for the S08 family, due to the embedded state-machine.

http://www.freescale.com/files/microcontrollers/doc/app_note/AN2183.pdf

(Alban formatted link)

Message Edited by Alban on 2006-09-11 01:06 PM

0 Kudos