| NANO100_BSP V3.05.000 The Board Support Package for Nano100BN Series

NuEdu-Basic01_PWMDAC.c
Go to the documentation of this file.
1/**************************************************************************/
12#include <stdio.h>
13#include "Nano100Series.h"
14#include "NuEdu-Basic01_PWMDAC.h"
15
33 void Write_PWMDAC(void)
34{
35 /* Enable PWM clock */
36 CLK_EnableModuleClock(PWM1_CH01_MODULE);
37 /* Set HCLK as PWM clock source */
38 CLK_SetModuleClock(PWM1_CH01_MODULE, (0x2UL<<4), 0);
39 // PWM0 frequency is 100Hz, duty 30%,
40 PWM_ConfigOutputChannel(PWM1, 0, 100, 30);
41 // Enable PWM0 output
42 PWM_EnableOutput(PWM1, 0x01);
43 // Start PWM module
44 PWM_Start(PWM1, 0x01);
45}
46
51 void Initial_PWM_DAC(void)
52{
53 SYS->PC_H_MFP = (SYS->PC_H_MFP & ~(SYS_PC_H_MFP_PC12_MFP_Msk ));
54 SYS->PC_H_MFP |= SYS_PC_H_MFP_PC12_MFP_PWM1_CH0;
55}
56 /* end of group Nano130_Basic01_FUNCTIONS PWM DAC Exported Functions */
58 /* end of group NuEdu-SDK-Nano130_Basic01 Nano130_Basic01 Library */
60 /* end of group NANO100_Library NANO100 Library */
62
63/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
Nano100Series.h
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
SYS_PC_H_MFP_PC12_MFP_Msk
#define SYS_PC_H_MFP_PC12_MFP_Msk
Definition: Nano100Series.h:3185
NuEdu-Basic01_PWMDAC.h
PWM1_CH01_MODULE
#define PWM1_CH01_MODULE
Definition: clk.h:308
CLK_EnableModuleClock
void CLK_EnableModuleClock(uint32_t u32ModuleIdx)
This function enable module clock.
Definition: clk.c:436
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
PWM1
#define PWM1
Pointer to PWM1 register structure.
Definition: Nano100Series.h:11680
SYS
#define SYS
Pointer to SYS register structure.
Definition: Nano100Series.h:11692
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
PWM_Start
void PWM_Start(PWM_T *pwm, uint32_t u32ChannelMask)
This function start PWM module.
Definition: pwm.c:227
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_PC_H_MFP_PC12_MFP_PWM1_CH0
#define SYS_PC_H_MFP_PC12_MFP_PWM1_CH0
Definition: sys.h:394
Initial_PWM_DAC
void Initial_PWM_DAC(void)
This function is used to setup multi-function pin of PC12 for PWM1_CH0.
Definition: NuEdu-Basic01_PWMDAC.c:51
Write_PWMDAC
void Write_PWMDAC(void)
This function is used to set PWM for PWM DAC.
Definition: NuEdu-Basic01_PWMDAC.c:33