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.

AM335x RTC clock initialization

Other Parts Discussed in Thread: AM3352

Hello,


we use RTC peripheral of the AM3352 processor. Following initialization sequence is executed:

   /* Performing the clock configuration for RTC. */
   moduleClkConfig();

   /* Disabling write protection for RTC registers */
   HWREG(SOC_RTC_0_REGS + RTC_KICK0) = RTC_KICK0R_KEY;
   HWREG(SOC_RTC_0_REGS + RTC_KICK1) = RTC_KICK1R_KEY;

   /* Selecting Internal Clock source for RTC by */
   /* clearing the 32KCLK_SEL bit in Oscillator register. */
   HWREG(SOC_RTC_0_REGS + RTC_OSC) &= ~(RTC_OSC_32KCLK_SEL);

   /* Enabling RTC to receive the Clock inputs. */
   HWREG(SOC_RTC_0_REGS + RTC_OSC) &= ~(RTC_OSC_32KCLK_EN);
   HWREG(SOC_RTC_0_REGS + RTC_OSC) |= (RTC_32KCLK_ENABLE & RTC_OSC_32KCLK_EN);

   /* Perform dummy reads until clock is available */
   for(i=0; i<1000; i++)
   {
      status = HWREG(SOC_RTC_0_REGS + RTC_STATUS);
   }

   /* Enable the RTC module. */
   HWREG(SOC_RTC_0_REGS + RTC_CTRL) &= ~(RTC_CTRL_RTCDISABLE);

We would like to user the internal clock source derived from PLL. In the initialization sequence we inserted some dummy reads. If we not insert this, the first set of the time and date information is excepted well.
So is there any timing requirements of clock before the RTC module can be enabled?

Thanks for your assistance in advance.

Regards,

Andreas

  • Hi Andreas,

    The correct steps are given in section 20.3.4 of the AM335X TRM Rev. K.

  • Hello,


    i changed my RTC initialization to following sequence:

       /* Performing the clock configuration for RTC. */
       moduleClkConfig();
    
       /* Enable the RTC module. */
       /* PRQA S 0303 1 */
       HWREG(SOC_RTC_0_REGS + RTC_CTRL) &= ~(RTC_CTRL_RTCDISABLE);
    
       /* Selecting Internal Clock source for RTC by */
       /* clearing the 32KCLK_SEL bit in Oscillator register. */
       /* PRQA S 0303 1 */
       HWREG(SOC_RTC_0_REGS + RTC_OSC) &= ~(RTC_OSC_32KCLK_SEL);
    
       /* Enabling RTC to receive the Clock inputs. */
       /* PRQA S 0303 2 */
       HWREG(SOC_RTC_0_REGS + RTC_OSC) &= ~(RTC_OSC_32KCLK_EN);
       HWREG(SOC_RTC_0_REGS + RTC_OSC) |= (RTC_32KCLK_ENABLE & RTC_OSC_32KCLK_EN);
    
       /* Disabling write protection for RTC registers  */
       HWREG(SOC_RTC_0_REGS + RTC_KICK0) = RTC_KICK0R_KEY;
       HWREG(SOC_RTC_0_REGS + RTC_KICK1) = RTC_KICK1R_KEY;
    
       /* Init default values */
       timeToSet.hour = 0;
       timeToSet.minute = 0;
       timeToSet.second = 0;
    
       dateToSet.year = 2000;
       dateToSet.month = 1;
       dateToSet.dayOfMonth = 1;
       dateToSet.dayOfWeek = RTC_DAY_OF_WEEK_SUNDAY;
    
       centuryMillenniumYears = 2000;
    
       RTC_setTimeAndDate(&dateToSet, &timeToSet);
    
       HWREG(SOC_RTC_0_REGS + RTC_CTRL) |= RTC_CTRL_RUN; 

    But in this case the RTC does not running. I also do not understand the described sequence in chapter 20.3.4, because it is different compared with the Starterware example code:

        /* Performing the System Clock configuration for RTC. */
        RTCModuleClkConfig();
        
        /* Disabling Write Protection for RTC registers.*/
        RTCWriteProtectDisable(SOC_RTC_0_REGS);
    
        /* Selecting Internal Clock source for RTC. */
        RTC32KClkSourceSelect(SOC_RTC_0_REGS, RTC_INTERNAL_CLK_SRC_SELECT);
    
        /* Enabling RTC to receive the Clock inputs. */
        RTC32KClkClockControl(SOC_RTC_0_REGS, RTC_32KCLK_ENABLE);
    
        /* Enable the RTC module. */
        RTCEnable(SOC_RTC_0_REGS);
    
        UARTPuts("SitaraWare AM335x RTC Application.\r\n", -2);
    
        /* Receiving Time related information from the user. */
        userTime = UserTimeInfoGet();
    
        /* Receing Calendar relatd information from the user. */
        userCalendar = UserCalendarInfoGet();
        
        /* Programming calendar information in the Calendar registers. */
        RTCCalendarSet(SOC_RTC_0_REGS, userCalendar);
    
        /* Programming the time information in the Time registers. */
        RTCTimeSet(SOC_RTC_0_REGS, userTime);
        
        /* Set the 32KHz counter to run. */
        RTCRun(SOC_RTC_0_REGS);
  • Hi Andreas,

    On this forum we support only the TI distributed Linux EZSDK. I suggest you ask questions about Starterware on the dedicated forum: http://e2e.ti.com/support/embedded/starterware/f/790.aspx