| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

system_NUC472_442.c
Go to the documentation of this file.
1/**************************************************************************/
12#include "NUC472_442.h"
13
14/*----------------------------------------------------------------------------
15 Clock Variable definitions
16 *----------------------------------------------------------------------------*/
17uint32_t SystemCoreClock = __HSI;
18uint32_t CyclesPerUs = (__HSI / 1000000);
19uint32_t gau32ClkSrcTbl[] = {__HXT, __LXT, 0, __LIRC, 0, 0, 0, __HIRC};
23/*----------------------------------------------------------------------------
24 Clock functions
25 *----------------------------------------------------------------------------*/
26 void SystemCoreClockUpdate (void) /* Get Core Clock Frequency */
27{
28 uint32_t u32Freq, u32ClkSrc;
29 uint32_t u32HclkDiv;
30
31 u32ClkSrc = CLK->CLKSEL0 & CLK_CLKSEL0_HCLKSEL_Msk;
32
33 if(u32ClkSrc != CLK_CLKSEL0_HCLKSEL_PLL) {
34 /* Use the clock sources directly */
35 u32Freq = gau32ClkSrcTbl[u32ClkSrc];
36 } else {
37 /* Use PLL clock */
38 u32Freq = CLK_GetPLLClockFreq();
39 }
40
41 u32HclkDiv = (CLK->CLKDIV0 & CLK_CLKDIV0_HCLKDIV_Msk) + 1;
42
43 /* Update System Core Clock */
44 SystemCoreClock = u32Freq/u32HclkDiv;
45
46 CyclesPerUs = (SystemCoreClock + 500000) / 1000000;
47}
48
56 void SystemInit (void)
57{
58
59 /* FPU settings ------------------------------------------------------------*/
60#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
61 SCB->CPACR |= ((3UL << 10*2) | /* set CP10 Full Access */
62 (3UL << 11*2) ); /* set CP11 Full Access */
63#endif
64
65
66}
67/*** (C) COPYRIGHT 2015 Nuvoton Technology Corp. ***/
NUC472_442.h
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
CLK_CLKDIV0_HCLKDIV_Msk
#define CLK_CLKDIV0_HCLKDIV_Msk
Definition: NUC472_442.h:3860
CLK_CLKSEL0_HCLKSEL_Msk
#define CLK_CLKSEL0_HCLKSEL_Msk
Definition: NUC472_442.h:3761
CLK_CLKSEL0_HCLKSEL_PLL
#define CLK_CLKSEL0_HCLKSEL_PLL
Definition: clk.h:87
CLK_GetPLLClockFreq
uint32_t CLK_GetPLLClockFreq(void)
This function get PLL frequency. The frequency unit is Hz.
Definition: clk.c:166
CLK
#define CLK
Definition: NUC472_442.h:28798
gau32ClkSrcTbl
uint32_t gau32ClkSrcTbl[]
Definition: system_NUC472_442.c:19
CyclesPerUs
uint32_t CyclesPerUs
Definition: system_NUC472_442.c:18
SystemInit
void SystemInit(void)
Setup the micro controller system.
Definition: system_NUC472_442.c:56
SystemCoreClock
uint32_t SystemCoreClock
Definition: system_NUC472_442.c:17
SystemCoreClockUpdate
void SystemCoreClockUpdate(void)
Updates the SystemCoreClock with current core Clock retrieved from CPU registers.
Definition: system_NUC472_442.c:26
__HIRC
#define __HIRC
Definition: system_NUC472_442.h:27
__HXT
#define __HXT
Definition: system_NUC472_442.h:25
__LIRC
#define __LIRC
Definition: system_NUC472_442.h:28
__LXT
#define __LXT
Definition: system_NUC472_442.h:26
__HSI
#define __HSI
Definition: system_NUC472_442.h:29