NUC472_NUC442_BSP V3.03.005
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 *----------------------------------------------------------------------------*/
18uint32_t CyclesPerUs = (__HSI / 1000000);
19uint32_t gau32ClkSrcTbl[] = {__HXT, __LXT, 0, __LIRC, 0, 0, 0, __HIRC};
23/*----------------------------------------------------------------------------
24 Clock functions
25 *----------------------------------------------------------------------------*/
26void 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
56void 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/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
#define CLK_CLKDIV0_HCLKDIV_Msk
Definition: NUC472_442.h:3860
#define CLK_CLKSEL0_HCLKSEL_Msk
Definition: NUC472_442.h:3761
#define CLK_CLKSEL0_HCLKSEL_PLL
Definition: clk.h:87
uint32_t CLK_GetPLLClockFreq(void)
This function get PLL frequency. The frequency unit is Hz.
Definition: clk.c:166
#define CLK
Definition: NUC472_442.h:28798
uint32_t gau32ClkSrcTbl[]
uint32_t CyclesPerUs
void SystemInit(void)
Setup the micro controller system.
uint32_t SystemCoreClock
void SystemCoreClockUpdate(void)
Updates the SystemCoreClock with current core Clock retrieved from CPU registers.
#define __HIRC
#define __HXT
#define __LIRC
#define __LXT
#define __HSI