请参考这个代码
****************************************************************************************/
/* EPWM start output waveform functoin */
/****************************************************************************************/
// Num, Number of wavform outputing from PWM pin
// Delay_PWM, After such PWM Period, ADC start to convert
void EPWM_Output(uint8_t Num, uint16_t Delay_PWM)
{
if (Num == 0) return ;
EPWM1->CNTCLR = ~0 ;
EPWM1->IFA[0] = 0 ;
EPWM1->IFA[0] = 0x80000000 + Num ; // CH0,interrupt every Num period
EPWM1->AINTSTS = ~0 ; // Clear interrupt flag
NVIC_ClearPendingIRQ(EPWM1P0_IRQn);
EPWM1->IFA[2] = 0 ;
EPWM1->IFA[2] = 0x80000000 + Delay_PWM ; // CH1,interrupt every Delay_PWM period
NVIC_ClearPendingIRQ(EPWM1P1_IRQn);
EPWM1->AINTEN = 5 ; // Enable PWM intrrupt,Disable output after such number of period
PDMA_Initial(Data_Num) ; // Configure number of data that PDMA transfering
EPWM_TRIGGER_SYNC_START(EPWM1); // Active EPWM0 synchronously
}
|