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.
Solved! Go to Solution.
Hi Yasuhiko Koumoto,
The RTC clock can be from the following sources, so you have to cogfiure which is for RTC before using.
Have a great day,
Kan
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Yasuhiko Koumoto,
The RTC clock can be from the following sources, so you have to cogfiure which is for RTC before using.
Have a great day,
Kan
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
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.