FRDM-KL25Z how to get RTC work properly

cancel
Showing results for 
Search instead for 
Did you mean: 

FRDM-KL25Z how to get RTC work properly

6,722 Views
pengliang
Contributor III

Hello,

I am new to freescale.

I start on FRDM-KL25Z evaluation board. I am using cw 10.3 with PE. I added a RTC components using PE. I would like to measure the current consumed by RTC module. what I need to do is just run RTC keep time counting on. I set the time, and using the RTC_GetTime(RTC1_DeviceData, rtc) function which suppose to get the second, minute, hour, date, day, month, year values and stores into rtc object. however, when I run this in debug mode(using OpenSDA USB), I checked the rtc object. the value is just same as initial value. I dont know what is wrong. I did automatic initialize rtc device, and call  rtc_enable() function as well.

Can anyone give me a hint?

Thanks in advance.

Labels (1)
12 Replies

923 Views
subramaniantr
Contributor I

Dear Peng Liang

I have to generate an hourly interrupt and wake up the KL05 from VLLSx mode. It's mentioned using 32k crystal instead of 8M crystal for RTC. I guess it means the processor ll run at 32kHz clock. I would like to know how RTC could use this clock. Could anything be done for preventing RTC registers from getting reset due to VLLSx wakeup interrupt?

0 Kudos

923 Views
heliosfa
Contributor II

I know this thread is a couple of months old, but I have found a way to get the RTC working properly without needing to swap crystals, etc.  By default, there is no link between the internal 32K reference and the RTC clock input HOWEVER it is possible to route the internal 32K out to PTC3 and bring it back in on the RTC clock input on PTC1.

You can configure the required settings in Codewarrior/Processor Expert on the CPU component (in expert mode) as follows:

  • set RTC Clock Input to "Enabled".  This sets PTC1 as an input for a clock source.
  • set MCGIRCLK source to "slow" in "Clock Source Settings" > "Clock Source Setting 0" > "Internal Reference Clock"
  • set ERCLK32K Clock Source to "RTC Clock Input" in "Clock Source Settings" > "Clock Source Setting 0" > "External Reference Clock"
  • Enable "CLKOUT pin control" in "Internal Peripherals" > "System Integration Module"
    • set "CLKOUT pin" to "PTC3/LLWU_P7/..."
    • Set "CLKOUT pin output" to "MCGIRCLK"
    • This routes the internal 32K reference oscillator out to pin PTC3

On the RTC, set the "Clock Source" to "ERCLK32K".

And don't forget to put a wire link between PTC1 and PTC3 :smileyhappy:

Low and behold, you have an internally-sourced 32K signal to run the RTC on the Freedom board without needing any external devices or needing to change any crystals.

923 Views
pradyumnakammar
Contributor III

Hi Graeme Bragg,

i tried to do above but failed,

have you done any Projects which involves RTC if you could share it would be very helpfull !!

0 Kudos

923 Views
GregC
NXP Employee
NXP Employee

Just for information

The new FRDM-KL05Z freedom board for Kinetis-L KL05 MCUs will have an external 32KHz crystal on board.

0 Kudos

923 Views
pengliang
Contributor III

I figured out~~

Thanks for replys

0 Kudos

923 Views
antoineodonne
Contributor II

Hello Peng Liang,

It seems that I am facing the same problem,

what solution did you find?

And by the way can I ask you what is the consumption you measure for RTC running?

Thank you and regards.

Antoine

0 Kudos

923 Views
pengliang
Contributor III

I guess you need to install 32k crystal instead of 8M.

0 Kudos

923 Views
toñohernández
Contributor III

Hi there!

Have you tried to get started with our FRDM-KL25Z Sample Code Package?

It has a Sample Code Guide with step-by-step instructions to download tools, load projects, configure the hardware, run the code, and use the OpenSDA mass-storage flash programmer to program pre-compiled binaries onto your board... and some other goodies you can find useful.

Let me know if works for you!

0 Kudos

923 Views
JimDon
Senior Contributor III

Too bad they seem to have forgotten the code warrior projects that are supposed to be there in the cw directory.

0 Kudos

923 Views
pengliang
Contributor III

I tried some the samples. There is no one related to RTC setting. and I notice, RTC requires external crystal 32k, the evaluation board has a 8MHz external crystal populated. How can this achieve RTC running?

0 Kudos

923 Views
adriansc
Contributor IV

Hi,

In the Sample Code Package for FRDM-KL25 in drivers folder you can find and example, there is the source and its header file for RTC configuration:

Kinetis L Sample Code\kl25_sc\kl25-sc-baremetal\src\drivers

It is all commented so you can follow step by step the code.

Hope this helps.

0 Kudos

923 Views
pengliang
Contributor III

Does anyone know about how to get RTC running properly?

0 Kudos