How to use LPC4357 RTC?

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

How to use LPC4357 RTC?

1,343 Views
uaz
Contributor II

Hi,

Is there any guide on how to use LPC4357 RTC correctly?

I'm having many issues with the RTC:

1. Using 32.768khz crystal: everytime I update RTC time, the cpu will become glitchy. My freertos will freeze for 1-2 seconds. I tried without RTC, no issue with my freertos. Then I realised about the errata which might cause this issue.

2. Using external 32.768khz oscillator (connected to RTCX1, RTCX2 open): Unable to countdown LPC_ATIMER->DOWNCOUNTER. Looks like rtc peripheral is not getting the clock signal

How do I configure external the external oscillator? I can't find any info, and I just use the same CREG0 clock setting as the crystal.

Can you recommend an external oscillator that can work straight away with this MCU?

Labels (1)
Tags (3)
0 Kudos
7 Replies

1,093 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
To provide the fastest possible support, I'd highly recommend you to refer to the periph_rtc in the LPC4357's LPCOpen library, this demo shows how to use the RTC, generate periodic interrupts,

LPCOpen Software for LPC43XX | NXP 
and use the alarm interrupt.
Hope it helps.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,093 Views
uaz
Contributor II

I've tried the example from lpcOpen. Results:

1. 32kHz crystal: working

2. 32kHz oscillator: Stuck in the ATIMER downcount loop during initialization. Seems like RTC peripheral is not getting 32khz clock

I also found that using 32kHz crystal + RTC is buggy when I use Watchdog at the same time. 

You can try the following code:

[C] LPC4357 RTC + Wwatchdog - Pastebin.com 

The program can run the first time, but it won't run the second time after I click 'Restart' button.

0 Kudos

1,092 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

Thanks for your reply.
1. The 'bug' may cause the RTC to fail to run when using the external 32kHz oscillator, please follow the workaround to fix it.

pastedImage_5.png
2. Whether you mean that the demo ([C] LPC4357 RTC + Wwatchdog - Pastebin.com ) only can work once and it won't run anymore after reset.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,093 Views
uaz
Contributor II

Hi,

1. I've tried the workaround:

  - Don't use the pin 180 and 181 of LQFP208: Same issue. If I use Watchdog along with RTC, the application will reset.

  - Use external oscillator: RTC won't work at all because the 32kHz signal is not detected.

2. If you try [C] LPC4357 RTC + Wwatchdog - Pastebin.com  your application will not run for second time ( after clicking restart, and then run button). 

I sense that writing to RTC register (even after waiting 2 seconds during initialization) will cause the some glitch that slows down the processor, thus watchdog reset will trigger.

If I disable watchdog reset option, I will enter watchdog timeout interrupt when running with RTC enabled. If RTC is not enabled, I will not enter watchdog timeout. Seems like RTC is causing the main cpu to become unstable.

0 Kudos

1,093 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

Thanks for your reply.
I've run the application on my board: MCB4357(please check the attachment), it can work well after clicking the restart button, it doesn't encounter the issue you mentioned.

pastedImage_2.png

Fig 1 MCB4357 board

pastedImage_1.png

Fig 2 Testing

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,093 Views
uaz
Contributor II

Strange. I have confirmed that my mcu will stall/glitch whenever I write to the RTC registers. It probably caused by the board design since I'm using my own board.

Now I would like to try external oscillator but I need more info how to provide external clock to the internal rtc. I did the following and both did not work:

1. RTCX1 signal: External oscillator with DC offset. ATIMER->DOWNCOUNT will not count down. No clock signal detected on RTCX2.DS0013.PNG

2. RTCX1 signal: External oscillator without DC offset. ATIMER->DOWNCOUNT will not count down too. In addition, debugging will crash when I click 'restart'. No clock signal detected on RTCX2.

DS0014.PNG

Do you have suggestion on recommended external oscillator parts?

Any particular setting that I need to set if using external oscillator?

Thanks

0 Kudos

1,093 Views
jeremyzhou
NXP Employee
NXP Employee

Hi uaz,

Hi,
Thanks for your reply.
According to the datasheet, RTCX1 signal meets the amplitude's requirement, so please check the coupling capacitance by yourself.

pastedImage_14.png
Actually, I have no idea except for the aforementioned workaround, maybe you can share the schematic about the external oscillator connection.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos