Help me get the right PWM of PIC16F690

Status
Not open for further replies.

ahmet2004

Member level 3
Joined
Jan 1, 2004
Messages
63
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Activity points
383
Hi, I'm trying to get the PWM of my PIC16F690 working. Unfortunately, no matter what I do, I can't seem to make the thing output what I want. Ideally, I want to have the CCP1 pin always output a constant 40Khz square wave, 50% duty cycle. However, I always get a constant voltage out for some reason. I've been looking at the provided examples from CCS and I've been poking aroun this forum too, but nothing seems to work. Can someone have a quick look at my code and tell me what I'm doing wrong? The compiler version is 3.243 btw.

Thanks for any help!


#include <16F690.h>
#use delay(clock=4000000)

void main(){
set_tris_a(0x00);
set_tris_b(0x00);
set_tris_c(0x00);

setup_ccp1(CCP_PWM);
setup_timer_2(T2_DIV_BY_1, 24, 1);
set_pwm1_duty(20);
}
 

pwm pic16f690

See Ex_pwm.c in examples folder of ccs.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…