umka
Joined: 28 Aug 2007 Posts: 99 Location: New Zealand
|
Low Frequency PWM |
Posted: Wed Jan 16, 2008 4:20 pm |
|
|
how does one get a low frequency?
i dont know how to get it to 50Hz i can get much less than 250Hz. do i have to go to a slower crystal? the adc sets the duty ratio.
Code: | #include <16F877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
void main() {
int value;
setup_ccp1(CCP_PWM);
setup_timer_2(T2_DIV_BY_16, 249, 5);
setup_port_a(ALL_ANALOG);
setup_adc(adc_clock_internal);
set_adc_channel( 0 );
while( TRUE ) {
value=read_adc();
set_pwm1_duty(value);
}
} |
|
|