LPC1547 RTC problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1547 RTC problem

671 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by AlexandreR on Wed Jul 23 02:54:14 MST 2014
Hi everybody!

I have a big problem, we produced 500 boards with a LPC1547 embedded, and on half the RTC doesn't work.
The 32khz oscillates, I think it's not a pb from the XTAL.

my code to initiate the RTC:

void RTC_Init( void )
{
LPC_SYSCON->RTCOSCCTRL    |=  BIT_0;
LPC_SYSCON->SYSAHBCLKCTRL0 |= (BIT_23);
LPC_RTC->CTRL|= RTC_OFD ;
LPC_RTC->CTRL&= ~ RTC_SWRESET;
while(LPC_RTC->CTRL&RTC_SWRESET);
LPC_RTC->CTRL |= RTC_ALARM_1HZ | RTC_EN;
NVIC_EnableIRQ(RTC_ALARM_IRQn );
}

The LPC_RTC->CTRL is always equal to 0x82 ie

"Fail. RTC oscillator fail detected. Clear this flag after the following power-up. Writing a 1 clears this bit."

Have you an idea?

Thanks
Labels (1)
0 Kudos
2 Replies

571 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mubes on Wed Jul 30 02:48:43 MST 2014
Hi,

This code definately works (you can probably remove the vTaskDelay in rtsSetTime, I just had it there for tidyness;

// ============================================================================================
uint32_t rtcGetTime(void)

{
    uint32_t r;

    /* Keep reading until we get something stable back */
    while (r!=LPC_RTC->COUNT) r=LPC_RTC->COUNT;

    return r;
}
// ============================================================================================
void rtcSetTime(uint32_t timeSet)

{
    LPC_RTC->CTRL&=~(1<<0);  /* Take part out of reset if it was in reset */
    vTaskDelay(10);
    LPC_RTC->CTRL&=~(1<<7);  /* Disable the RTC while we load the value */
    LPC_RTC->COUNT=timeSet;
    LPC_RTC->CTRL|=(1<<7);  /* Enable the RTC */
    LPC_RTC->CTRL&=~(1<<1);  /* Clear the osc fail flag */
}
// ============================================================================================
void rtcUnset(void)

{
    LPC_RTC->CTRL&=(1<<0);
}
// ============================================================================================
BOOL rtcRunning(void)

{
    return (LPC_RTC->CTRL&(1<<7));
}
// ============================================================================================
void rtcInit(void)

{
    LPC_SYSCON->SYSAHBCLKCTRL0|=(1<<23); /* Allow access to RTC registers */
}
// ============================================================================================


Hope it's useful. It should at least help you remove code from the equation of what's going wrong.  In my experience the oscillator is a bit fragile at spinning up so be careful with your capacitor choices (putting a scope probe on one leg can be enough to start the thing up, so seeing it running on a scope is no certainty that it's _always_ running).

DAVE
0 Kudos

571 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mc on Fri Jul 25 09:40:08 MST 2014
Hi AlexandreR,
Could you please also post your schematic here?
0 Kudos