Re: How to prevent databse from being overwritten in xmem after a power cycle?

"Tom Collins tom-lnEA/wrDJtNWk0Htik3J/[email protected] [rabbit-semi]" <[email protected]> Sat, 8 Aug 2015 15:52:40 -0700
Newsgroups gmane.comp.hardware.rabbit-semiconductor
Message-ID <[email protected]>
[Oops, accidentally sent that last message too soon.]

You'll always allocate the memory on program startup.  Allocating just reserves that block of memory for your program's use -- it doesn't initialize or clear it.  In general:

1) Allocate memory.
2) If markers aren't set correctly:
  a) Initialize data structures in memory.
  b) Set markers.

That's it.  Each time the device starts up, your program will get the same address from the memory allocation call.

If you make changes to your code, the first time you run a new version of the program it might get a different address, but it will detect that condition since the markers won't be set correctly.

-Tom


On Aug 8, 2015, at 7:13 AM, [email protected] [rabbit-semi] wrote:
> Hi John,
> You're probably correct, the battery might be low. I will need to check the voltage.  Thanks again. 
> AFTER allocating memory space [ pMemBlock_Member = (far char *) _xalloc(&tempsz, 0, XALLOC_BB); ] , the values are initialized.  However, I don't want to allocate memory if I have already done so before power cycle.
> 
> How do i check if startAddrMark and StopAddrMark exist?  If it doesn't exist I would allocate the xmem space and initialized it. If Start/Stop markers already exist, nothing no allocating is necessary.
> 
> My current code doesn't work.
> //check to see if the block is initialized (look for the beginning & ending marker)
>    if ((*pStartAddrMark_Member != BLOCK_START_MEMBER) || (*pStopAddrMark_Member != BLOCK_END_MEMBER))