Reply by eric_cina July 6, 20052005-07-06
Thanks Gilles. I modified the script you sent me and it works great.

If there are any new manuals, completed or not, I would be happy to
get a hold of them.

Thanks again.

Regards,
Eric
--- In 68HC12@68HC..., Gilles Blanquin
<gilles.blanquin@f...> wrote:
> Hi Eric.
>
> CodeWarrior for HC(S)12 does not provide a sector granularity for
flash
> erasing. Currently only blocks or entire flash can be erased.
> Also the Flash Programmer will overwrite all protections to get a
full
> access and will eventually erase the entire part.
>
> However, please find here below a script example that you can
adapt to
> erase the sectors you want.
>
> The "erasesectors.cmd" script example here below erases sector in
ppage
> $3E, except the last one. Create the file, adapt it to what you
want to
> erase, and store it in the same folder as your project.
>
> Then change the script you have in the Preload cmd file:
>
> // reset the device to get default settings
> RESET
>
> // call the command file to erase desired sectors
> cf erasesectors.cmd
>
> // initialize flash programming process
> FLASH
>
> // select the flash modules
> FLASH SELECT
>
> // erase the flash modules
> // >>> erasing is already done by erasesectors.cmd file >>> FLASH
ERASE
>
> // arm the flash for programming
> FLASH ARM >
>
> //***** BEGIN: erasesectors.cmd file ***************
>
> // Evaluate the clock divider to set in ECLKDIV/FCLKDIV registers:
>
> // An average programming clock of 175 kHz is chosen.
>
> // If the oscillator frequency is less than 10 MHz, the value to
store
> // in ECLKDIV/FCLKDIV is equal to " oscillator frequency (kHz) /
175 ".
>
> // If the oscillator frequency is higher than 10 MHz, the value to
store
> // in ECLKDIV/FCLKDIV is equal to " oscillator frequency (kHz) /
1400 +
> 0x40 (to set PRDIV8 flag)".
>
> // Datasheet proposed values:
> //
> // oscillator frequency ECLKDIV/FCLKDIV value (hexadecimal)
> //
> // 16 MHz $49
> // 8 MHz $27
> // 4 MHz $13
> // 2 MHz $9
> // 1 MHz $4
>
> define CLKDIV 0x49
> define iblock 0
> define asector 0x8000
>
> bankwindow ppage off // (backward compatibility)
>
> FLASH MEMUNMAP // do not interact with Flash Programmer
>
> wb 0x100 CLKDIV
>
> for asector=0x8000..0xAE00,0x200
>
> wb 0x103 0 // Set Block Pointer bits to block 0
> wb 0x105 0x30 // clear PVIOL and ACCERR in FSTAT register
> wb 0x30 0x3E // Set Page Register (here PPAGE $3E)
> wb 0x102 0x00 // clear FTSTMOD
> wb 0x104 0xFF // Disable Protection
> wb 0x105 0x30 // clear PVIOL and ACCERR in FSTAT register
> ww asector 0 // Write to Flash to set address, data
> wb 0x106 0x40 // write SECTOR ERASE in FCMD reg
> wb 0x105 0x80 // clear CBEIF in FSTAT to execute command
> wait 1 // wait for 100 ms - wait for command to
complete
>
> endfor
>
> FLASH MEMMAP // restore Flash Programmer monitor
>
> bankwindow ppage on (backward compatibility) > //***** END: erasesectors.cmd file *************** > Regards,
> Gilles > At 03:00 AM 7/6/2005, you wrote:
> >I am using CodeWarrior and a USB BDM to flash my code. I have a
> >preload command script which wipes out the entire flash before the
> >BDM performs the loading. The command script has the following:
> >
> > // reset the device to get default settings
> > RESET
> > // initialize flash programming process
> > FLASH
> > // select the flash modules
> > FLASH SELECT
> > // erase the flash modules
> > FLASH ERASE
> > // arm the flash for programming
> > FLASH ARM
> >
> >How can I modify this script to erase only a certain portion of
> >flash, like up until address 0xF000? Should I just protect that
> >flash section so it is not erased or should I modify this script
> >somehow?
> >
> >Thanks in advance for the help.
> >
> >Regards,
> >Eric
> >
> >
> >
> >
> >
> >Yahoo! Groups Links
> >
> >
> >
> >


