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

"'John Stanley' rizklyf02-O/[email protected] [rabbit-semi]" <[email protected]> Fri, 7 Aug 2015 13:56:23 -0500
Newsgroups gmane.comp.hardware.rabbit-semiconductor
Message-ID <[email protected]>
It looks like you've got the basics.  If it's still initializing the data
on every power up, you might want to check the bbram coin battery.  They
can sometimes arrive very low or dead.

Hmmm....  I just noticed that you're not setting PtrToFamilyMemberFile
until AFTER you call InitializeWithDefaultData().   How is your
initialization function going to know where to put the data?

.... John S.

PS : You don't need to define separate start block and end block pointers
for testing and initializing each block.  Just define a pair and reuse them
for each block.  (They shouldn't be needed after the setup.)
On Aug 6, 2015 9:47 AM, "[email protected] [rabbit-semi]
rabbit-semi-at-yahoogroups.com |yahoo/Example Allow|" <
biosvrdert-O/[email protected]> wrote:

>
>
> After allocating +13kB in xmem using _xalloc(&tempsz, 0, XALLOC_BB) and
> itializing it, how do I prevent reallocating memory with default data(which
> are out-of-date) after a power cycle?  is there something I'm missing?
>
>
> // begin quasi pseudo-code...
>
> #define BLOCK_START_MEMBER             ((long)0x3A8446F7)
> #define BLOCK_END_MEMBER                 ((long)0x7F6448A3)
>
> #define BLOCK_START_NODE                 ((long)0x3A8446F8)
> #define BLOCK_END_NODE                 ((long)0x7F6448A4)
>
> #define BLOCK_START_DIGITAL             ((long)0x3A8446F9)
> #define BLOCK_END_DIGITAL             ((long)0x7F6448A5)
>
> #define BLOCK_START_ANALOG             ((long)0x3A8446FA)
> #define BLOCK_END_ANALOG                 ((long)0x7F6448A6)
>
>
> void main(void)
> {
>
>
>    long tempsz;
>    far char *pMemBlock_Member, *pMemBlock_Node,
> *pMemBlock_Digital,*pMemBlock_Analog;
>    far long *pStartAddrMark_Member, *pStartAddrMark_Node,
> *pStartAddrMark_Digital, *pStartAddrMark_Analog;
>    far long *pStopAddrMark_Member, *pStopAddrMark_Node,
> *pStopAddrMark_Digital, *pStopAddrMark_Analog;
>
>
>    //--------------------------Allocate Memory Block for
> Members----------------
>    //_xalloc the data block and calculate marker locations
>    tempsz = (MAX_MEMBERS * sizeof(Member_t));
>    tempsz += 2 * sizeof(long);                                  //add room
> for start/end address
>    pMemBlock_Member = (far char *) _xalloc(&tempsz, 0, XALLOC_BB);
>    if(pMemBlock_Member == NULL)
>    {
>       printf("\n _xalloc failed for MEMBER \n");
>       //reboot
>    }
>    pStartAddrMark_Member = (far long *)pMemBlock_Member;
>    pStopAddrMark_Member = (far long *)(pMemBlock_Member + tempsz -
> sizeof(long) );
>
>    //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))
>    {
>       // zero the memory block
>       _f_memset(pMemBlock_Member, 0, tempsz);
>
>       Initialize with default data.
>       InitializeWithDefaultData();
>       // put markers at start and end of the memory block
>       *pStartAddrMark_Member = BLOCK_START_MEMBER;
>       *pStopAddrMark_Member = BLOCK_END_MEMBER;
>    }
>    PtrToFamilyMemberFile = (far Member_t *)(pMemBlock_Member +
> sizeof(long));
>
>
>   while (1)
>   {
>
>
>
>    }
>
> }
>
>
>
>
> 
>