Hi all, I need to create a function that copies a complete flash segment to RAM but I should be able to call the function with any address within that segment, and the function should be able to find the start of the section it self. Example: /*********************************************************************** ************************** Function : flash_Push Parameter : *dest : pointer to updated copy of data in RAM *src : pointer to start of destination flash segment Date : 06/11/2003 Description : flash_Push copies the content of the flash segment containing src into ram segment dest. but prior to doeing so, it first needs to find the start of the segment. ************************************************************************ *************************/ void flash_Push ( U8 *dest, U8 *src ){ U8 i; src = (U8*)((WORD)(src) & 0xF000); // wrap around for flash page base address for(i=0;i<512;i++) dest[i] = *src++; } U8 Container [512] ; flash_Push ( container, 0x1250 ); // should copy from $1200 to $13FF thanks Martijn.
Flash segment erase how to find the start of the section?
Started by ●November 6, 2003
Reply by ●November 6, 20032003-11-06
The segments occur every 512 bytes unless it is segment A or B or (and
this doesn't appear to be documented, the first segment.
1000h is the start of dataflash segment A
107fh is the end of seg A
1080h is the start of segB
10ffh is the end of seg B
1100h is the start of segment 0
11ffh is the end of segment 0, this is a short (256 byte segment
All other segments are 512 bytes long and start with an even number as
the MSB of the address (12xxH etc) hence the address of the start of a
segment can be found by ANDing the address of any location within that
segment with 0FE00H, unless the address of the location is less then 11FFH.
A quick tip, use the word write not byte write procedure. it is faster
when copying segments are writing large tracts of flash.
Al
Martijn Broens wrote:
> Hi all,
>
> I need to create a function that copies a complete flash segment to RAM
> but I should be able to call the function with any address within that
> segment, and the function should be able to find the start of the
> section it self.
>
> Example:
> /***********************************************************************
> **************************
> Function : flash_Push
> Parameter : *dest : pointer to updated copy of data in RAM
> *src : pointer to start of destination
> flash segment
> Date : 06/11/2003
> Description : flash_Push copies the content of the flash segment
> containing src
> into ram segment dest.
> but prior to doeing so, it first needs to find the start
> of the segment.
> ************************************************************************
> *************************/
> void flash_Push ( U8 *dest, U8 *src ){
> U8 i;
>
> src = (U8*)((WORD)(src) & 0xF000); // wrap around for
> flash page base address
>
> for(i=0;i<512;i++)
> dest[i] = *src++;
> }
>
> U8 Container [512] ;
> flash_Push ( container, 0x1250 ); // should copy from $1200 to $13FF
>
>
> thanks Martijn.
>
>
>
>
>
>
>
> .
>
>
>
> ">http://docs.yahoo.com/info/terms/
>
>
>
Reply by ●April 23, 20042004-04-23
Hi, because functions decay implicitly into pointers in expressions (the value of) flash_Push is the start address. Rolf ----------------------------- Hi all, I need to create a function that copies a complete flash segment to RAM but I should be able to call the function with any address within that segment, and the function should be able to find the start of the section it self. Example: /*********************************************************************** ************************** Function : flash_Push Parameter : *dest : pointer to updated copy of data in RAM *src : pointer to start of destination flash segment Date : 06/11/2003" Description : flash_Push copies the content of the flash segment containing src into ram segment dest. but prior to doeing so, it first needs to find the start of the segment. ************************************************************************ *************************/ void flash_Push ( U8 *dest, U8 *src ){ U8 i; src = (U8*)((WORD)(src) & 0xF000); // wrap around for flash page base address for(i=0;i<512;i++) dest[i] = *src++; } U8 Container [512] ; flash_Push ( container, 0x1250 ); // should copy from $1200 to $13FF thanks Martijn.