控制所有PWM輸出的代碼
/**************************************************************************//**
* @file main.c
* @version V1.00
* $Revision: 2 $
* $Date: 14/12/25 10:24a $
* @brief Change duty cycle and period of output waveform by BPWM Double Buffer function.
* @note
* Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved.
*
******************************************************************************/
#include <stdio.h>
#include "M0518.h"
/*---------------------------------------------------------------------------------------------------------*/
/* Macro, type and constant definitions */
/*---------------------------------------------------------------------------------------------------------*/
/* Configure UART0 and set UART0 Baudrate */
UART_Open(UART0, 115200);
}
void PWM01_Init(void)
{
/* Set PWM0/1 channel 0/2/4 as independent mode and down count type */
PWM0->CTL1 = 0x0111;
PWM1->CTL1 = 0x0111;
/* Set BPWM0/1 all 6 channels as down count type */
BPWM0->CTL1 = 0x01;
BPWM1->CTL1 = 0x01;
// PWM0 channel 0 frequency is 100Hz, duty 30%,
PWM_ConfigOutputChannel(PWM0, 0, 10000, 0);//B COLOR
PWM_ConfigOutputChannel(PWM0, 1, 10000, 0);//R COLOR
PWM_ConfigOutputChannel(PWM0, 2, 10000, 0);//g COLOR