Mini51 BSP  V3.02.002
The Board Support Package for Mini51 Series
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  *----------------------------------------------------------------------------*/
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 2013 Nuvoton Technology Corp. ***/
uint32_t CyclesPerUs
#define CLK_CLKSEL0_HCLK_S_Msk
Mini51 series peripheral access layer header file. This file contains all the peripheral register's d...
#define __XTAL
uint32_t SystemCoreClock
#define __IRC10K
#define CLK_CLKDIV_HCLK_N_Msk
#define __HSI
#define CLK
Pointer to CLK register structure.
#define __IRC22M
void SystemCoreClockUpdate(void)
This function is used to update the variable SystemCoreClock and must be called whenever the core clo...