LPC23XX backup battery ram issue

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by EhsanDaneshvar on Sun Nov 22 07:12:50 MST 2015

I have a board consist of LPC2368 and backup battery ( CR2032 )
after a while some thing strange have been happened that made me confused!

i don't know why but after every reset all data stored in battery ram set to zero and it happen in both hardware and software reset.
but the RTC works correct and there is no error in time value.

i checked it in IAR watch panel ... befor running any line of my MAIN procedure all values set to  zero!

in my code I've defined them like it :

        __no_init     int unsigned          press_counter@ "BATTERY_RAM";
__no_init    unsigned int           Ltime@ "BATTERY_RAM";
__no_init    unsigned int           Lcounter@ "BATTERY_RAM";
__no_init    unsigned int           Ltime_on@ "BATTERY_RAM";
__no_init    profile_t                 prof @ "BATTERY_RAM";
__no_init    shaft_status_e       machine_t::shaft_status @ "BATTERY_RAM";

also i added a section in ICF linker file for battery ram like this :

    define symbol __region_BATTERY_RAM_start__ = 0xE0084000;
    define symbol __region_BATTERY_RAM_end__   = 0xE00847FF;
    define region BATTERY_RAM_region= mem:[from __region_BATTERY_RAM_start__ to __region_BATTERY_RAM_end__];  
    define block BATTERY_RAM with alignment = 4, size = 2048 { };

the strange thing is that it was working ....