| NUC029FAE_BSP V3.02.000 The Board Support Package for NUC029FAE MCU

system_NUC029FAE.c
Go to the documentation of this file.
1/**************************************************************************/
13#include <stdint.h>
14#include "NUC029FAE.h"
15
16
17/*----------------------------------------------------------------------------
18 Clock Variable definitions
19 *----------------------------------------------------------------------------*/
20uint32_t SystemCoreClock = __HSI;
21uint32_t CyclesPerUs = (__HSI / 1000000);
31 void SystemCoreClockUpdate (void)
32{
33 uint32_t u32CoreFreq, u32ClkSrc;
34
35 u32ClkSrc = CLK->CLKSEL0 & CLK_CLKSEL0_HCLK_S_Msk;
36
37 if (u32ClkSrc == 0)
38 u32CoreFreq = __XTAL; /* External crystal clock */
39 else if (u32ClkSrc == 3)
40 u32CoreFreq = __IRC10K; /* Internal 10K crystal clock */
41 else if (u32ClkSrc == 7)
42 u32CoreFreq = __IRC22M; /* Internal 22M */
43 else
44 u32CoreFreq = __IRC22M; /* unknown value, use default Internal 22M */
45
46 SystemCoreClock = (u32CoreFreq/((CLK->CLKDIV & CLK_CLKDIV_HCLK_N_Msk) + 1));
47 CyclesPerUs = (SystemCoreClock + 500000) / 1000000;
48}
49
50#if USE_ASSERT
51
63 void AssertError(uint8_t * file, uint32_t line)
64{
65
66 printf("[%s] line %d : wrong parameters.\r\n", file, line);
67
68 /* Infinite loop */
69 while(1) ;
70}
71#endif
72
73/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
NUC029FAE.h
NUC029FAE peripheral access layer header file. This file contains all the peripheral register's defin...
CLK
#define CLK
Pointer to CLK register structure.
Definition: NUC029FAE.h:3228
CyclesPerUs
uint32_t CyclesPerUs
Definition: system_NUC029FAE.c:21
SystemCoreClock
uint32_t SystemCoreClock
Definition: system_NUC029FAE.c:20
SystemCoreClockUpdate
void SystemCoreClockUpdate(void)
This function is used to update the variable SystemCoreClock and must be called whenever the core clo...
Definition: system_NUC029FAE.c:31
__IRC10K
#define __IRC10K
Definition: system_NUC029FAE.h:32
__IRC22M
#define __IRC22M
Definition: system_NUC029FAE.h:31
__XTAL
#define __XTAL
Definition: system_NUC029FAE.h:33
__HSI
#define __HSI
Definition: system_NUC029FAE.h:34