iruraz
Member level 2
Hi Everyone,
I try to obtain 120 KHz carrier signal with using pwm module of pic 16f877 . PWM uses timer2 and maximum frequency value is 250 Hz because pr2 maximum value is 255 and postscale maximum value is 16. And the formula is :
Tpwm=Tcommand*(pr2 + 1)*(tmr2 division ratio)
And here is the code below. How can i obtain 120KHz signal with pwm. By the way i work with ccs-c
regards
I try to obtain 120 KHz carrier signal with using pwm module of pic 16f877 . PWM uses timer2 and maximum frequency value is 250 Hz because pr2 maximum value is 255 and postscale maximum value is 16. And the formula is :
Tpwm=Tcommand*(pr2 + 1)*(tmr2 division ratio)
And here is the code below. How can i obtain 120KHz signal with pwm. By the way i work with ccs-c
regards
Code:
#include <16f877.h>
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay (clock=4000000)
#use fast_io(c)
void main ( )
{
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_1(T1_DISABLED);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
set_tris_c(0x00);
setup_ccp1(CCP_PWM);
setup_timer_2(T2_DIV_BY_16,255,16);
set_pwm1_duty(30);
while(1);
}