CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

16F690 PWM setup

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
GhostofK
Guest







16F690 PWM setup
PostPosted: Fri Jun 02, 2006 7:52 pm     Reply with quote

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);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 02, 2006 8:09 pm     Reply with quote

See the example that I've posted in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=17729

Note the things in that example that are missing from your code:
It has a #fuses statement, and a while(1) statement at the end.
Note the things that are not needed: set_tris_x() statements.

That example shows how to setup two PWMs, but it is still
applicable to your situation.
GhostofK
Guest







PostPosted: Fri Jun 02, 2006 8:36 pm     Reply with quote

AWESOME. It works! Thanks!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group