Reply by Gilles Blanquin July 6, 20052005-07-06
Hi Eric.

CodeWarrior for HC(S)12 does not provide a sector granularity for flash
erasing. Currently only blocks or entire flash can be erased.
Also the Flash Programmer will overwrite all protections to get a full
access and will eventually erase the entire part.

However, please find here below a script example that you can adapt to
erase the sectors you want.

The "erasesectors.cmd" script example here below erases sector in ppage
$3E, except the last one. Create the file, adapt it to what you want to
erase, and store it in the same folder as your project.

Then change the script you have in the Preload cmd file:

// reset the device to get default settings
RESET

// call the command file to erase desired sectors
cf erasesectors.cmd

// initialize flash programming process
FLASH

// select the flash modules
FLASH SELECT

// erase the flash modules
// >>> erasing is already done by erasesectors.cmd file >>> FLASH ERASE

// arm the flash for programming
FLASH ARM

//***** BEGIN: erasesectors.cmd file ***************

// Evaluate the clock divider to set in ECLKDIV/FCLKDIV registers:

// An average programming clock of 175 kHz is chosen.

// If the oscillator frequency is less than 10 MHz, the value to store
// in ECLKDIV/FCLKDIV is equal to " oscillator frequency (kHz) / 175 ".

// If the oscillator frequency is higher than 10 MHz, the value to store
// in ECLKDIV/FCLKDIV is equal to " oscillator frequency (kHz) / 1400 +
0x40 (to set PRDIV8 flag)".

// Datasheet proposed values:
//
// oscillator frequency ECLKDIV/FCLKDIV value (hexadecimal)
//
// 16 MHz $49
// 8 MHz $27
// 4 MHz $13
// 2 MHz $9
// 1 MHz $4

define CLKDIV 0x49
define iblock 0
define asector 0x8000

bankwindow ppage off // (backward compatibility)

FLASH MEMUNMAP // do not interact with Flash Programmer

wb 0x100 CLKDIV

for asector=0x8000..0xAE00,0x200

wb 0x103 0 // Set Block Pointer bits to block 0
wb 0x105 0x30 // clear PVIOL and ACCERR in FSTAT register
wb 0x30 0x3E // Set Page Register (here PPAGE $3E)
wb 0x102 0x00 // clear FTSTMOD
wb 0x104 0xFF // Disable Protection
wb 0x105 0x30 // clear PVIOL and ACCERR in FSTAT register
ww asector 0 // Write to Flash to set address, data
wb 0x106 0x40 // write SECTOR ERASE in FCMD reg
wb 0x105 0x80 // clear CBEIF in FSTAT to execute command
wait 1 // wait for 100 ms - wait for command to complete

endfor

FLASH MEMMAP // restore Flash Programmer monitor

bankwindow ppage on (backward compatibility) //***** END: erasesectors.cmd file *************** Regards,
Gilles At 03:00 AM 7/6/2005, you wrote:
>I am using CodeWarrior and a USB BDM to flash my code. I have a
>preload command script which wipes out the entire flash before the
>BDM performs the loading. The command script has the following:
>
> // reset the device to get default settings
> RESET
> // initialize flash programming process
> FLASH
> // select the flash modules
> FLASH SELECT
> // erase the flash modules
> FLASH ERASE
> // arm the flash for programming
> FLASH ARM
>
>How can I modify this script to erase only a certain portion of
>flash, like up until address 0xF000? Should I just protect that
>flash section so it is not erased or should I modify this script
>somehow?
>
>Thanks in advance for the help.
>
>Regards,
>Eric >Yahoo! Groups Links >
>




Reply by eric_cina July 5, 20052005-07-05
I am using CodeWarrior and a USB BDM to flash my code. I have a
preload command script which wipes out the entire flash before the
BDM performs the loading. The command script has the following:

// reset the device to get default settings
RESET
// initialize flash programming process
FLASH
// select the flash modules
FLASH SELECT
// erase the flash modules
FLASH ERASE
// arm the flash for programming
FLASH ARM

How can I modify this script to erase only a certain portion of
flash, like up until address 0xF000? Should I just protect that
flash section so it is not erased or should I modify this script
somehow?

Thanks in advance for the help.

Regards,
Eric