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/TM4C1294NCPDT: Not satisfying " if(ui32Status & HIBERNATE_INT_RTC_MATCH_0) " condition.

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

Hii

In my code every 5 sec it will come out from hibernation due to HIBERNATE_WAKE_RTC.

When I observed, HIB(bar) signal is low for 5 sec and after 5 sec it's coming from the hibernation but it's not satisfying "if(ui32Status & HIBERNATE_INT_RTC_MATCH_0);" condition.

 In If(ui32Status & HIBERNATE_INT_RTC_MATCH_0), we are transferring data through UART but data is not receiving in receiver side.

You can go through the below attached code..

#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <time.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/systick.h"
#include "utils/uartstdio.h"
#include "utils/uartstdio.c"
#include "driverlib/uart.h"
#include "inc/hw_uart.h"
#include "driverlib/timer.h"
#ifdef DEBUG
void__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif

/**
 * main.c
 */
uint32_t ui32SysClock,ui32Status=0,flag=1,arr1[64]={0};
uint32_t g_ui32MonthIdx,g_ui32DayIdx,g_ui32YearIdx,g_ui32HourIdx,g_ui32MinIdx;

void DateTimeDefaultSet(void)
{
    g_ui32MonthIdx = 6;
    g_ui32DayIdx = 7;
    g_ui32YearIdx = 119;
    g_ui32HourIdx = 17;
    g_ui32MinIdx = 15;

}

void DateTimeSet(void)
{
    struct tm sTime;
    HibernateCalendarGet(&sTime);

    sTime.tm_hour = g_ui32HourIdx;
    sTime.tm_min = g_ui32MinIdx;
    sTime.tm_mon = g_ui32MonthIdx;
    sTime.tm_mday = g_ui32DayIdx;
    sTime.tm_year = g_ui32YearIdx;

    HibernateCalendarSet(&sTime);
}

uint32_t GetDaysInMonth(uint32_t ui32Year, uint32_t ui32Mon)
{
    if(ui32Mon == 1)
    {
        if((ui32Year % 4) == 0)
            return 29;
        else
            return 28;
    }
    else if((ui32Mon == 3) || (ui32Mon == 5) || (ui32Mon == 8) || (ui32Mon == 10))
        return 30;
    return 31;
}


void GetCalendarMatchValue(struct tm* sTime)
{
    uint32_t ui32MonthDays;
    HibernateCalendarGet(sTime);
    sTime->tm_sec += 5;
    if(sTime->tm_sec > 59)
    {
        sTime->tm_sec -= 60;
        sTime->tm_min++;
    }
    if(sTime->tm_min > 59)
    {
        sTime->tm_min -= 60;
        sTime->tm_hour++;
    }
    if(sTime->tm_hour > 23)
    {
        sTime->tm_hour -= 24;
        sTime->tm_mday++;
    }
    ui32MonthDays = GetDaysInMonth(sTime->tm_year, sTime->tm_mon);
    if(sTime->tm_mday > ui32MonthDays)
    {
        sTime->tm_mday -= ui32MonthDays;
        sTime->tm_mon++;
    }
    if(sTime->tm_mon > 11)
    {
        sTime->tm_mon -= 11;
        sTime->tm_year++;
    }

    if(sTime->tm_year > 99)
        sTime->tm_year -= 100;
}

void Hibernate_Init(void)
{
	 struct tm sTime;
	 SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
	 HibernateEnableExpClk(ui32SysClock);

	 HibernateIntClear(HIBERNATE_INT_PIN_WAKE | HIBERNATE_INT_RTC_MATCH_0);

     HibernateRTCEnable();
     HibernateCounterMode(HIBERNATE_COUNTER_24HR);
     HibernateDataGet(arr1,8);
     if(arr1[0] != 1)
     {
    	 DateTimeDefaultSet();
    	 DateTimeSet();
    	 arr1[0] = 1;
    	 HibernateDataSet(arr1,8);
     }

     GetCalendarMatchValue(&sTime);
     HibernateCalendarMatchSet(0, &sTime);

}
void Uart_Init(void)
{
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
	GPIOPinConfigure(GPIO_PB0_U1RX);
	GPIOPinConfigure(GPIO_PB1_U1TX);
	GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	UARTConfigSetExpClk(UART1_BASE, ui32SysClock , 115200,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
}

int main(void)
{
      ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

      Hibernate_Init();
      ui32Status = HibernateIntStatus(0);
      HibernateIntClear(ui32Status);
      HibernateWakeSet(HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC);

      if(ui32Status & HIBERNATE_INT_RTC_MATCH_0)
      {
    	  flag=0;
    	  Uart_Init();
    	  unsigned int i;
    	  for(i=0;i<10;i++)
    	  {
    		  UARTCharPut(UART1_BASE,'M');
    	  }
        flag=1;
      }

      while(1)
      {
    	  if(flag)
    	  {
    		  HibernateRequest();
    	  }
      }
}

Kindly suggest some solution so that I can proceed further.

Thanks & regard

Anamika