Code: |
void InitFlash(void){ FSTAT_FACCERR=1; FSTAT_FPVIOL=1; FCDIV = 39; } |
Code: |
void Flash_Byte_Write(byte Dato,unsigned int Address){ //write to flash unsigned int tmp = 0; byte * ADD; ADD = (byte *)Address; //se c'è un errore cancello l'errore FSTAT_FACCERR=1; FSTAT_FPVIOL=1; //carico il dato nel buffer della flash * ADD = Dato; //mando il comando di programmazione byte singolo FCMD = 0x20; //lancio il comando FSTAT_FCBEF = 1; while(!FSTAT_FCCF){ } } |
Posted: Tue May 17, 2005 6:06 am
The init clock is created by Codewarrior....
/****************/
SOPT = 2;
SPMSC1 = 28;
SPMSC2 = 0;
ICGC1 = 60;
ICGC2 = 81;
ICGTRM = 128;
while(!ICGS1_LOCK);
/****************/
I check the instruction and is all ok.
Posted: Tue May 17, 2005 7:57 am
OK, It's Right,
I use the stack for execute the function
that write-erase flash and it's ok.
Posted: Tue May 17, 2005 11:55 am
Hi,
Code: |
ICGC1 = 60; ICGC2 = 81; |
means that you get low speed speed (range=P=64), Multiplier of 14 (MFD=101) and divider of 2 (RFD=001). Therefore bus frequency is:
datasheet wrote: |
fext * P * N / R |
You get, from a 36kHz osc => 16.128MHz
I don't see how you get 7MHz bus.
Also
Code: |
ICGTRM = 128; |
looks like a default value and that the internal oscillator is not really trimed.
What am I missing ?
Cheers,
Posted: Tue May 17, 2005 12:52 pm
Yes, but the crystal is 32768 Hz and then
the FBus is FCLK /2, where
FCLK = P *N/R *FCRYSTAL
using P=64 N=14, R=2
so the FBus = 7340032 Hz
Page 109 of datasheet GT60 and example 7.4.2 page 112
Posted: Tue May 17, 2005 1:17 pm
Oki, I get it. Coz my 16...MHz divided by two were far from 7MHz.
But the reference was different!
And about the trim? Are you sure you stay within specified time for Flash timing. Anyway, even slightly out, it should not be an issue.
Posted: Tue May 17, 2005 1:21 pm
It's not important,
you can cut the line TRIM=128,
it's only because i have make cut and paste from
another project and i forgot to eliminate the line
Posted: Wed May 18, 2005 8:40 am
Thanks for the input. Could you please give me an example of executing the commands from the stack.
Posted: Wed May 18, 2005 9:18 am
OK,
You Can Download from freescale the Software
AN2295SW.zip of the application AN2295
It's the Bootloader for the GT family.
If You search inside zip, You will find the file
slfprg-s08gbgt.asm
in this file you can cut and paste the function ERASE_COM and WR_DATA_COM, cut the part of the serial port.
Use this functions and call from another asm routine or c function.
Ok ?
Posted: Thu May 19, 2005 8:16 am
you are a champ. Many thanks
Posted: Tue Sep 20, 2005 6:59 pm
any other guru:
I am pretty new to f/w programming and not really familiar with assembly language
I have been trying max's solution of using code from slfprg-s08gbgt.asm for quite some time now.
Could anyone please print out the exact(independent) assembly code that should be included and code in C calling those assembly functions?
I have trying to pass arguments to assembly functions without much success
Thanks
Message Edited by RChapman on 01-24-2006 02:24 PM