#include "N76E003.h"
#include "Common.h"
#include "Delay.h"
#include "SFR_Macro.h"
#include "Function_define.h"
void main(void)
{
unsigned int pwm;
unsigned int FREQ = 100;
unsigned long reg;
P10_PushPull_Mode;
P12_PushPull_Mode;
PWM2_P10_OUTPUT_ENABLE;
PWM_EDGE_TYPE;
PWM_INT_PWM2;
PWM_FALLING_INT;
PWM_CLOCK_DIV_8;
reg = 16000000/8/FREQ;
PWMPH = (unsigned int)(reg>>8);
PWMPL = (unsigned int)(reg);
set_EPWM;
set_LOAD;
set_EA;
set_PWMRUN;
while(1)
{
for(pwm = 1; pwm<reg-100; pwm++ )
{
PWM2H = (unsigned int)(pwm>>8);
PWM2L = (unsigned int)(pwm);
}
for(pwm = reg-100; pwm>1; pwm--)
{
PWM2H = (unsigned int)(pwm>>8);
PWM2L = (unsigned int)(pwm);
}
}
}
void PWM_ISR (void) interrupt 13
{
PWMF = 0;
P12 = ~P12;
} |