Merge pull request #7406 from OpenNuvoton/nuvoton_fix_wakeup_delay

NANO130: Change PLL clock source to HIRC instead of HXT
pull/7437/head
Cruz Monrreal 2018-07-06 11:20:40 -05:00 committed by GitHub
commit 59defa29e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 2 deletions

View File

@ -52,8 +52,36 @@ void mbed_sdk_init(void)
/* Set HCLK source form HXT and HCLK source divide 1 */
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HXT, CLK_HCLK_CLK_DIVIDER(1));
/* Set HCLK frequency 42MHz */
CLK_SetCoreClock(42000000);
/* Select HXT/HIRC to clock PLL
*
* Comparison between HXT/HIRC-clocked PLL:
* 1. Spare HXT on board if only HIRC is used.
* 2. HIRC has shorter stable time.
* 3. HXT has better accuracy. USBD requires HXT-clocked PLL.
* 4. HIRC has shorter wake-up time from power-down mode.
* Per test, wake-up time from power-down mode would take:
* T1. 1~13 ms (proportional to deep sleep time) with HXT-clocked PLL as HCLK clock source
* T2. <1 ms with HIRC-clocked PLL as HCLK clock source
* T1 will fail Greentea test which requires max 10 ms wake-up time.
*
* If we just call CLK_SetCoreClock(FREQ_42MHZ) to configure HCLK to 42 MHz,
* it will go T1 with HXT already enabled in front. So we manually configure
* it to choose HXT/HIRC-clocked PLL.
*/
#define NU_HXT_PLL 1
#define NU_HIRC_PLL 2
#ifndef NU_CLOCK_PLL
#define NU_CLOCK_PLL NU_HIRC_PLL
#endif
#if (NU_CLOCK_PLL == NU_HXT_PLL)
CLK_EnablePLL(CLK_PLLCTL_PLL_SRC_HXT, FREQ_42MHZ*2);
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_PLL, CLK_HCLK_CLK_DIVIDER(2));
#elif (NU_CLOCK_PLL == NU_HIRC_PLL)
CLK_EnablePLL(CLK_PLLCTL_PLL_SRC_HIRC, FREQ_42MHZ*2);
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_PLL, CLK_HCLK_CLK_DIVIDER(2));
#endif
/* Update System Core Clock */
/* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */

View File

@ -3952,6 +3952,11 @@
"gpio-irq-debounce-sample-rate": {
"help": "Select GPIO IRQ debounce sample rate: GPIO_DBCLKSEL_1, GPIO_DBCLKSEL_2, GPIO_DBCLKSEL_4, ..., or GPIO_DBCLKSEL_32768",
"value": "GPIO_DBCLKSEL_16"
},
"clock-pll": {
"help": "Choose clock source to clock PLL: NU_HXT_PLL or NU_HIRC_PLL",
"macro_name": "NU_CLOCK_PLL",
"value": "NU_HIRC_PLL"
}
},
"inherits": ["Target"],