This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LCP4357 RTC reset and calibration

Hi
I have an evaluation board based on LPC4357 and works well but during RTC_init it takes a long time (I think about 5 to 6 seconds ) to init.

here is my code to init which is exactly the same as CMSIS source code:


void RTC_Init (LPC_RTC_Type *RTCx)
{
        CHECK_PARAM(PARAM_RTCx(RTCx));
        LPC_CREG->CREG0 &= ~((1<<3)|(1<<2));
        LPC_CREG->CREG0 |= (1<<1)|(1<<0);
        LPC_SCU->SFSCLK_0 = 1 | (0x3<<2);
        LPC_CGU->BASE_OUT_CLK = (CGU_CLKSRC_32KHZ_OSC<<24) |(1<<11);
        do
        {
                /* Reset RTC clock*/
                RTCx->CCR = RTC_CCR_CTCRST | RTC_CCR_CCALEN;
        }
        while(RTCx->CCR!=(RTC_CCR_CTCRST | RTC_CCR_CCALEN));
        do
        {
                /* Finish resetting RTC clock*/
                RTCx->CCR = RTC_CCR_CCALEN;
        }
        while(RTCx->CCR != RTC_CCR_CCALEN);
        RTCx->ILR = RTC_IRL_RTCCIF | RTC_IRL_RTCALF;
        RTCx->CIIR = 0x00;
        RTCx->AMR = 0xFF;
        RTCx->CALIBRATION = 0x00;
}

about 3 seconds for first do-while and 3 seconds for the next one.

Is it usual?

  • I don't use that specific processor, but the RTC startup is normally lightning-fast with other LPC ARM chips.

    Have you verified that you have a correct RTC crystal, and looked at how it spins up? For some reason, it doesn't sound like you get a stable 32768Hz to the chip.

  • Hi
    I know what you mean ... I had the same experience on LPC1768, LPC1788, LPC2378 and any other NXP products and they were so fast but this one is too different previous ones.

    About 23768Hz crystal ... good idea ... I'll check it out.

    thanks

  • Just another question too. I assume this chip has a dedicated supply pin for the RTC - is that pin powered?

  • Yes it's exactly same as MCB4300

    My battery is about 3Volt right now.
    I have changed rtc crystal and capacitors but it doesn't have any effect.

    I've tried to comment those do-while loops ... it works but never generates interrupt.

    in my source code every second it generates an interrupt like this:

    
    void InitRTC(void){
    
            EVRT_SetUpIntSrc(LPC_EVENTROUTER,EVRT_SRC_RTC,DISABLE);
            RTC_Init(LPC_RTC);
            RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);
            EVRT_Init(LPC_EVENTROUTER);
            EVRT_ConfigIntSrcActiveType(LPC_EVENTROUTER,EVRT_SRC_RTC,EVRT_SRC_ACTIVE_RISING_EDGE);
            EVRT_SetUpIntSrc(LPC_EVENTROUTER,EVRT_SRC_RTC,ENABLE);
            EVRT_ClrPendIntSrc(LPC_EVENTROUTER,EVRT_SRC_RTC);
            NVIC_EnableIRQ(EVENTROUTER_IRQn);
            NVIC_SetPriority(EVENTROUTER_IRQn, ((0x01<<3)|0x01));
            NVIC_EnableIRQ(EVENTROUTER_IRQn);
            RTC_Cmd(LPC_RTC, ENABLE);
    }