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/TM4C129ENCPDT: Issue setting RTC Date

Part Number: TM4C129ENCPDT

Tool/software: Code Composer Studio

Hello Sir,

I Have Problem regarding RTC Code.

In My Code, Hour, Minute, Second, Month and Year Working Properly. Only Problem in Setting or Reading in RTC DATE.

1 to 7 and 16 to 23 Date Read writes correctly. But Problem is that when i am trying to set 8 to 15 or 24 to 31 Date in RTC, then it display =  Enter Date – 8.

For Example, if I try to set 9 then it display = 9- 8 = 1.

Same way, if I try to set 26 then it display = 26- 8 = 18. And So on.

 

                               

Software:            Code Composer Studio 5.4.0

Controller:          TM4C129 – ENCPDT13.

 

1.) RTC Initialize Function. Only 1 timed Called.

 

void Initialize_RTC(void)

{

 SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);      

HibernateEnableExpClk(g_ui32SysClock);

HibernateRTCEnable();

HibernateCounterMode(HIBERNATE_COUNTER_24HR);

}

 

 

2.) RTC SET Function. This function is called when RTC Time Set.

 

  • Note : I have Always set all parameters  (Set_Min, Set_Hour, Set_Sec , Set_Day, Set_Month, Set_Year) of RTC when need to Set RTC Time.

 

void Set_Rtc_Data(void)

{

       struct tm RTC_Temp;

 

       RTC_Temp.tm_hour= Set_Min;

       RTC_Temp.tm_min = Set_Hour;

       RTC_Temp.tm_sec = Set_Sec;

       RTC_Temp.tm_mday= Set_Day;

       RTC_Temp.tm_mon =  Set_Month;

       RTC_Temp.tm_year = Set_Year;

             

       HibernateCalendarSet(&RTC_Temp);

}

 

 

3.) RTC Read Function. Every second this function Called

              

void Get_RTC_Data(void)

{

       struct tm RTC_Temp;

 

       HibernateCalendarGet(&RTC_Temp);

 

       RTC_Sec = RTC_Temp.tm_sec;

       RTC_Min = RTC_Temp.tm_min;

       RTC_Hour = RTC_Temp.tm_hour;

       RTC_Day = RTC_Temp.tm_mday;

       RTC_Month = RTC_Temp.tm_mon;

       RTC_Year = RTC_Temp.tm_year;

 

}

 

  • I was unable to recreate your problem. Did you initialize all the elements of the tm structure?

    struct tm
    {
        int tm_sec;      /* seconds after the minute   - [0,59]  */
        int tm_min;      /* minutes after the hour     - [0,59]  */
        int tm_hour;     /* hours after the midnight   - [0,23]  */
        int tm_mday;     /* day of the month           - [1,31]  */
        int tm_mon;      /* months since January       - [0,11]  */
        int tm_year;     /* years since 1900                     */
        int tm_wday;     /* days since Sunday          - [0,6]   */
        int tm_yday;     /* days since Jan 1st         - [0,365] */
        int tm_isdst;    /* Daylight Savings Time flag           */
    };
    

    I have attached a project that does a static initialization and then prints the current date and time. Use Code Composers "File" "Import" commands to add this project to your workspace.

    /cfs-file/__key/communityserver-discussions-components-files/908/Calendar.zip