Hello people,
Here some info about clocks in EFM32.
I’ll show you code snippet, for EFM32 that make work HF timers, LF timers, HF USART and LF USART.
I will not explain why those definitions work – you can read it in datasheet.
Simply, shortly, I’ll save your time by giving you an example below.
So….
void systemClocksInit(void) {
/* Use crystal oscillator for HFXO */
CMU->CTRL |= CMU_CTRL_HFXOMODE_XTAL;
/* HFXO setup */
CMU->CTRL = (CMU->CTRL & ~_CMU_CTRL_HFXOBOOST_MASK) | CMU_CTRL_HFXOBOOST_100PCENT;
/* Enable HFXO as high frequency clock, HFCLK */
CMU_ClockSelectSet(cmuClock_HF,cmuSelect_HFXO);
/* Use crystal oscillator for LFXO */
CMU->CTRL |= CMU_CTRL_LFXOMODE_XTAL;
/* LFXO setup */
CMU->CTRL = (CMU->CTRL & ~_CMU_CTRL_LFXOBOOST_MASK) | CMU_CTRL_LFXOBOOST_100PCENT;
EMU->AUXCTRL = (EMU->AUXCTRL & ~_EMU_AUXCTRL_REDLFXOBOOST_MASK);
/* Enable LFXO and wait for it to stabilize */
CMU_OscillatorEnable(cmuOsc_LFXO, true, true);
/* Select LFXO as clock source for LFACLK */
CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFXO);
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_CORELE, true);
/***********************************************************************/
/*************** ENABLE CLOCKS OF PEREPHERIA ***************************/
CMU_ClockEnable(cmuClock_GPIO, true);
CMU_ClockEnable(cmuClock_USART0, true);
CMU_ClockEnable(cmuClock_LEUART0, true);
CMU_ClockEnable(cmuClock_LETIMER0, true);
CMU_ClockEnable(cmuClock_TIMER0, true);
}
Have a nice day! 🙂