常见问答

よくあるご質問

Why can’t the clock source of HCLK be switched to PLL when the system clock source is initialized with the following commands? CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_HCLKSEL_Msk); CLK->CLKSEL0 |= CLK_CLKSEL0_HCLKSEL_PLL;  日付:2016-11-29

Q: Why can’t the clock source of HCLK be switched to PLL when the system clock source is initialized with the following commands?
CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_HCLKSEL_Msk);  
CLK->CLKSEL0 |= CLK_CLKSEL0_HCLKSEL_PLL;

A: In the execution of the first command line,
CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_HCLKSEL_Msk);

HCLKSEL (CLKSEL0 [2: 0]) is set to 0x00. When HCLKSEL is set to 0x00, as shown below, the clock source of HCLK is switched to external crystal.

 

If the external crystal is not stable or enabled at this time, the switching clock source will fail and the HCLKSEL will be remain its default setting (initialized as 0x07, clock source as HIRC).

Therefore, in the execution of the second command line,

CLK->CLKSEL0 |= CLK_CLKSEL0_HCLKSEL_PLL;

HCLKSEL cannot be correctly set to PLL and HCLK cannot be switched to PLL.

 

To switch the clock source, user needs to make sure that the clock source to be switched is stable. It is recommended to switch the clock source using the following methods:

 

1. Write a value directly

CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_HCLKSEL_Msk) | CLK_CLKSEL0_HCLKSEL_PLL;

 

2. Call function

CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_PLL, CLK_CLKDIV_HCLK(2));

製品: マイクロコントローラ ,8ビット 8051 MCU ,低ピンカウント 8051 シリーズ ,標準 8051 シリーズ ,Arm Cortex-M0 MCU ,M051 ベースシリーズ ,M0518シリーズ ,M0519シリーズ ,ミニ 51 ベースシリーズ ,ナノ 100/102 ベースシリーズ ,Nano103 ベースシリーズ ,ナノ 110/112 LCD シリーズ ,ナノ 120 USB シリーズ ,ナノ 130 アドバンストシリーズ ,NUC029 シリーズ ,NUC100/200 アドバンストシリーズ ,NUC120/122/123/220 USB シリーズ ,NUC130/230 CAN シリーズ ,NUC131/NUC1311 CAN シリーズ ,NUC140/240 コネクティビティシリーズ ,Arm Cortex-M4 MCU ,M451 ベースシリーズ ,M451M シリーズ ,M452 USB シリーズ ,M453 CAN シリーズ ,M4TK タッチキーシリーズ ,NUC442/472 シリーズ ,NUC505 シリーズ
アプリケーション:
機能: Peripherals,ARM,Cortex-M0,Cortex-M4,Clock Control,HIRC,HXT,PLL