I have created a clone of the Kinetis twrk60f120m BSP. I am using CW 10.6 and MQX 4.1.1.
My target does use an RTC, so VBAT is not supplied with power.
Referring to https://community.freescale.com/thread/304195, I did set BSPCFG_ENABLE_RTCDEV to 0.
However in \Freescale\Freescale_MQX_4_1\mqx\source\bsp\<mybsp>\bsp_cm.c in the function __pe_initialize_hardware() is the following
if ((RTC_CR & RTC_CR_OSCE_MASK) == 0u) { /* Only if the OSCILLATOR is not already enabled */
/* RTC_CR: SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
RTC_CR &= (uint32_t)~0x3C00UL;
/* RTC_CR: OSCE=1 */
RTC_CR |= (uint32_t)0x0100UL;
/* RTC_CR: CLKO=0 */
RTC_CR &= (uint32_t)~0x0200UL;
}
If the RTC is not operational, as it is on my target, executing the first line, the 'if' results in a kernel exception.
I updated the section of __pe_initialize_hardware() to the following:
#if BSPCFG_ENABLE_RTCDEV
if ((RTC_CR & RTC_CR_OSCE_MASK) == 0u) { /* Only if the OSCILLATOR is not already enabled */
/* RTC_CR: SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
RTC_CR &= (uint32_t)~0x3C00UL;
/* RTC_CR: OSCE=1 */
RTC_CR |= (uint32_t)0x0100UL;
/* RTC_CR: CLKO=0 */
RTC_CR &= (uint32_t)~0x0200UL;
}
#endif
Is this the appropriate update to not configure the RTC when VBAT is not powered?