Monday, March 8, 2010

PWM (pic18f4550)

to use pwm here is the ccs code:

#include <18f4550.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock = 20000000)

void main() {
setup_ccp1(ccp_pwm); // Select timer and mode
set_pwm1_duty(25); // Set on time
setup_timer_2(T2_DIV_BY_16,248,1); // Clock rate & output period
while(1) { } // Wait until reset
}

pin17 ---> pwm output
+ everything was mentioned in previous posts in order to run a 18f pic.