This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-CC26X2R1: RAM is cleared after reset

Part Number: LAUNCHXL-CC26X2R1
Other Parts Discussed in Thread: CC2650

I have a code that runs on the CC2650, there is a __no_init (IAR) definition  to a variable that needs to keep his value after reset happens and it's works grate.

But when the same code runs on CC26X2R1, the variable is getting the value 0 (has been written another value before the reset happen) after watchdog timer has reset the system.

Is there any known issue about it?

  • Hi Netanel,

    Can you provide a minimal code example that generates this error? Also, what IAR version are you using?
  • Code is simple as you think:

    1. init the WDT:

    Watchdog_init();

    Watchdog_Params wp;
    Watchdog_Params_init(&wp);
    wp.callbackFxn = (Watchdog_Callback)Hal_WDTCallback;
    wp.debugStallMode = Watchdog_DEBUG_STALL_ON;
    wp.resetMode = Watchdog_RESET_ON;

    hWDT = Watchdog_open(0, &wp);

    uint32_t tickValue;
    tickValue = Watchdog_convertMsToTicks(hWDT, 3000);
    Watchdog_setReload(hWDT, tickValue);

    if (hWDT == NULL) {
    while(1);
    }

    2. init variable:

    __no_init   UTCTime UTC_timeSeconds;

    3. somewhere in the code (in our case it's a command received from UART to set the time)

    UTC_timeSeconds = ....;

    4. stuck the mcu with uart command,

    while (1);

    5. the mcu will reset after 3 seconds.

    6. on init read UTC_timeSeconds  and send it over uart, it's 0.

    IAR ver 8.22.2

    simplelink_cc26x2_sdk_1_60_00_43

  • Netanel,

    The issue here is that tickValue is placed in RAM, and a Watchdog reset causes a HW reset of the entire RAM section, essentially clearing out the tickValue variable. __no_init does indicate to the C run-time to not initialize the tickCount variable at application startup, however, this does not guard the variable from being cleared by a RAM reset.

    I'm wondering, is it non-volatile storage (NVS) you are looking after? Then there are a couple of options:
    1. Using the NVS driver to either store the variable on the internal flash or on the external flash.
    2. Storing the variable in AUX RAM. This might be problematic if you are planning to use the Sensor Controller.
  • The value used for real time clock, and it being saved every 1 second. so to save power we prefers to save it in RAM.

    how can i save the value in the AUX RAM ?
  • Please elaborate why you want to save the real time clock every second? I'm curious.

    To store a value into AUX RAM, simply create a pointer to your desired location and dereference the pointer. E.g.

    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(inc/hw_memmap.h)
    
    #define TICK_COUNT_OFFSET (0)
    #define TICK_COUNT_ADDR   (AUX_RAM_BASE + TICK_COUNT_OFFSET)
    
    // Should be volatile
    volatile uint32_t * const pTickCount = (uint32_t*)TICK_COUNT_ADDR;
    
    /* Writing variable */
    *pTickCount = 42;
    /* Reading variable */
    uint32_t storedCount = *pTickCount;

  • Hi,
    It seems to work fine, very cool.
    You are right, update the var every 1 second is too much, we will tell the client :)

  • I'm not sure I got what you meant at the end there. Setting an offset of 0 is fine. The only constraint is that variables stored in AUX_RAM doesn't overlap.
  • you are right, my mistake.