Hi all, I'm newbee so please be patient reading my post :-). I have code as below (Which is working properly on FRD-KE04Z) but this development board is using external oscillatror. I have my own simple board based on KE04Z but I need to use internal oscillator. Please help me how to set it up KE04Z to use internal oscillator.
int main (void)
{
RTC_ConfigType sRTCConfig;
RTC_ConfigType *pRTCConfig = &sRTCConfig;
/* Perform processor initialization */
sysinit();
cpu_identify();
printf("\nLED exaple.\n");
/* configure RTC to 1Hz interrupt frequency */
pRTCConfig->u16ModuloValue = 9;
pRTCConfig->bInterruptEn = RTC_INTERRUPT_ENABLE; /* enable interrupt */
pRTCConfig->bClockSource = RTC_CLKSRC_1KHZ; /*clock source is 1khz*/
pRTCConfig->bClockPresaler = RTC_CLK_PRESCALER_100; /*prescaler is 100*/
RTC_SetCallback(RTC_Task);
RTC_Init(pRTCConfig);
GPIO_PinInit(GPIO_PTE7, GPIO_PinOutput);
while (1);
}
}
void RTC_Task(void)
{
GPIO_PinToggle(GPIO_PTE7);
printf("\nLED state changed.\n");
}
Hi Marcin Goluch,
Welcome to use kineits chip!
If you want to use the internal oscillator, you even don't need to configure the clock system.
Because the KE04 is using the the internal oscillator as the default clock.
Just modify you code like this:
int main (void)
{
unsigned int i;
GPIO_PinInit(GPIO_PTE7, GPIO_PinOutput);
while (1){
for(i=0;i<65535;i++);
GPIO_PinToggle(GPIO_PTE7);
}
}
}
You can try it on your side.
Wish it helps you!
If you still have question, please let me know!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi
To use the KE04 RTC from an internal clock you need to ensure that the code (the generated code possibly doesn't support all cases) does the following:
ICS_C1 |= (ICS_C1_IRCLKEN | ICS_C1_IREFSTEN); // enable the internal reference clock and allow it to continue running in stop mode
RTC_MOD = (((ICSIRCLK)/RTC_CLOCK_PRESCALER_1) - 1); // set the match value for 1s
RTC_SC = (RTC_SC_RTIE | RTC_SC_RTIF | _RTC_CLOCK_SOURCE | _RTC_PRESCALER); // clock the RTC from the defined clock source/pre-scaler and enable interrupt
whereby some of the parameters can be chosen, for example RTC_CLOCK_PRESCALER_1 can be 1,2,4,8,16,32, or 64
Links below give more details or a complete solution with Gregorian calendar implementation in case you prefer to complete a project optimally that is compatible with all Kinetis parts and be accurately simulated.
Regards
Mark
Kinetis for professionals: http://www.utasker.com/kinetis.html
http://www.utasker.com/docs/uTasker/uTasker_Time.pdf
http://www.utasker.com/kinetis/KL_RTC.html
http://www.utasker.com/kinetis/FRDM-KE02Z40M.html
http://www.utasker.com/kinetis/FRDM-KE04Z.html
http://www.utasker.com/kinetis/FRDM-KE06Z.html