/************************************************************************************************************
* PWM interrupt subroutine
************************************************************************************************************/
void PWM_ISR (void) interrupt 13
{
clr_PWMF; // clear PWM interrupt flag
P12 = ~P12; // GPIO1 show PWM INT
}
/************************************************************************************************************
* Main function
************************************************************************************************************/
void main(void)
{
Set_All_GPIO_Quasi_Mode;
/**********************************************************************
PWM frequency = Fpwm/((PWMPH,PWMPL) + 1) <Fpwm = Fsys/PWM_CLOCK_DIV>
= (22.1184MHz/8)/(0x3FF + 1)
= 2.7KHz
***********************************************************************/
PWM2_P10_OUTPUT_ENABLE;
PWM_INT_PWM2;
PWM_FALLING_INT; //Setting Interrupt happen when PWM0 falling signal
PWM_CLOCK_DIV_8;
PWMPH = 0x03; //Setting PWM period
PWMPL = 0xFF;
PWM2H = 0x01; //PWM0 high duty = 1/2 PWM period
PWM2L = 0xFF;
set_EPWM; //Enable PWM interrupt
set_EA;
set_LOAD;
set_PWMRUN;
while(1);
}
|