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

NuEdu-Basic01_RGBLED.c
Go to the documentation of this file.
1 /**************************************************************************/
12 #include <stdio.h>
13 #include "Nano100Series.h"
14 #include "NuEdu-Basic01_RGBLED.h"
15
16
33 void Initial_PWM_LED(void)
34 {
35 /* Set PA 12,13,7 multi-function pins for PWM0 channel 0,1,2*/
36 SYS->PA_H_MFP = (SYS->PA_H_MFP & ~(SYS_PA_H_MFP_PA12_MFP_Msk | SYS_PA_H_MFP_PA13_MFP_Msk));
37 SYS->PA_L_MFP = (SYS->PA_L_MFP & ~(SYS_PA_L_MFP_PA7_MFP_Msk));
38 SYS->PA_H_MFP |= (SYS_PA_H_MFP_PA12_MFP_PWM0_CH0 | SYS_PA_H_MFP_PA13_MFP_PWM0_CH1);
39 SYS->PA_L_MFP |= SYS_PA_L_MFP_PA7_MFP_PWM0_CH2;
40 }
41
47 void PWM_LED(void)
48 {
49 /* Enable PWM clock */
50 CLK_EnableModuleClock(PWM0_CH01_MODULE);
51 /* Set HCLK as PWM clock source */
52 CLK_SetModuleClock(PWM0_CH01_MODULE, CLK_CLKSEL1_PWM0_CH01_S_HCLK, 0);
53 CLK_SetModuleClock(PWM0_CH23_MODULE, CLK_CLKSEL1_PWM0_CH23_S_HCLK, 0);
54 // PWM0 frequency is 100Hz, duty 30%,
55 PWM_ConfigOutputChannel(PWM0, 0, 100, 30);
56 PWM_ConfigOutputChannel(PWM0, 1, 100, 30);
57 PWM_ConfigOutputChannel(PWM0, 2, 100, 30);
58 // Enable output of all PWM channels
59 PWM_EnableOutput(PWM0, 0x07);
60 PWM_Start(PWM0, 0x07);
61 }
62 /* end of group Nano130_Basic01_FUNCTIONS Buzzer Exported Functions */
64 /* end of group NuEdu-SDK-Nano130_Basic01 Nano130_Basic01 Library */
66 /* end of group NANO100_Library NANO100 Library */
68 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. **
PWM_EnableOutput
void PWM_EnableOutput(PWM_T *pwm, uint32_t u32ChannelMask)
This function enables PWM output generation of selected channels.
Definition: pwm.c:334
SYS_PA_H_MFP_PA12_MFP_Msk
#define SYS_PA_H_MFP_PA12_MFP_Msk
Definition: Nano100Series.h:3089
SYS_PA_H_MFP_PA12_MFP_PWM0_CH0
#define SYS_PA_H_MFP_PA12_MFP_PWM0_CH0
Definition: sys.h:174
CLK_EnableModuleClock
void CLK_EnableModuleClock(uint32_t u32ModuleIdx)
This function enable module clock.
Definition: clk.c:436
SYS_PA_L_MFP_PA7_MFP_Msk
#define SYS_PA_L_MFP_PA7_MFP_Msk
Definition: Nano100Series.h:3074
PWM0_CH23_MODULE
#define PWM0_CH23_MODULE
Definition: clk.h:309
Nano100Series.h
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
CLK_CLKSEL1_PWM0_CH23_S_HCLK
#define CLK_CLKSEL1_PWM0_CH23_S_HCLK
Definition: clk.h:129
SYS_PA_H_MFP_PA13_MFP_Msk
#define SYS_PA_H_MFP_PA13_MFP_Msk
Definition: Nano100Series.h:3092
PWM0_CH01_MODULE
#define PWM0_CH01_MODULE
Definition: clk.h:310
PWM_ConfigOutputChannel
uint32_t PWM_ConfigOutputChannel(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle)
This function config PWM generator and get the nearest frequency in edge aligned auto-reload mode.
Definition: pwm.c:37
SYS_PA_L_MFP_PA7_MFP_PWM0_CH2
#define SYS_PA_L_MFP_PA7_MFP_PWM0_CH2
Definition: sys.h:102
CLK_CLKSEL1_PWM0_CH01_S_HCLK
#define CLK_CLKSEL1_PWM0_CH01_S_HCLK
Definition: clk.h:124
Initial_PWM_LED
void Initial_PWM_LED(void)
Set multi-function pins for PWM0 channel 0,1,2.
Definition: NuEdu-Basic01_RGBLED.c:33
PWM_LED
void PWM_LED(void)
Set PWM clock enable and HCLK as PWM clock source, PWM frequency is 100Hz, duty 30% and enable output...
Definition: NuEdu-Basic01_RGBLED.c:47
SYS_PA_H_MFP_PA13_MFP_PWM0_CH1
#define SYS_PA_H_MFP_PA13_MFP_PWM0_CH1
Definition: sys.h:167
NuEdu-Basic01_RGBLED.h
NuEdu-Basic01 RGB LED driver header file for NuEdu-SDK-Nano130.
PWM_Start
void PWM_Start(PWM_T *pwm, uint32_t u32ChannelMask)
This function start PWM module.
Definition: pwm.c:227
CLK_SetModuleClock
void CLK_SetModuleClock(uint32_t u32ModuleIdx, uint32_t u32ClkSrc, uint32_t u32ClkDiv)
This function set selected module clock source and module clock divider.
Definition: clk.c:339
PWM0
#define PWM0
Pointer to PWM0 register structure.
Definition: Nano100Series.h:11679
SYS
#define SYS
Pointer to SYS register structure.
Definition: Nano100Series.h:11692