How to switch clock source from FIRC to PLL_PHI0 for S32K3?

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

How to switch clock source from FIRC to PLL_PHI0 for S32K3?

跳至解决方案
3,576 次查看
vusal
Contributor III

Hi,

I need to switch the clock source to PLL_PHI0 manually, meaning bare-metal, using registers. It looks like there are two ways to do this: Hardware and software. I tried setting up the hardware option; however, the status register (MUX_0_CSS[SELCTL]) still shows FIRC. MUX_0_CSC[SELCTL] shows 1000b (for PLL_PHI0) however, this is not reflected in the status register (MUX_0_CSS[SELCTL]).

Thanks for your help.

Vusal

0 项奖励
回复
1 解答
3,490 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Please refer to the CLOCK_Init function in clock_test project.

CLOCK_Init clock_test.png

在原帖中查看解决方案

5 回复数
3,553 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Vusal,

Please refer to the attached project: clock_test.zip
Hope it helps.

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

 

3,543 次查看
vusal
Contributor III
Hi Robin,

Thank you for your response.

I moved the following code (please see below) into my project and tried building, however I got 010b in SWTRG bits in the Clock Mux 0 Select Status Register, which indicates the clock I am trying to switch is not active?

"010b - Switch after the request failed because of an inactive target clock and the current clock is FIRC."

If so, how do I activate PLL?

Thanks!

Best,
Vusal

This is the code I moved into my project:

#define CLOCK_MuxInit_(mux, src, div) \
do{ \
while((MC_CGM->MUX_##mux##_CSS & MC_CGM_MUX_##mux##_CSS_SWIP_MASK) != 0) \
{ \
} \
if(div == 0) \
{ \
MC_CGM->MUX_##mux##_DC_0 = 0ul; \
} \
else \
{ \
MC_CGM->MUX_##mux##_CSC = MC_CGM_MUX_##mux##_CSC_SELCTL(src); \
MC_CGM->MUX_##mux##_DC_0 = MC_CGM_MUX_##mux##_DC_0_DIV(div - 1); \
MC_CGM->MUX_##mux##_DC_0 |= MC_CGM_MUX_##mux##_DC_0_DE_MASK; \
while((MC_CGM->MUX_##mux##_DIV_UPD_STAT & MC_CGM_MUX_##mux##_DIV_UPD_STAT_DIV_STAT_MASK) != 0) \
{ \
} \
MC_CGM->MUX_##mux##_CSC |= MC_CGM_MUX_##mux##_CSC_CLK_SW_MASK; \
while((MC_CGM->MUX_##mux##_CSS & MC_CGM_MUX_##mux##_CSS_CLK_SW_MASK) == 0) \
{ \
} \
while((MC_CGM->MUX_##mux##_CSS & MC_CGM_MUX_1_CSS_SWIP_MASK) != 0) \
{ \
} \
} \
}while(0)
0 项奖励
回复
3,491 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Please refer to the CLOCK_Init function in clock_test project.

CLOCK_Init clock_test.png

3,454 次查看
vusal
Contributor III
Hi Robin,

I incorporated the CLOCK_Init into my project and it worked. I can see on the status register (MUX_0_CSS) that my clock source switched to the PLL_PHI0_CLK.

Thank you very much for your help!

Best,
Vusal
3,482 次查看
vusal
Contributor III
Thank you, Robin. This is helpful. I'll take a look.
0 项奖励
回复