Häufig gestellte Fragen

Häufig gestellte Fragen

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;  Datum: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));

Produkte: Mikrocontroller ,8-bit-8051-MCUs ,8051-Serie mit geringer Pinzahl ,Standard-8051-Serie ,Arm Cortex-M0-MCUs ,M051-Base-Serie ,M0518-Serie ,M0519-Serie ,Mini51-Base-Serie ,Nano100/102-Base-Serie ,Nano103-Base-Serie ,Nano110/112-LCD-Serie ,Nano120-USB-Serie ,Nano130-Advanced-Serie ,NUC029-Serie ,NUC100/200-Advanced-Serie ,NUC120/122/123/220-USB-Serie ,NUC130/230-CAN-Serie ,NUC131-NUC1311-CAN-Serie ,NUC140/240-Konnektivität-Serie ,Arm Cortex-M4-MCUs ,M451-Base-Serie ,M451M-Serie ,M452-USB-Serie ,M453-CAN-Serie ,M4TK-Touch-Key-Serie ,NUC442/472-Serie ,NUC505-Serie
Applikationen:
Funktion: Peripherals,ARM,Cortex-M0,Cortex-M4,Clock Control,HIRC,HXT,PLL
This website uses cookies to ensure you get the best experience on our website. Learn more
OK