HardwareDriver/nuvoton/m451/steppernew/interrupt.c

33 lines
715 B
C

#include "M451Series.h"
/**
* @brief PWM0 IRQ Handler
*
* @param None
*
* @return None
*
* @details ISR to handle PWM0 interrupt event
*/
void PWM0P0_IRQHandler()
{
static uint32_t cnt;
static uint32_t out;
// Channel 0 frequency is 100Hz, every 1 second enter this IRQ handler 100 times.
if(++cnt == 100)
{
if(out)
PWM_EnableOutput(PWM0, PWM_CH_0_MASK | PWM_CH_1_MASK | PWM_CH_2_MASK | PWM_CH_3_MASK);
else
PWM_DisableOutput(PWM0, PWM_CH_0_MASK | PWM_CH_1_MASK | PWM_CH_2_MASK | PWM_CH_3_MASK);
out ^= 1;
cnt = 0;
}
// Clear channel 0 period interrupt flag
PWM_ClearPeriodIntFlag(PWM0, 0);
}