EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Erase Flash Function Work Well!

Started by changj101010 November 30, 2003
I had tested the operation of flash. That is, call flash erasing
functions directly from program running in RAM. The result is, it
work all the time. Thus, I really don't know why so many times I
can't compile program to flash with PILOT! ACCESSORY:
The code in my test program like this, and is compiled to RAM:

...
printf(" Try to erase the 1st sector of flash...\n");

saveMB2 = MB2CRShadow; //Map flash to qua-2,3
saveMB3 = MB3CRShadow;
WrPortI(MB2CR, &MB2CRShadow, 0xc0);
WrPortI(MB3CR, &MB3CRShadow, 0xc0);

#asm
ld hl,0x04|0x08
c ;
call _InitFlashDriver; //Initflash driver for not done in BIOS
//when compile to RAM
ld a,0x72
ld de,0xe010 //to erase first sector of flash
//the corresponding address is 72:e010
c ;
call _EraseFlashSect
#endasm
printf(" Erase finished!\n");
...


How do you conclude the Flash erase works with below sample code?

The only thing I can conclude from this code, is that the function
_EraseFlashSect is called and it returns. That thus not guarantee
the function really erased a Flash sector, thus it???

Follow Roberts advice. Run a test program in RAM, which writes the
Flash. Check the return code of the Flash write routine to find out
about write problems. If no problems are reported, read the Flash
and check whether the write was successfull.

Once more I want to inform you, you really need to add the proper
Flash device information to the FlashData table in flashwr.lib. Else
you will not be able to write to the Flash. ALL the flash support
functions of DC will report an 'unknown' flash device. Check it,
with a test program in RAM.

Rudi

--- In rabbit-semi@rabb..., "changj101010" <changj10@v...>
wrote:
> I had tested the operation of flash. That is, call flash erasing
> functions directly from program running in RAM. The result is, it
> work all the time. Thus, I really don't know why so many times I
> can't compile program to flash with PILOT! > ACCESSORY:
> The code in my test program like this, and is compiled to RAM:
>
> ...
> printf(" Try to erase the 1st sector of flash...\n");
>
> saveMB2 = MB2CRShadow; //Map flash to qua-2,3
> saveMB3 = MB3CRShadow;
> WrPortI(MB2CR, &MB2CRShadow, 0xc0);
> WrPortI(MB3CR, &MB3CRShadow, 0xc0);
>
> #asm
> ld hl,0x04|0x08
> c ;
> call _InitFlashDriver; //Initflash driver for not done in
BIOS
> //when compile to RAM
> ld a,0x72
> ld de,0xe010 //to erase first sector of flash
> //the corresponding address is 72:e010
> c ;
> call _EraseFlashSect
> #endasm
> printf(" Erase finished!\n");
> ...




Hi Rudi
Some work I have done are not mentioned in this message. I had
seen the containning of the flash at first sector and it's not all
0xff(actually there is the code in it. I have wrotten flash
succefully before) and after I carried this code out in RAM, the
cantainnings became all 0xff. So I can concluded the flash was
erased OK. On the same time, I observed the CS1/ signal and there
was a serials of pulse.
OK, I'll get the flash-test program to run on my board. It has
hold me back for a whole week!

--- In rabbit-semi@rabb..., "xgraph1" <yahoo2@d...> wrote:
> How do you conclude the Flash erase works with below sample code?
>
> The only thing I can conclude from this code, is that the function
> _EraseFlashSect is called and it returns. That thus not guarantee
> the function really erased a Flash sector, thus it???
>
> Follow Roberts advice. Run a test program in RAM, which writes the
> Flash. Check the return code of the Flash write routine to find
out
> about write problems. If no problems are reported, read the Flash
> and check whether the write was successfull.
>
> Once more I want to inform you, you really need to add the proper
> Flash device information to the FlashData table in flashwr.lib.
Else
> you will not be able to write to the Flash. ALL the flash support
> functions of DC will report an 'unknown' flash device. Check it,
> with a test program in RAM.
>
> Rudi
>
> --- In rabbit-semi@rabb..., "changj101010" <changj10@v...>
> wrote:
> > I had tested the operation of flash. That is, call flash erasing
> > functions directly from program running in RAM. The result is,
it
> > work all the time. Thus, I really don't know why so many times I
> > can't compile program to flash with PILOT!
> >
> >
> > ACCESSORY:
> > The code in my test program like this, and is compiled to RAM:
> >
> > ...
> > printf(" Try to erase the 1st sector of flash...\n");
> >
> > saveMB2 = MB2CRShadow; //Map flash to qua-2,3
> > saveMB3 = MB3CRShadow;
> > WrPortI(MB2CR, &MB2CRShadow, 0xc0);
> > WrPortI(MB3CR, &MB3CRShadow, 0xc0);
> >
> > #asm
> > ld hl,0x04|0x08
> > c ;
> > call _InitFlashDriver; //Initflash driver for not done in
> BIOS
> > //when compile to RAM
> > ld a,0x72
> > ld de,0xe010 //to erase first sector of flash
> > //the corresponding address is
72:e010
> > c ;
> > call _EraseFlashSect
> > #endasm
> > printf(" Erase finished!\n");
> > ...





Memfault Beyond the Launch