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.

Calendar mode TM4C129, year and weekday error

Other Parts Discussed in Thread: ENERGIA, EK-TM4C1294XL

I've been using calendar mode just for hours, minutes and seconds but after i set the year and weekday and i check for return, i get just random values.

So there seems to be a bug with this feature or i'm just being silly?

This is my code using energia

void setup()
{
  Serial.begin(9600);
  // put your setup code here, to run once:
  
  //Enable Hibernate peripheral. I'm using Energia so i use F_CPU for geting the clock frequency
  HibernateEnableExpClk(F_CPU);
  HibernateRTCEnable();
  
  //We set a interrupt for the RTC after second. You can change the value
  HibernateRTCMatchSet(0,HibernateRTCGet()+1);
  HibernateIntRegister(HibernateHandler);
  HibernateIntEnable(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(temp); //<-- the struct declared
  
  //We change the hour, minutes and seconds
  temp->tm_year= 2014;
  temp->tm_wday=0;
  //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(temp);
  
}

void loop()
{
  //This is to take the "live" values that the RTC keeps updating into our struct
  HibernateCalendarGet(temp);
  Serial.print(temp->tm_year);
   Serial.print(':'); 
   Serial.println(temp->tm_wday);
  delay(1000);
}

  • Hello Luis,

    The function for HibernateCalendarSet and HibernateCalendarGet require the address of the structure be passed.

    HibernateCalendarSet(&temp);

    HibernateCalendarGet(&temp);

    For more detail you can refer to the TIVAWare example

    C:\ti\TivaWare_C_Series-2.1.0.12573\examples\boards\ek-tm4c1294xl\hibernate

    Regards

    Amit

  • Hi,

    @Amit, the o/p has right when writing only "temp".

    But I think the function HibernateCalendarSet() has a bug if using with TM4C129x - I have tested the above program with Energia and indeed has a bug. That is coming from the fact that RTC in this case has separate year, min, etc fields and for field "year" the above routine subtract "100" from the year, as in usual "1970 date origin" - there is no more the case. User manual states the year field should be in range 00..99, so writing 2014 for instance is wrong (equally when reading HibernateCalendarGet() add 100 to the year). The year field is seven bits long.

    Petrei

  • Gona try to test that, Thanks.

    Now i was also messing with the interrupt of the RTC using the HibernateRTCMatchSet() and it doesn't seem to work in tm4c1294. This was to make a interrupt every second. I used the example in TivaWare

    In tm4c123 it works fine.

    When i have more time i will do some more tests and say how it went but there's also a possible bug in that interrupt

  • Hello Petrei,

    Thanks for bringing the bug to our notice. It is good that we get such feedbacks.

    Hello Luis,

    The HibernateRTCMatchSet "would" not be a bugged code as I have used this function now for quite some time. If you could post the code for this I would be more than glad to help.

    Regarding the RTC Calendar Set and Get, I would get back on this thread,

    Regards

    Amit

  • right now i also have this to check for interrupts but it nevers seems to work. In tm4c123 it works

    #include "driverlib/hibernate.c"
    
    uint32_t seconds=0;
    
    void HibernateHandler(void)
    {
      //Use this to reset interrupt flag
      uint32_t ui32Status = HibernateIntStatus(1);
      HibernateIntClear(ui32Status);
      
      seconds++;
      Serial.println(seconds);
      
      //To keep the interrupt hapening every second you need this
      HibernateRTCMatchSet(0,HibernateRTCGet()+1);  
    }
    
    /*It's need a struct pointer of the type "tm" so i use new to do that. This type of struct is defined in the driverlib/hibernation
      you could also create it like this: tm temp; and then use &temp and temp.values in the fuctions                              
    */
    tm *temp = new tm;
    
    
    
    void setup()
    {
      Serial.begin(9600);
      // put your setup code here, to run once:
      
      //Enable Hibernate peripheral. I'm using Energia so i use F_CPU for geting the clock frequency
      SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
      HibernateEnableExpClk(F_CPU);
    
      
      //We set a interrupt for the RTC after second. You can change the value
      HibernateRTCMatchSet(0,HibernateRTCGet()+1);
      HibernateIntRegister(HibernateHandler);
      HibernateIntEnable(HIBERNATE_INT_RTC_MATCH_0);
      
      HibernateRTCEnable();  
    }
    
    void loop()
    {
    
    }
    

  • Hello Luis,

    I ran the test and was able to reproduce the issue. As it turned out the issue is because when the Calendar Mode is enabled the RTC MATCH interrupt is for Calendar Match. My bet is that the bits in HIBCALCTL registers for calendar enable are set as then cannot be simply reset.

    The Interrupt bit also mentions that if the calendar is enabled then the interrupt comes for a calendar match and not RTC Match. So what the application needs to do is to clear the Calendar Enable bit and then the RTC will interrupt. (That also I have tested)

    Regards

    Amit

  • I was actualy noticed yesterday that it existed a CalendarMatch and wanted to try exams are thoug this time of the year.

    Thanks for the info, nice work. 

    Still there is sometigh amiss here. I tested the code withot using Calender code and the interrupt still didn't work. Is it possible that RTC match just doesn't interrupt in parts with calendarmode?

  • Hello Luis,

    A sample code that I tried in CCS to enable RTC Match every 10 seconds from the current match. As I mentioned do make sure that the CALCTL.CALEN=0. A Board reset will not reset Hibernate, so this bit has to be cleared by SW/debugger

        HibernateEnableExpClk(ui32SysClock);
        HibernateRTCEnable();

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

        while(1)
        {
          HibernateIntClear(HIBERNATE_INT_RTC_MATCH_0);
          HibernateRTCMatchSet(0,HibernateRTCGet()+10);
          UARTprintf("%d:%d\n",sTime.tm_year,sTime.tm_hour);
          SysCtlDelay(5*ui32SysClock);
        }

    Regards

    Amit

  • Unfortunaly i have almost 0 knowledge how to use direct register access.

    How can i operate the register CALCTL?

     

    Thanks alot for the info about how the match interrupt works with calendar mode on

  • Hello Luis

    Please use the following

    HibernateCounterMode)HIBERNATE_COUNTER_RTC);

    This will remove the Calendar Mode and put it back in RTC Mode.

    Regards

    Amit