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,574件の閲覧回数
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,488件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

Please refer to the CLOCK_Init function in clock_test project.

CLOCK_Init clock_test.png

元の投稿で解決策を見る

5 返答(返信)
3,551件の閲覧回数
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,541件の閲覧回数
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,489件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

Please refer to the CLOCK_Init function in clock_test project.

CLOCK_Init clock_test.png

3,452件の閲覧回数
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,480件の閲覧回数
vusal
Contributor III
Thank you, Robin. This is helpful. I'll take a look.
0 件の賞賛
返信