How to use RTC on FRDM-KL25Z board.

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

How to use RTC on FRDM-KL25Z board.

Jump to solution
1,311 Views
yasuhikokoumoto
Senior Contributor I

Hi all,

I am working on FRDM-K20D50M and FRDM-KL25Z boards.

Also I would like to use RTC to make MCU woken up from the low power mode.

In the FRDM-K20D50M case, it seems to be no problem.

However, in the FRDM-KL25Z case, the MCU hangs up when RTC_CR[OSCE] bit is set.

I think the reason would be because no 32kHz OSC was not equipped on the FRDM-KL25Z board,

For your reference, I will show my code below.

void RTC_init(void)
{
    SIM_SCGC6 |= SIM_SCGC6_RTC_MASK;// by this statement, hard fault becomes not occur

    RTC_CR |= RTC_CR_OSCE_MASK; //<= hanged up at this statement
    RTC_TPR = 0;
    RTC_TSR = 0xFFFFFFFF-5;
    RTC_TAR = 0;
    while((RTC_SR &( RTC_SR_TOF_MASK|RTC_SR_TIF_MASK))!=0);
    RTC_SR |= RTC_SR_TCE_MASK;  //<= although enabled RTC, count does not count up
}

If 'RTC_CR |= RTC_CR_OSCE_MASK' does not exist, the hanged-up does not occur.

However the overflow interrupt neither occur.

Could anyone let me know how to use RTC on FRDM-KL25Z board?

Otherwise, can RTC not actually be used on FRDM-KL25Z board?

Best regards,

Yasuhiko Koumoto.

Tags (3)
0 Kudos
1 Solution
679 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Yasuhiko Koumoto,


The RTC clock can be from the following sources, so you have to cogfiure which is for RTC before using.

1.png


Have a great day,
Kan

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

View solution in original post

0 Kudos
2 Replies
680 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Yasuhiko Koumoto,


The RTC clock can be from the following sources, so you have to cogfiure which is for RTC before using.

1.png


Have a great day,
Kan

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

0 Kudos
679 Views
yasuhikokoumoto
Senior Contributor I

Hi Kan-san,

thank you very much.

according to your advice, I used LPO clock instead of 32kHz oscillator, and I succeeded to use RTC on FRDM-KL25Z board.

That is, I no longer use

     

         RTC_CR |= RTC_CR_OSCE_MASK

but use

          SIM_SOPT1 &= ~SIM_SOPT1_OSC32KSEL_MASK;

          SIM_SOPT1 |=  SIM_SOPT1_OSC32KSEL(3); // 1kHz LPO

descriptions.

Best regards,,

Yasuhiko Koumoto.