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

"petermcs-/[email protected] [rabbit-semi]" <[email protected]> 07 Aug 2015 02:51:14 -0700
Newsgroups gmane.comp.hardware.rabbit-semiconductor
Message-ID <[email protected]>
If you are using Recent versions of DC 10 it may be much easier to use normal arrays and allocate them with "bbram far" to create persistent storage over power cycles. I do that in my product and one of the arrays is about 300KB in length - the DC manual says that the limit is 32KB but if you allocate an array of structs you can reserve a much bigger amount of memory. You then need to use far pointers to access the memory instead of array indexes but it works very well as to be honest the array indexing code produced by DC10 is often quite bad so the pointer based access is often faster and takes up less code.
 

 If you look at the trendlog object code in the BACnet stack at bacrabbit.sourceforge.net, you will see this in action (I didn't make the array bbram in this case as it has to work on several boards and not all of them have BBRAM) - see demo\object\trendlog.c for details..
 

 This approach works very well for me and means that the structures are always in the same place in memory after a power up and don't get wiped. You may need to have some checking in place for some of the variables in BBRAM so that on initial power up you can detect unintialised memory and clear everything down first time the code runs.
 

 Regards,
 Peter