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.

Hibernation



Hi,

I want to use hibernation mode on my system. I am using the Tiva launchpad to test the hibernation mode. I want the board to go to hibernation mode when button is pressed on launchpad and should wake up when button is pressed again. Kindly advise me on this. I have attached my code.

Regards,

Mohsin

#include <stdint.h>
#include <stdbool.h>
#include "utils/ustdlib.h"
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_ints.h"
#include "driverlib/sysctl.h"
#include "driverlib/pin_map.h"
#include "driverlib/debug.h"
#include "driverlib/hibernate.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"


bool g_bHibernate = false;

void HibernateIntHandler(void)
{
uint32_t ui32Status;

//
// Read and clear any status bits that might have been set since
// last clearing them.
//
ui32Status = HibernateIntStatus(0);
HibernateIntClear(ui32Status);

//
// If switch is pressed.
//
if(ui32Status & HIBERNATE_INT_PIN_WAKE)
g_bHibernate = g_bHibernate ? false: true;
}

int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, GPIO_PIN_1);

SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
HibernateEnableExpClk(SysCtlClockGet());
HibernateGPIORetentionEnable();
SysCtlDelay(64000000);
HibernateWakeSet(HIBERNATE_WAKE_PIN);

HibernateIntRegister(HibernateIntHandler);
HibernateIntEnable(HIBERNATE_INT_PIN_WAKE);
HibernateIntClear(HIBERNATE_INT_PIN_WAKE);
IntEnable(INT_HIBERNATE);
IntMasterEnable();

while(1)
{
if (g_bHibernate)
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1, 0x00);
g_bHibernate = false;
HibernateIntClear(HIBERNATE_INT_PIN_WAKE);

//
// Configure Hibernate wake sources.
//
HibernateWakeSet(HIBERNATE_WAKE_PIN);

//
// Enables GPIO retention after wake from hibernation
//
HibernateGPIORetentionEnable();
HibernateRequest();
}
}
}