MINI58_BSP V3.01.005
The Board Support Package for Mini58 Series MCU
system_Mini58Series.c
Go to the documentation of this file.
1/**************************************************************************/
13#include <stdint.h>
14#include "Mini58Series.h"
15
16
17/*----------------------------------------------------------------------------
18 Clock Variable definitions
19 *----------------------------------------------------------------------------*/
21uint32_t __HSI = __HIRC;
22uint32_t PllClock = __HIRC;
23uint32_t CyclesPerUs;
31void SystemInit (void)
32{
33
34}
35
44{
45 uint32_t u32CoreFreq, u32ClkSrc;
46
47 /* Update PLL Clock */
49
50 u32ClkSrc = CLK->CLKSEL0 & CLK_CLKSEL0_HCLKSEL_Msk;
51
52 if (u32ClkSrc == 0)
53 u32CoreFreq = __XTAL; /* External crystal clock */
54 else if (u32ClkSrc ==2)
55 u32CoreFreq = PllClock; /* PLL clock */
56 else if (u32ClkSrc == 3)
57 u32CoreFreq = __IRC10K; /* Internal 10K crystal clock */
58 else if (u32ClkSrc == 7)
59 u32CoreFreq = __HIRC; /* Factory Default is internal RC */
60 else
61 u32CoreFreq = __HIRC; /* unknown value, use Factory Default is internal RC */
62
63 SystemCoreClock = (u32CoreFreq/((CLK->CLKDIV & CLK_CLKDIV_HCLKDIV_Msk) + 1));
64 CyclesPerUs = (SystemCoreClock + 500000) / 1000000;
65}
66
67#if USE_ASSERT
68
80void AssertError(uint8_t * file, uint32_t line)
81{
82
83 printf("[%s] line %d : wrong parameters.\r\n", file, line);
84
85 /* Infinite loop */
86 while(1) ;
87}
88#endif
89
90/*** (C) COPYRIGHT 2015 Nuvoton Technology Corp. ***/
Mini58 series peripheral access layer header file. This file contains all the peripheral register's d...
__STATIC_INLINE uint32_t CLK_GetPLLClockFreq(void)
Get PLL clock frequency.
Definition: clk.h:197
#define CLK_CLKSEL0_HCLKSEL_Msk
#define CLK_CLKDIV_HCLKDIV_Msk
#define CLK
Pointer to CLK register structure.
uint32_t __HSI
uint32_t CyclesPerUs
void SystemInit(void)
Check HIRC clock rate feed to HCLK.
uint32_t PllClock
uint32_t SystemCoreClock
void SystemCoreClockUpdate(void)
This function is used to update the variable SystemCoreClock and must be called whenever the core clo...
#define __HIRC
#define __IRC10K
#define __XTAL