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.

RTC module with external resource

Other Parts Discussed in Thread: TM4C129XNCZAD, TM4C129LNCZAD

Hi.

I'm configuring the RTC module of TIVAC129 like:

    uint32_t ui32HIBCtl = 0;

    GPIOPinConfigure(GPIO_PP3_RTCCLK);
    GPIODirModeSet(GPIO_PORTP_BASE, GPIO_PIN_3, GPIO_DIR_MODE_HW);
    GPIOPadConfigSet(GPIO_PORTP_BASE, GPIO_PIN_3, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);

    ui32HIBCtl = HWREG(HIB_CTL);
    ui32HIBCtl |= HIB_CTL_OSCBYP;
    ui32HIBCtl |= HIB_CTL_CLK32EN;
    HWREG(HIB_CTL) = ui32HIBCtl;
    SystemDelayMilliSecond( 10 );

    HibernateRTCEnable();
    HibernateCounterMode(HIBERNATE_COUNTER_24HR);

    // Configure HIBCC for RTCOSC available, serve per buttare fuori il monitor della frequenza di oscillazione
    HWREG(HIB_CC) = HIB_CC_SYSCLKEN;

This configuration is because  I'm using an external source 32768 Hz cristal, as per pdf manual of TivaC129 TM4C129XNCZAD paragraph 7.3 I know that for external source must be:

CLK32EN=1,  OSCSEL=0, OSCBYP=1

The schematics is as below:

The issue is that I don't see any signal on Pin C12 (PP3).

Regards,

Marco Crivellari

  • Hello Marco,

    First of all you can replace

    GPIODirModeSet(GPIO_PORTP_BASE, GPIO_PIN_3, GPIO_DIR_MODE_HW);
    GPIOPadConfigSet(GPIO_PORTP_BASE, GPIO_PIN_3, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);

    with the following for reducing code overhead.

    GPIOPinTypeHibernateRTCCLK(GPIO_PORTP_BASE, GPIO_PIN_3);

    Now for the issue of the RTC clock not getting sourced from the TM4C129LNCZAD device. The schematic shows the RTCCLK is W16 ball pin which is PK7 and not C12 which is PP3.
  • Hi Amit,
    I know W16 is cutted. I'm using C12 because I have a 22 ohm resistor where I was able to put a probe.

    I can confirm that if the bit OSCBYP is zero I can observe a square waveform of 32768 but I think it's the internal one .

    Let me kow if I'm wrong.

    Regards,
    Marco
  • Hello Marco

    Thanks for the clarification regarding the pins. Since I do not have an external 32K single ended clock source, I will need to try with a crystal connected to a launchpad to double check your configuration. I will post an updated response.
  • Hello Marco

    If you are using a 32KHz crystal then the API call HibernateEnableExpClk is enough. In fact your code is working as expected with the crystal.
  • Hi Amit,
    Yes I know.

    But the fact is that with this piece of code:
    uint32_t ui32HIBCtl = 0;

    GPIOPinConfigure(GPIO_PP3_RTCCLK);
    GPIOPinTypeHibernateRTCCLK(GPIO_PORTP_BASE, GPIO_PIN_3);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);

    ui32HIBCtl = HWREG(HIB_CTL);
    ui32HIBCtl |= HIB_CTL_OSCBYP;
    ui32HIBCtl |= HIB_CTL_CLK32EN;
    HWREG(HIB_CTL) = ui32HIBCtl;
    while(!(HWREG(HIB_CTL) & HIB_CTL_WRC)) {}
    SystemDelayMilliSecond( 10 );

    HibernateRTCEnable();
    HibernateCounterMode(HIBERNATE_COUNTER_24HR);

    // Configure HIBCC for RTCOSC available, serve per buttare fuori il monitor della frequenza di oscillazione
    HWREG(HIB_CC) = HIB_CC_SYSCLKEN;

    I cannot see anything on my debug pin. Meanwhile if I commet the row:
    ui32HIBCtl |= HIB_CTL_OSCBYP;

    then I can see the cristal output .

    I have no idea about that.

    Regards
  • Hello Marco

    When using an external crystal the OSCBYP must be clear. If using a single ended clock source from a Clock Distribution device OSCBYP must be set. If you use an external crystal with OSCBYP set, then the crystal will not start correctly.
  • Ok Amit,
    I undestand now. I was wrong on what I read on the manual.

    If so, then the cristal works fine and the output is enabled.

    Just another question, I have a cristal with a frequency 32808 Hz , could you help me to understand how to correct the value for calendar mode with instruction HibernateRTCTrimSet( xxx )


    Thanks in advance
    Marco
  • Hello Marco

    Since the clock rate is higher than the nominal 32.768KHz, You need to apply a higher than 0x7FFF trim value. Now the manner in which this is computed is that, in calendar mode the trim is applied every 60 seconds. So the value to be added to 0x7FFF is (Measured Freq-32768)*60, i.e (32808-32768)*60 = 2400 or 0x960 needs to be added to 0x7FFF.
  • Hi Amit,

    just another simple question.

    Which is the right sequence on how to initialize the RTC, I mean:

    HibernateRTCTrimSet( rtcOffset );

    HibernateRTCEnable();

    HibernateCounterMode(HIBERNATE_COUNTER_24HR);

    or

     HibernateRTCEnable();

    HibernateRTCTrimSet( rtcOffset );

    HibernateCounterMode(HIBERNATE_COUNTER_24HR);

     

    Thanks in advance,

    Regards,

    Marco Crivellari

     

  • Hello Marco,

    It should be

    HibernateRTCTrimSet( rtcOffset );
    HibernateCounterMode(HIBERNATE_COUNTER_24HR);
    HibernateRTCEnable();