NUC029FAE BSP  V3.01.002
The Board Support Package for NUC029FAE
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  *----------------------------------------------------------------------------*/
20 uint32_t SystemCoreClock = __HSI;
21 uint32_t CyclesPerUs = (__HSI / 1000000);
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 peripheral access layer header file. This file contains all the peripheral register's defin...
#define __IRC10K
uint32_t SystemCoreClock
#define __HSI
void SystemCoreClockUpdate(void)
This function is used to update the variable SystemCoreClock and must be called whenever the core clo...
#define __IRC22M
#define CLK
Pointer to CLK register structure.
Definition: NUC029FAE.h:3228
#define __XTAL
uint32_t CyclesPerUs