Hello,
void SOSC_init_16MHz(void)
{
/*!
* SOSC Initialization (8 MHz):
* ===================================================
*/
SCG->SOSCDIV = SCG_SOSCDIV_SOSCDIV1(1)|
SCG_SOSCDIV_SOSCDIV2(1); /* SOSCDIV1 & SOSCDIV2 =1: divide by 1 */
SCG->SOSCCFG |= (0x3 << 4); // 11 : High frequency range selected for the crystal oscillator
SCG->SOSCCFG &= ~(0x1 << 3); // 0 : HGO bit for low gain operation
SCG->SOSCCFG &= ~(0x1 << 2); // EREFS : 0 , external clock selected
while(SCG->SOSCCSR & SCG_SOSCCSR_LK_MASK); /* Ensure SOSCCSR unlocked */
SCG->SOSCCSR = SCG_SOSCCSR_SOSCEN_MASK; /* LK=0: SOSCCSR can be written */
/* SOSCCMRE=0: OSC CLK monitor IRQ if enabled */
/* SOSCCM=0: OSC CLK monitor disabled */
/* SOSCERCLKEN=0: Sys OSC 3V ERCLK output clk disabled */
/* SOSCLPEN=0: Sys OSC disabled in VLP modes */
/* SOSCSTEN=0: Sys OSC disabled in Stop modes */
/* SOSCEN=1: Enable oscillator */
while(!(SCG->SOSCCSR & SCG_SOSCCSR_SOSCVLD_MASK)); /* Wait for sys OSC clk valid */
}
Hi arajan,
If crystal is used, then you need you enable(set 1) the SCG_SOSCCFG[EREFS] bit.
Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------