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.

Trouble to get data from the Hibernation module non-volatile memory LM4F120H5Q

I try to put controller into the hibernation mode, preserve a data before and restore a data after the code restart . But I have a trouble: I get an unexpected data after wake up. My code looke like this:

unsigned long static_array;

void main()

{

...

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);

ROM_HibernateEnableExpClk(ROM_SysCtlClockGet());

if(ROM_HibernateIsActive())
{
        ulStatus = ROM_HibernateIntStatus(0);
        if(ulStatus & (HIBERNATE_INT_PIN_WAKE))
        {
               ROM_HibernateDataGet(&static_array, 1);
              PulseLed(PIN_BLUE);
       }
}

static_array++;
uart_write((char *)&static_array, 1); // verify the value of static_array variable

...

// put controller into hibernate mode

}

void hibernate_start(void)

{

        ...

       ROM_HibernateDataSet(&static_array, 1);

       PulseLed(PIN_RED);

       ...

}

I sure that hibernate mode work correctly. But after the processor waked up I always get from UART only 0x01, I expect an increasing value.

  • Hello Tankist,

    It is really hard to figure out what might be going wrong with the amount of information provided. By looking at the code I can think of the following two reasons that could be causing the issue that you are reporting.

    1) ROM_HibernateIsActive() returns a '0' since it did not enter Hibernate. This would result in the variable 'static_array' being incremented to 1 (most toolchains initialize a global variable to zero). Are you sure that the device is entering Hibernation? How is the device waking up from Hibernation? What microcontroller and board are you using?

    2) hibernate_start() function is not executed (since I don't have access to all of the code, I can only speculate this). This might result in the hibernate memory having a zero which is read out into "static_array" every time it wakes up from hibernate and then increments it to 1. Did you check the hibernate memory registers to see what value it has? It might help in understanding if the registers are getting written at all. From the code it seems that you are blinking an LED. Do you see the LED blink when expected?

    I hope this information helps you in debug! 

    Regards,

    Sainandan Reddy

     

  • That's just it, I sure, that hibernate is active because:
    - I measured the current consumption;
    - I checked a state of the HIB pin;
    - visual observing of blinking red and blue leds.

    The device wake up by using the WAKE pin. Hibernation come true by pressing a key. Development board is Stellaris Launchpad. The Vbat pin is connect to Vdd pin (in the hibernate mode the power is stable).
    If it is useful, I can publish all source codes.

  • Tankist,

    I think it will help if you can post your code. Please post it in a file so that it is easier to access.

    Thanks,
    Sainandan Reddy
  • This is my project. It was built in the IAR EWARM 6.50. I put into archive the library from StellarisWare.

    3644.stellaris_pow_cons_meas.zip