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.

CCS/TM4C123GH6PM: HIBERNATION MODULE

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: EK-TM4C123GXL

Tool/software: Code Composer Studio

Hi all, I want to perform hibernation for 10 minutes and after that, my program should enter into normal operation for 2 minutes and again it should enter into hibernation for 10 minutes. In this way, the whole cycle should be repeated in this way. Is it possible to perform this method in tm4c123gh6pm?

  • Hello Siva,

    That should be possible, yes.

    Are you planning to use the RTC for this? Have you worked with the hibernate module at all yet? If so, which mode(s) have you worked with?
  • Hello Ralph Jacobi,

    Yes, I am going to use RTC for this task.Now started working in hibernation module. I am planning to use RTC Match - Seconds/Subseconds Mode and RTC Counter - Seconds/Subseconds Mode.Kindly share any reference for hibernation module mode and that could be very helpfull for me.

    Thanks and Regards,

    Siva 

  • Hello Siva,

    The RTC Match is definitely the way to go! Unfortunately we don't have a TivaWare example for it.

    This thread has some details that can help guide you on implementation: e2e.ti.com/.../511213

    Also there was a lot of discussion and code examples shared for Hiberate with RTC Match here: e2e.ti.com/.../561075

    Please see if these get you going, if not I may have time next week to put together a basic example.
  • Hello Ralphi Jacobi,
    This code enters into hibernation after 50 seconds and I want to prolong the hibernation for 120 seconds. After 120 seconds, it should wake up from hibernation.how to set 120 seconds time period for hibernation and RTC match to wake up.Kindly help me to solve the problem.


    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include "tm4c123gh6pm.h"
    #include "utils/ustdlib.h"
    #include "inc/hw_types.h"
    #include "inc/hw_memmap.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"
    #include "inc/hw_hibernate.h"
    void uart0_init()
    {
    SYSCTL_RCGCUART_R |=0x00000001;
    SYSCTL_RCGCGPIO_R |=0x00000001;
    SYSCTL_RCGCHIB_R |=0x00000001;
    GPIO_PORTA_LOCK_R |=0x4C4F434B;
    GPIO_PORTA_CR_R |=0x00000003;
    GPIO_PORTA_DEN_R |=0x00000003;
    GPIO_PORTA_AFSEL_R |=0x00000003;
    GPIO_PORTA_PCTL_R |=0x00000011;
    UART0_CTL_R &=~0x00000001;
    UART0_IBRD_R =104;
    UART0_FBRD_R=11;
    UART0_LCRH_R |=0x00000060;
    UART0_CC_R |=0x00000000;
    UART0_CTL_R |=0x00000301;

    }
    void U0_send(unsigned char k)
    {
    while((UART0_FR_R & 0x00000020)!=0);
    UART0_DR_R =k;
    }
    void U0_print(unsigned char *p)
    {
    while(*p)
    {
    U0_send(*p++);
    }
    }
    void delay(unsigned int x)
    {
    unsigned int i,j;
    for(i=0;i<x;i++)
    {
    for(j=0;j<x;j++)
    {

    }
    }
    }
    int main(void)
    {

    long i=0;
    uart0_init();
    U0_print("UART0 Initialized\r\n");
    delay(3000);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
    HibernateEnableExpClk(SysCtlClockGet());
    HibernateRTCEnable();
    HibernateRTCSet(0);
    uint32_t ui32Status;
    unsigned char buff[100]={0};
    unsigned char test[3]="50";
    while(1)
    {
    i++;
    delay(1000);
    ui32Status =HibernateRTCGet();
    memset(buff,0,sizeof(buff));
    ltoa(ui32Status,buff);
    U0_print(buff);

    if(strcmp(buff,test)==0)
    {
    SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
    HibernateEnableExpClk(SysCtlClockGet());
    HibernateRequest();
    }

    }

    }
  • Hello Siva,

    I put together an example project (attached below) for the EK-TM4C123GXL LaunchPad which includes having Hibernate starting after 50 seconds and waking from Hibernate every 120 seconds. The RGB LED starts on when the RTC is enabled, turns off after 50 seconds, and then toggles on and off every 120 seconds.

    hibernate_120secwake.zip

  • Hello Ralphi Jacobi,

           In this below code, With reference to your example code, I have added to the following API

            1. HibernateRequest();

            2.HibernateRTCGet();

            3.HibernateWakeSet(HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC);

       My aim is to get the current value of RTC counter and if it is 50 it should initiate the hibernation. After that whenever RTC match occurs, it wakes up from hibernation. Kindly verify the following above conditions is satisfied properly or not. If any further modifications are required and kindly help me.

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


    void uart0_init()
    {
    SYSCTL_RCGCUART_R |=0x00000001;
    SYSCTL_RCGCGPIO_R |=0x00000001;
    SYSCTL_RCGCHIB_R |=0x00000001;
    GPIO_PORTA_LOCK_R |=0x4C4F434B;
    GPIO_PORTA_CR_R |=0x00000003;
    GPIO_PORTA_DEN_R |=0x00000003;
    GPIO_PORTA_AFSEL_R |=0x00000003;
    GPIO_PORTA_PCTL_R |=0x00000011;
    UART0_CTL_R &=~0x00000001;
    UART0_IBRD_R =104;
    UART0_FBRD_R=11;
    UART0_LCRH_R |=0x00000060;
    UART0_CC_R |=0x00000000;
    UART0_CTL_R |=0x00000301;

    }
    void U0_send(unsigned char k)
    {
    while((UART0_FR_R & 0x00000020)!=0);
    UART0_DR_R =k;
    }
    void U0_print(unsigned char *p)
    {
    while(*p)
    {
    U0_send(*p++);
    }
    }
    void delay(unsigned int x)
    {
    unsigned int i,j;
    for(i=0;i<x;i++)
    {
    for(j=0;j<x;j++)
    {

    }
    }
    }
    void HibernateISRHandler(void)
    {
         uint32_t ui32Status;
         ui32Status = HibernateIntStatus(true);
          HibernateIntClear(ui32Status);

         if(ui32Status & HIBERNATE_INT_RTC_MATCH_0)
            {
               U0_print("in hibernate INTeruppt \r\n");
               uint32_t ui32RTCMatch;
               ui32RTCMatch = HibernateRTCGet();
               HibernateRTCMatchSet(0,ui32RTCMatch + 200);
               if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_3))
                   {
                        U0_print("in hibernate led off\r\n");
                       delay(1000);
                       GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3,0x00);
                   }
               else
                   {
                      U0_print("in hibernate led ON\r\n");
                     delay(1000);
                     GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3,0x08);
                   }
          }
    }

    void main(void)
    {
        long i=0;
        uart0_init();
        U0_print("UART0 Initialized\r\n");
        delay(3000);


    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);


    SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
    HibernateEnableExpClk(0);

    while(!(HWREG(HIB_RIS) & HIB_RIS_WC));

    HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE);


    HibernateRTCSet(0);
    HibernateRTCMatchSet(0,5);
    HibernateIntEnable(HIBERNATE_INT_RTC_MATCH_0);
    HibernateRTCTrimSet(0x7FFF);
    HibernateRTCEnable();
    HibernateWakeSet(HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC);

    IntEnable(INT_HIBERNATE_TM4C123);
    IntMasterEnable();

    uint32_t ui32Status;
    unsigned char buff[100]={0};
    unsigned char test[3]="50"; 

        while(1)
        {
           U0_print("in main\r\n");
            delay(1000);
             i++;
             delay(1000);

            ui32Status = HIB_RTCC_R ;
            memset(buff,0,sizeof(buff));
            ltoa(ui32Status,buff);
            U0_print(buff); 
            U0_print("\r\n");
                    if(strcmp(buff,test)==0)
                     {
                       U0_print("\n\r Hibernate Requested\r\n");
                       HibernateRequest();

                      }

         }

    }

  • Hello Siva,

    Ah yes I did forgot to add in the HibernateRequest(); at the end of the ISR processing, thanks for catching this, I was focused on RTC timings.

    The only difference in code then would be that instead of setting

    HibernateRTCMatchSet(0,50); // Set initial match value to trigger RTC after 50 seconds

    You would need to manually check the count via HibernateRTCGet and determine when to enter Hibernation from there.

  • Hello Ralph Jacobi,
    With HibernateRTCGet, I am able to enter the hibernate request and wakeup from Hibernate using Hibernate_Wake_RTC in HibernateWakeSet(); whenever RTC match occurs. Thanks a lot for helping me to solve the issue.


    Thanks and Regards,
    Siva