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.

Reason for Processor Being locked in Hibernation module

Other Parts Discussed in Thread: EK-TM4C1294XL

I am currently using TM4C129X developement board and Implementing the same code given in example for RTC in Hibernate Module named as "hibernate" by excluding the display function from it.

And while debugging when i Run the code my processor goes in locked state.Can you help me in knowing the reason by which processor goes in locked state.

  • Hello Vibha,

    When you say "locked state" what does that mean? Is the MCU getting locked - that is, cannot access using the JTAG? Or is the code not executing the code? Are you putting the MCU into hibernate mode when the MCU goes into "locked state"?

    Thanks,
    Sai
  • I got locked state i.e when i run the code once and exit from debug state then after while again going to debug state it shows an Error as "Cannot Connect to the Target".
    After executing HibernateRequest(); from next line i got erroe as "Debug Port error Occured" then "Trouble Halting Target CPU"
    Yes I am using Hibernate mode but am not Using Any JTAG pin. I've just excluded the display function from the example given as "hibernate".
    MY code is

    //*********************************************************************************************************

    ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), 120000000);
    //
    // Configure the device pins.
    //
    PinoutSet();

    //
    // Enable the hibernate module.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);

    //
    // Initialize these variables before they are used.
    //
    ui32Status = 0;
    ui32HibernateCount = 0;

    //
    // Check to see if Hibernation module is already active,which could mean
    // that the processor is waking from a hibernation.
    //
    if(HibernateIsActive())
    {
    //
    // Read the status bits to see what caused the wake.Clear the wake
    // source so that the device can be put intohibernation again.
    //
    ui32Status = HibernateIntStatus(0);
    HibernateIntClear(ui32Status);

    //
    // Wake was due to RTC match.
    //
    if(ui32Status & HIBERNATE_INT_RTC_MATCH_0)
    {
    gwCount++;
    }

    //
    // Wake was due to Reset button.
    //
    else if(ui32Status & HIBERNATE_INT_RESET_WAKE)
    {
    gwCount++;
    }

    //
    // Wake was due to the External Wake pin.
    //
    else if(ui32Status & HIBERNATE_INT_PIN_WAKE)
    {
    gwCount++;
    }
    //
    // If the wake is due to any of the configured wakesources, then read
    // the first location from the battery backed memory,as the
    // hibernation count.
    //
    if(ui32Status & (HIBERNATE_INT_PIN_WAKE |HIBERNATE_INT_RTC_MATCH_0 |
    HIBERNATE_INT_RESET_WAKE))
    {
    HibernateDataGet(&ui32HibernateCount, 1);
    }
    }

    //
    // Configure Hibernate module clock.
    //
    HibernateEnableExpClk(ui32SysClock);

    //
    // If the wake was not due to the above sources, then itwas a system
    // reset.
    //
    if(!(ui32Status & (HIBERNATE_INT_PIN_WAKE |HIBERNATE_INT_RTC_MATCH_0 |HIBERNATE_INT_RESET_WAKE)))
    {
    //
    // Configure the module clock source.
    //
    HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE);

    //
    // Set Calendar time to start from 08/29/2013 at8:30AM
    //
    g_ui32MonthIdx = 7;
    g_ui32DayIdx = 29;
    g_ui32YearIdx = 13;
    g_ui32HourIdx = 8;
    g_ui32MinIdx = 30;
    }

    //
    // Enable RTC mode.
    //
    HibernateRTCEnable();

    //
    // Configure the hibernate module counter to 24-hourcalendar mode.
    //
    HibernateCounterMode(HIBERNATE_COUNTER_24HR);

    //
    // Configure GPIOs used as Hibernate wake source
    //
    GPIOPadConfigSet(GPIO_PORTK_BASE, 0x20, GPIO_STRENGTH_2MA,
    (GPIO_PIN_TYPE_WAKE_LOW |GPIO_PIN_TYPE_STD_WPU));

    //
    // Enable processor interrupts.
    //
    IntMasterEnable();

    //
    // If hibernation count is very large, it may be thatthere was already
    // a value in the hibernate memory, so reset the count.
    //
    ui32HibernateCount = (ui32HibernateCount > 10000) ? 0 :ui32HibernateCount;

    //
    // Increment the hibernation count, and store it in thebattery backed
    // memory.
    //
    ui32HibernateCount++;
    HibernateDataSet(&ui32HibernateCount, 1);

    while(1)
    {
    //
    // Write the requested date and time.
    //
    DateTimeSet();
    //
    // Get calendar match value to be 5 seconds fromthe current time.
    //
    GetCalendarMatchValue(&sTime);

    //
    // Set the calendar match register such that itwakes up from
    // hibernation in 5 seconds.
    //
    HibernateCalendarMatchSet(0, &sTime);

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

    //
    // Configure Hibernate wake sources.
    //
    HibernateWakeSet(HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RESET |HIBERNATE_WAKE_RTC);

    //
    // Request Hibernation.
    //
    HibernateRequest();

    //
    // Wait for a while for hibernate to activate. Itshould never get
    // past this point.
    //
    SysCtlDelay(100);
    }
    }
  • Hello Vibha,

    Are you able to program the MCU after resetting the power - unplug and plug the power cable?

    If you run the code without the debugger, are you seeing the same issue?

    Are you seeing the same behavior with the unmodified code in TivaWare?

    Hopefully these experiments will help you in identifying the issue!

    Thanks,
    Sai
  • Hello,
    Yes when I unlock the Processor by LM Flash programer I can go to Debug again.
    When i run code without any modification it does not go in locked state.
    My issue is Why it goes to locked state, Are my steps are not suitable as per requirement in code?
    Can you please help me to Configure RTC in Hibernate Calender mode ?

    Thanks,
    Vibha
  • Hello,
    Will you help me to find the correct steps to configure RTC in Hibernate Calender Mode.

    Thanks,
    Vibha
  • Hello Vibha,

    The "hibernate" example in the folder "/example/boards/dk-tm4c129x" and "/example/boards/ek-tm4c1294xl" configures the Hibernate module in 24-hour calendar mode.

    Are you doing something different? If not, then did you compare with the example in TivaWare and check what the differences are?

    Thanks,
    Sai
  • Hello,

    Yes I followed the same example you are talking about by just excluding all display function from it . My requirement is my RTC should continue its working even if i remove power. And after i run my code it shows updated second,minute,hour and month but i am getting corrupted year value.My year value are unmodified and wrong as per requirement.can you tell me why this happens. my code is as follow:

    bool DateTimeGet(struct tm *sTime)
    {
    //
    // Get the latest time.
    //
    HibernateCalendarGet(sTime);

    //
    // Is valid data read?
    //
    if(((sTime->tm_sec < 0) || (sTime->tm_sec > 59)) ||
    ((sTime->tm_min < 0) || (sTime->tm_min > 59)) ||
    ((sTime->tm_hour < 0) || (sTime->tm_hour > 23)) ||
    ((sTime->tm_mday < 1) || (sTime->tm_mday > 31)) ||
    ((sTime->tm_mon < 0) || (sTime->tm_mon > 11)) ||
    ((sTime->tm_year < 100) || (sTime->tm_year > 199)))
    {
    return false;
    }
    else
    {
    //
    // Return that new data is available so that it can be displayed.
    //
    return true;
    }
    }
    //*****************************************************************************
    bool
    DateTimeUpdateGet(char *pcMon, char *pcDay, char *pcYear, char*pcHour,char *pcMin, char *pcAMPM)
    {
    struct tm sTime;

    //
    // Get the latest date and time and check the validity.
    //
    if(DateTimeGet(&sTime) == false)
    {
    //
    // Invalid - Return here with false as no informationto update. So
    // use default values.
    //
    return false;
    }

    //
    // If date and time is valid, copy the date and timevalues into respective
    // indexes.
    //
    g_ui32MonthIdx = sTime.tm_mon;
    g_ui32DayIdx = sTime.tm_mday;
    // g_ui32YearIdx = sTime.tm_year - 100;
    g_ui32HourIdx = sTime.tm_hour;
    g_ui32MinIdx = sTime.tm_min;
    //
    // Return true to indicate new information has been updated.
    //
    return true;
    }

    //*****************************************************************************
    //
    // This function writes the requested date and time to thecalendar logic of
    // hibernation module.
    //
    //*****************************************************************************
    void
    DateTimeSet(void)
    {
    struct tm sTime;

    //
    // Get the latest date and time. This is done here sothat unchanged
    // parts of date and time can be written back as is.
    //
    HibernateCalendarGet(&sTime);

    //
    // Set the date and time values that are to be updated.
    //
    sTime.tm_hour = g_ui32HourIdx;
    sTime.tm_min = g_ui32MinIdx;
    sTime.tm_mon = g_ui32MonthIdx;
    sTime.tm_mday = g_ui32DayIdx;
    // sTime.tm_year = 100 + g_ui32YearIdx;

    //
    // Convert 12-hour format into 24-hour format.
    //
    if(sTime.tm_hour < 12)
    {
    sTime.tm_hour += 12;
    }
    else
    {
    if(sTime.tm_hour > 11)
    {
    sTime.tm_hour -= 12;
    }
    }

    //
    // Update the calendar logic of hibernation module with the requested data.
    //
    HibernateCalendarSet(&sTime);
    }

    //*****************************************************************************
    //
    // This function returns the number of days in a monthincluding for a leap
    // year.
    //
    //*****************************************************************************
    uint32_t
    GetDaysInMonth(uint32_t ui32Year, uint32_t ui32Mon)
    {
    //
    // Return the number of days based on the month.
    //
    if(ui32Mon == 1)
    {
    //
    // For February return the number of days based on theyear being a
    // leap year or not.
    //
    if((ui32Year % 4) == 0)
    {
    //
    // If leap year return 29.
    //
    return 29;
    }
    else
    {
    //
    // If not leap year return 28.
    //
    return 28;
    }
    }
    else if((ui32Mon == 3) || (ui32Mon == 5) || (ui32Mon == 8)||
    (ui32Mon == 10))
    {
    //
    // For April, June, September and November return 30.
    //
    return 30;
    }

    //
    // For all the other months return 31.
    //
    return 31;
    }

    //*****************************************************************************
    //
    // This function returns the date and time value that iswritten to the
    // calendar match register. 5 seconds are added to thecurrent time. Any
    // side-effects due to this addition are handled here.
    //
    //*****************************************************************************
    void
    GetCalendarMatchValue(struct tm* sTime)
    {
    uint32_t ui32MonthDays;

    //
    // Get the current date and time and add 5 secs to it.
    //
    HibernateCalendarGet(sTime);
    sTime->tm_sec += 5;

    //
    // Check if seconds is out of bounds. If so subtractseconds by 60 and
    // increment minutes.
    //
    if(sTime->tm_sec > 59)
    {
    sTime->tm_sec -= 60;
    sTime->tm_min++;
    }

    if(sTime->tm_min > 59)
    {
    sTime->tm_min -= 60;
    sTime->tm_hour++;
    }

    //
    // Check if hours is out of bounds. If so subtractminutes by 24 and
    // increment days.
    //
    if(sTime->tm_hour > 23)
    {
    sTime->tm_hour -= 24;
    sTime->tm_mday++;
    }

    //
    // Since different months have varying number of days, getthe number of
    // days for the current month and year.
    //
    ui32MonthDays = GetDaysInMonth(sTime->tm_year, sTime->tm_mon);

    //
    // Check if days is out of bounds for the current monthand year. If so
    // subtract days by the number of days in the currentmonth and increment
    // months.
    //
    if(sTime->tm_mday > ui32MonthDays)
    {
    sTime->tm_mday -= ui32MonthDays;
    sTime->tm_mon++;
    }

    //
    // Check if months is out of bounds. If so subtractmonths by 11 and
    // increment years.
    //
    if(sTime->tm_mon > 11)
    {
    sTime->tm_mon -= 11;
    sTime->tm_year++;
    }

    //
    // Check if years is out of bounds. If so subtract yearsby 100.
    //
    if(sTime->tm_year > 99)
    {
    sTime->tm_year -= 100;
    }
    }

    void main()
    {

    uint32_t ui32Status;

    IntMasterDisable();

    Init_BSP();
    //
    //Activate The Hibernate Perpheral
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);

    ui32Status = HibernateIntStatus(0);
    HibernateIntClear(ui32Status);

    HibernateEnableExpClk(SYS_CLOCK);

    //
    //Configuration of clock Source for Hibernate Module
    //enables the LFIOSC as the clock source to the Hibernation module
    //
    HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE);

    HibernateRTCEnable();

    //
    //Set the Initial value for RTC
    //
    HibernateRTCSet(0);

    //We set a interrupt for the RTC after second. You can change the value
    HibernateRTCMatchSet(0,HibernateRTCGet()+1);

    HibernateIntEnable(HIBERNATE_INT_RTC_MATCH_0);

    HibernateIntClear(HIBERNATE_INT_RTC_MATCH_0);

    //Set up calender mode. HibernateCounterMode() is always needed but can be set to 12hr mode
    HibernateCounterMode(HIBERNATE_COUNTER_24HR);

    HibernateCalendarSet(&sTime); //<-- the struct declared
    //
    // Set Calendar time to start from 08/29/2013 at 8:30
    //
    sTime.tm_hour = 23;
    sTime.tm_sec = 00;
    sTime.tm_min = 59;
    sTime.tm_mon = 11;
    sTime.tm_mday = 31;
    sTime.tm_year = 10;
    //This fuction below is what actualy updates the values inside the peripheral.
    //if you don't use it, the value changes above won't do anytigh
    HibernateCalendarSet(&sTime);

    IntMasterEnable();

    while(1)
    {
    //
    // Write the requested date and time.
    //
    // DateTimeSet();

    //
    // Get calendar match value to be 5 seconds fromthe current time.
    //
    GetCalendarMatchValue(&sTime);

    HibernateCalendarMatchSet(0, &sTime);
    //
    // Request Hibernation.
    //
    HibernateRequest();

    SysCtlDelay(1000);
    }
    }

    Thanks,
    Vibha
  • Vibha,

    If all you are doing is removing the display part of the code, then they should work, as both the examples, I listed in my previous post, have been tested on their respective boards.

    Initially you reported an issue about the MCU getting locked-up. Is this issue solved? You are posting another issue now. Please solve one issue at a time. As mentioned before, please first compare the code you have written to the one in TivaWare. Then try to analyze if the code you omitted is causing the issue. I believe this will lead you to solving both the issue you have reported so far.

    Also use "Syntax Highlighter" when posting code snippets, to make the forum post and the code readable. This will improve the chances of getting a reply.

    Thanks,
    Sai
  • Hello,

    Yes I Have tested the example you  given on their respective Board and it worked properly but  it do not retain its value at power down in my case , I am working on the reason....

    As i already mentioned in third post of my that by using LM flash programmer i can unlock my processor .My issue was to finding the reason it has locked the processor so that i can avoid in future.

    The Example you given is really helpful...Thanks for your quick reply and support.

    Thanks,

    Vibha

  • Vibha Singh said:

    Yes I Have tested the example you  given on their respective Board and it worked properly but  it do not retain its value at power down in my case ...

    When you say "not retain its value at power down", what does this mean? Is the value in the hibernate memory being erased? Or does the device not stay in hibernate state?

     

    Vibha Singh said:

    As i already mentioned in third post of my that by using LM flash programmer i can unlock my processor .My issue was to finding the reason it has locked the processor so that i can avoid in future.

    As I mentioned before, I don't believe the device is getting locked. I think the device is being put in hibernate state continuously and hence it looks like it is locked.

    I would recommend that you start by using the working TivaWare example. Then remove a  block of code and test if the example continues to work as expected. Then remove the next block of code and test again until you hit the error or you are done with all the changes. Although this approach involves patience and hard work, it will allow you to learn which changes (you made) are causing the issue and hopefully will help you in the future.

    Thanks,

    Sai