| Nano100BN Series BSP V3.03.002 The Board Support Package for Nano100BN Series

NuEdu-Basic01_ClkOut.c
Go to the documentation of this file.
1 /**************************************************************************/
12 #include <stdio.h>
13 #include "Nano100Series.h"
14 #include "NuEdu-Basic01_ClkOut.h"
15
16
44 void Open_CLK_OUT(uint32_t Clock_Source, uint32_t FRQDIV_FSEL)
45 {
46
47 //Initial FCLKO Function Pin
48 SYS->PB_H_MFP = (SYS->PB_H_MFP & ~SYS_PB_H_MFP_PB12_MFP_Msk) | SYS_PB_H_MFP_PB12_MFP_CKO;
49
50 if(FRQDIV_FSEL>15)
51 {
52 printf("\nOpen CLK OUT FAIL\n");
53 return;
54 }
55
56 //Initial FCLKO Clock Divider
57 CLK->FRQDIV = CLK_FRQDIV_FDIV_EN_Msk | FRQDIV_FSEL;
58
59 /* Select FCLKO clock source */
60 CLK->CLKSEL2 = (CLK->CLKSEL2 & (~CLK_CLKSEL2_FRQDIV_S_Msk)) | Clock_Source;
61
62 /* Enable FCLKO clock source */
63 CLK->APBCLK |= CLK_APBCLK_FDIV_EN_Msk;
64
65 SYS_LockReg();
66
67 }
68
73 void Close_CLK_OUT(void)
74 {
75
76 //Disable FCLKO Function
77 CLK->FRQDIV &= ~CLK_FRQDIV_FDIV_EN_Msk;
78
79 //Disable FCLKO Clock Source
80 SYS_UnlockReg();
81 CLK->APBCLK &= ~CLK_APBCLK_FDIV_EN_Msk;
82 SYS_LockReg();
83 }
84
85 /* end of group Nano130_Basic01_FUNCTIONS ClkOut Exported Functions */
87 /* end of group NuEdu-SDK-Nano130_Basic01 Nano130_Basic01 Library */
89 /* end of group NANO100_Library NANO100 Library */
91
92 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
CLK
#define CLK
Pointer to CLK register structure.
Definition: Nano100Series.h:11693
Nano100Series.h
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
SYS_UnlockReg
__STATIC_INLINE void SYS_UnlockReg(void)
Disable register write-protection function.
Definition: sys.h:826
Open_CLK_OUT
void Open_CLK_OUT(uint32_t Clock_Source, uint32_t FRQDIV_FSEL)
This function enable frequency divider module clock, enable frequency divider clock function and conf...
Definition: NuEdu-Basic01_ClkOut.c:44
CLK_APBCLK_FDIV_EN_Msk
#define CLK_APBCLK_FDIV_EN_Msk
Definition: Nano100Series.h:1282
SYS_PB_H_MFP_PB12_MFP_Msk
#define SYS_PB_H_MFP_PB12_MFP_Msk
Definition: Nano100Series.h:3137
NuEdu-Basic01_ClkOut.h
NuEdu-Basic01 ClkOut driver header file.
Close_CLK_OUT
void Close_CLK_OUT(void)
This function disable frequency output function.
Definition: NuEdu-Basic01_ClkOut.c:73
SYS_PB_H_MFP_PB12_MFP_CKO
#define SYS_PB_H_MFP_PB12_MFP_CKO
Definition: sys.h:287
SYS_LockReg
__STATIC_INLINE void SYS_LockReg(void)
Enable register write-protection function.
Definition: sys.h:843
CLK_CLKSEL2_FRQDIV_S_Msk
#define CLK_CLKSEL2_FRQDIV_S_Msk
Definition: Nano100Series.h:1384
CLK_FRQDIV_FDIV_EN_Msk
#define CLK_FRQDIV_FDIV_EN_Msk
Definition: Nano100Series.h:1456
SYS
#define SYS
Pointer to SYS register structure.
Definition: Nano100Series.h:11692