Reply
Posts: 8
Registered: ‎05-24-2017
Accepted Solution

EFM32 RTCC wrong time

Hi

I explore the EFM32PG12 with the SDK3402A. When I call the RTCC with aTicks of 4098 it should call the interrupt after 1 second (244us*4098). But the interrupts is called after about 30 seconds!

Something must be wrong with my initialization or how I start the RTCC. Replacing the LFRCO with the LFX0 behaves the same.

 

Please can someone help me? Many thanks.

 

The initialization code is:

    // Enable clock to the interface with low energy modules.
    CMU_ClockEnable(cmuClock_HFLE, true);

    // Select LFRCO as clock source for LFE

    // -> RTCC
    // LFE is used for RTC. Should be set to ULFRCO in other EM4H mode.  
    CMU_ClockSelectSet(cmuClock_LFE, cmuSelect_LFRCO);

    // Enable Clock Module
    CMU_ClockEnable(cmuClock_RTCC, true);

    // RTC configuration structure
    RTCC_Init_TypeDef rtcInit =
    {
        false, // Don't counting when initialization is completed
        false, // Disable timer counting during debug halt. 
        false, // Disable precounter wrap on channel 0 CCV value. (Wraps on OV)
        false, // Disable counter wrap on channel 1 CCV value. (Wraps on OV)
        rtccCntPresc_8, // Set prescaler to 8 (244us)
        rtccCntTickPresc, // Counter increments according to prescaler value
        false, // Disable LFXO failure detection
        rtccCntModeNormal, // Use RTCC in normal mode, not calendar mode
        false // no lap year
    };
    RTCC_Init(&rtcInit);

    // Set up Compare Channel
    RTCC_CCChConf_TypeDef initRTCCCompareChannel =
    {
        rtccCapComChModeCompare, // Use Compare mode
        rtccCompMatchOutActionPulse,// Don't care
        rtccPRSCh0, // PRS not used
        rtccInEdgeNone, // Capture Input not used
        rtccCompBaseCnt, // Compare with Base CNT register
        0, // Compare mask
       rtccDayCompareModeMonth // Don't care
    };
   RTCC_ChannelInit(1, &initRTCCCompareChannel);
   RTCC_EM4WakeupEnable(true);

   // Disable Interrupts
   RTCC_IntDisable(_RTCC_IF_MASK);
   RTCC_IntClear(_RTCC_IF_MASK);

   // Set lowest priority (7) like systick
   NVIC_SetPriority (RTCC_IRQn,7);
   NVIC_ClearPendingIRQ(RTCC_IRQn);

 

The timer is started with the following sequence:
    RTCC_ChannelCCVSet(1, aTicks);
    RTCC->CNT = _RTCC_CNT_RESETVALUE;
    //  Start timer and enable interrupt
    RTCC_Enable(true);
    RTCC_IntClear(_RTCC_IF_MASK);
    NVIC_ClearPendingIRQ(RTCC_IRQn);
    RTCC_IntEnable(RTCC_IF_CC1);
    NVIC_EnableIRQ(RTCC_IRQn);

 

Highlighted
Posts: 8
Registered: ‎05-24-2017

Re: EFM32 RTCC wrong time

The code above is correct.

 

The cause of the problem is the call of the function DisplayInitialize(); It uses the RTCC to calibrate the delay function, but does not correctly restore the clocks.

Posts: 241
Registered: ‎07-27-2016

Re: EFM32 RTCC wrong time

Hi @benny,

 

This KB article talks about the limitations of the RTCC when using the memory LCD on the STK and how to work around it - http://community.silabs.com/t5/32-bit-MCU-Knowledge-Base/RTC-RTCC-limitations-on-STKs-with-the-memor...

 

Please let me know if that helps the issue you are seeing.

 

Best,

 

Manasa

 

Posts: 8
Registered: ‎05-24-2017

Re: EFM32 RTCC wrong time

Hi

Mani thanks for your answer.

I know the article and I used it to create the test code.

To clarify the solution.

When I use the following sequence

 

    Display initialization...

 

    CMU_ClockEnable(cmuClock_HFLE, true);
    CMU_ClockSelectSet(cmuClock_LFE, cmuSelect_LFRCO);
    CMU_ClockEnable(cmuClock_RTCC, true);

 

    RTCC initialization...

 

The timing of the RTCC is about 30 times too slow. It looks like the timer is clocked with 1kHz.

 

     RTCC initialization...

 

    CMU_ClockEnable(cmuClock_HFLE, true);
    CMU_ClockSelectSet(cmuClock_LFE, cmuSelect_LFRCO);
    CMU_ClockEnable(cmuClock_RTCC, true);

 

    Display initialization...

 

The timing of the RTCC is correct and the display works too.