USB API - how use HCS08_FCMD_BURST_PROG for flash programming?

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

USB API - how use HCS08_FCMD_BURST_PROG for flash programming?

461 Views
dmitriykirpika
Contributor I

Hello!

If write to flash 1 byte, no problems (first PAGE_ERASE):

  • FF=HCS08_FSTAT_FPVIOL | HCS08_FSTAT_FACCERR;
  • Err_=USBDM_WriteMemory (1, 1, #HCS08_FSTAT, pointer FF);
  • If (Err_!=0) ... ;//code skipped
  • Err_=USBDM_WriteMemory (1, 1, 0x1A00, pointer buffer); // 1 byte data for write to flash
  • If (Err_!=0) ... ;//code skipped
  • cmd=HCS08_FCMD_BURST_PROG;
  • Err_=USBDM_WriteMemory (1, 1, #HCS08_FCMD, pointer cmd);// Execute burst prog

The code above works. But slowly - 512 bytes 24 sec.

If write more bytes, FACCERR return error.

  • FF=HCS08_FSTAT_FPVIOL | HCS08_FSTAT_FACCERR;
  • Err_=USBDM_WriteMemory (1, 1, #HCS08_FSTAT, pointer FF);
  • If (Err_!=0) ... ;//code skipped
  • Err_=USBDM_WriteMemory (1, 64, 0x1A00, pointer buffer); //  64 bytes data for write to flash
  • If (Err_!=0) ... ;//code skipped
  • FF=HCS08_FCMD_BURST_PROG;
  • Err_=USBDM_WriteMemory (1, 1, #HCS08_FCMD, pointer FF);// Execute burst prog

What's wrong? How use burst_prog?

Version DLL 4.10.6

0 Kudos
1 Reply

255 Views
pgo
Senior Contributor V

Hi Dmitriy,

I do not believe the burst programming function works the way you think it does.

It does NOT allow programming of a range of memory in one operation.  All it does is it speeds up the process of programming the individual locations by implementing a 2-byte FIFO which allows the programming voltage to be left on between individual locations.

Please refer to the programming flowcharts provided in the chip manual for the correct sequence.

PS.The method you are using will be very slow (as you have discovered).

The usual method is to download a small program to the target RAM along with a buffer of bytes to program.  The small program then programs the target including the required polling between programming each byte.

I suggest you use the USBDM programming API rather than the low-level API you are using.

Please see the following link:

usbdm-eclipse-makefiles-build/USBDM_Programmer_API_Example at master · podonoghue/usbdm-eclipse-make...

bye

0 Kudos