NUC029FAE_BSP V3.01.004
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 *----------------------------------------------------------------------------*/
21uint32_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
63void 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 CLK
Pointer to CLK register structure.
Definition: NUC029FAE.h:3228
uint32_t CyclesPerUs
uint32_t SystemCoreClock
void SystemCoreClockUpdate(void)
This function is used to update the variable SystemCoreClock and must be called whenever the core clo...
#define __IRC10K
#define __IRC22M
#define __XTAL
#define __HSI