hi guys ...can any one please help me in this code ... i want to generate sine pwm of 50 hz and using a crystal of 12 MHZ....please help
#include <18f452.h>
#device HIGH_INTS=true
#fuses HS, NOWDT, PUT, NOLVP
#use delay(clock=12000000)
const long sine[32] = {0,5,9,14,18,23,27,31,34,37,40,42,44,46,47,48,48,
48,47,46,44,42,40,37,34,31,27,23,18,14,9,5};
int i=0;
#INT_TIMER0 //HIGH
void timer0_isr()
{
clear_interrupt(INT_TIMER0);
set_timer0(254);
set_pwm1_duty(sine);
i++;
if(i=32)
i=0;
delay_us(5);
}
void main()
{
setup_timer_2(T2_DIV_BY_1, 250, 1); //51.2us
setup_ccp1 (CCP_PWM);
set_pwm1_duty(200);
set_timer2(0);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8|RTCC_8_BIT);
set_timer0(254);
enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);
delay_ms(5);
while(true)
{
;;
}
}