Issue regarding selection of external clock source - NXP S32K144

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Issue regarding selection of external clock source - NXP S32K144

1,044 次查看
arajan
Contributor I

Hello,

 
I am trying to enable the external crystal oscillator for our S32K144 MCU based in-house board.

I have taken the S32K144_Project_FlexCAN example project as a reference for the same. 

My observations are as follows - 
I have disabled the EREFS bit as mentioned in the Reference manual to select the external clock as the clock source. 
 


 

 


 
After doing this configuration, the sys OSC clk valid bit is not setting when we read it, and it is therefore hanging in the while loop. I am attaching the snapshots of the code here as well -

 

 

 

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 */
}

 

 

Also, we have the external clock connected on the following pins on the hardware -
- PTB7 and PTB6
 
We want to use the external crystal oscillator as our clock source, please let us know if the configurations are correct or need some changes.
-- 
Thanks & Regards
Ajay Rajan
0 项奖励
回复
1 回复

1,021 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi arajan,

If crystal is used, then you need you enable(set 1) the SCG_SOSCCFG[EREFS] bit.

SCG_SOSCCFG[EREFS].png

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.
-------------------------------------------------------------------------------

0 项奖励
回复