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 CCS Technical Support

pwm weird output

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



Joined: 11 Jan 2007
Posts: 9
Location: Philadelphia, PA, USA

View user's profile Send private message

pwm weird output
PostPosted: Mon Jan 22, 2007 3:27 pm     Reply with quote

hi i setup my pwm as such

EDIT: reposted code

Code:

#include <18F2680.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, BRGH1OK)  // Jumpers: 8 to 11, 7 to 12



void main() {
   char selection;
   signed int16 value;

  setup_ccp1(CCP_PWM);   // Configure CCP1 as a PWM
   setup_timer_2(T2_DIV_BY_1, 127, 1);
   value=0x01FF;
   printf("%4X\r",value);
   set_pwm1_duty(value);          // This sets the time the pulse is
}


but the output voltage is flat at 1.68 volts on the scope .... it is the same thing for all values of pwm duty from 1 to 255 ???
i am using a 18f2680

thanks


Last edited by pwhitey86 on Mon Jan 22, 2007 5:22 pm; edited 1 time in total
Ttelmah
Guest







PostPosted: Mon Jan 22, 2007 4:46 pm     Reply with quote

Repost the code.
At the moment, what you have, makes no sense, with two trailing braces, and the code just setting up the PWM, and running off the end putting the PIC to sleep. Normally this is caused by not hitting the 'Disable HTML in this post' tick box, when posting code, which if left unticked, makes code unreadable...

Best Wishes
pwhitey86



Joined: 11 Jan 2007
Posts: 9
Location: Philadelphia, PA, USA

View user's profile Send private message

should have searched more
PostPosted: Mon Jan 22, 2007 5:40 pm     Reply with quote

this post helped

i forgot the while(1) at the end so it wouldn't sleep

http://www.ccsinfo.com/forum/viewtopic.php?t=17729&highlight=pwm+middle
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