| Nano100BN Series BSP V3.03.002 The Board Support Package for Nano100BN Series

NuEdu-Basic01_System.c
Go to the documentation of this file.
1 /**************************************************************************/
12 #include <stdio.h>
13 #include "Nano100Series.h"
14 #include "NuEdu-Basic01_System.h"
15
16
34 /*---------------------------------------------------------------------------------------------------------*/
35 /* Init System Clock */
36 /*---------------------------------------------------------------------------------------------------------*/
37 void SYS_Init(void)
38 {
39 /* Unlock protected registers */
40 SYS_UnlockReg();
41
42 /* Set HCLK source from HXT and HCLK source divide 1 */
43 CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HXT,CLK_HCLK_CLK_DIVIDER(1));
44
45 /* Enable external 12MHz HXT, 32KHz LXT and HIRC */
46 CLK_EnableXtalRC(CLK_PWRCTL_HXT_EN_Msk | CLK_PWRCTL_LXT_EN_Msk | CLK_PWRCTL_HIRC_EN_Msk);
47
48 /* Set HCLK frequency 42MHz */
49 CLK_SetCoreClock(42000000);
50
51 /* Lock protected registers */
52 SYS_LockReg();
53
54 }
55
56 /* end of group Nano130_Basic01_FUNCTIONS System Exported Functions */
58 /* end of group NuEdu-SDK-Nano130_Basic01 Nano130_Basic01 Library */
60 /* end of group NANO100_Library NANO100 Library */
62
63 /*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
CLK_PWRCTL_HXT_EN_Msk
#define CLK_PWRCTL_HXT_EN_Msk
Definition: Nano100Series.h:1213
SYS_Init
void SYS_Init(void)
This function enables HXT, LXT and LIRC clock and sets HCLK source from HXT to 42MHz.
Definition: NuEdu-Basic01_System.c:37
CLK_SetHCLK
void CLK_SetHCLK(uint32_t u32ClkSrc, uint32_t u32ClkDiv)
This function set HCLK clock source and HCLK clock divider.
Definition: clk.c:223
CLK_SetCoreClock
uint32_t CLK_SetCoreClock(uint32_t u32Hclk)
This function set HCLK frequency. The frequency unit is Hz. The range of u32Hclk is 24 ~ 42 MHz.
Definition: clk.c:177
Nano100Series.h
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
CLK_PWRCTL_LXT_EN_Msk
#define CLK_PWRCTL_LXT_EN_Msk
Definition: Nano100Series.h:1216
SYS_UnlockReg
__STATIC_INLINE void SYS_UnlockReg(void)
Disable register write-protection function.
Definition: sys.h:826
CLK_PWRCTL_HIRC_EN_Msk
#define CLK_PWRCTL_HIRC_EN_Msk
Definition: Nano100Series.h:1219
CLK_HCLK_CLK_DIVIDER
#define CLK_HCLK_CLK_DIVIDER(x)
Definition: clk.h:188
NuEdu-Basic01_System.h
NuEdu-Basic01 System driver header file.
CLK_CLKSEL0_HCLK_S_HXT
#define CLK_CLKSEL0_HCLK_S_HXT
Definition: clk.h:101
CLK_EnableXtalRC
void CLK_EnableXtalRC(uint32_t u32ClkMask)
This function enable clock source.
Definition: clk.c:369
SYS_LockReg
__STATIC_INLINE void SYS_LockReg(void)
Enable register write-protection function.
Definition: sys.h:843