|
|
View previous topic :: View next topic |
Author |
Message |
GhostofK Guest
|
16F690 PWM setup |
Posted: Fri Jun 02, 2006 7:52 pm |
|
|
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
|
|
Posted: Fri Jun 02, 2006 8:09 pm |
|
|
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
|
|
Posted: Fri Jun 02, 2006 8:36 pm |
|
|
AWESOME. It works! Thanks! |
|
|
|
|
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
|