| MINI51DE_BSP V3.02.004 The Board Support Package for Mini51DE Series MCU

system_Mini51Series.c
Go to the documentation of this file.
1/**************************************************************************/
13#include <stdint.h>
14#include "Mini51Series.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 2013 Nuvoton Technology Corp. ***/
Mini51Series.h
Mini51 series peripheral access layer header file. This file contains all the peripheral register's d...
CLK_CLKSEL0_HCLK_S_Msk
#define CLK_CLKSEL0_HCLK_S_Msk
Definition: Mini51Series.h:962
CLK_CLKDIV_HCLK_N_Msk
#define CLK_CLKDIV_HCLK_N_Msk
Definition: Mini51Series.h:986
CLK
#define CLK
Pointer to CLK register structure.
Definition: Mini51Series.h:5736
CyclesPerUs
uint32_t CyclesPerUs
Definition: system_Mini51Series.c:21
SystemCoreClock
uint32_t SystemCoreClock
Definition: system_Mini51Series.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_Mini51Series.c:31
__IRC10K
#define __IRC10K
Definition: system_Mini51Series.h:32
__IRC22M
#define __IRC22M
Definition: system_Mini51Series.h:31
__XTAL
#define __XTAL
Definition: system_Mini51Series.h:33
__HSI
#define __HSI
Definition: system_Mini51Series.h:34