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 signal generation on PIC18F27K40

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



Joined: 03 Jun 2009
Posts: 29

View user's profile Send private message

PWM signal generation on PIC18F27K40
PostPosted: Mon Feb 20, 2017 11:58 am     Reply with quote

I am trying to get a PWM signal on PIN_C2 and it's not working.
I am using the latest version of the compiler and my code looks like:
Code:
#pin_select CCP1OUT=PIN_C2
setup_ccp1(CCP_PWM);
set_pwm1_duty((int16)498);

The fact is that I am not getting any pulse on PIN_C2 (Checked with oscilloscope).
Any advice on how to proceed or what I am doing wrong?
Many thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Mon Feb 20, 2017 12:16 pm     Reply with quote

You haven't setup the timer....
Momboz



Joined: 03 Jun 2009
Posts: 29

View user's profile Send private message

PostPosted: Mon Feb 20, 2017 2:19 pm     Reply with quote

By searching the internet I found the following:
Code:
#use pwm(output=pin_a4, output=pin_b3, timer=1, frequency=1kHz, duty=75)

and this helped me a lot.
Thank for your help.
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Wed Feb 22, 2017 3:14 am     Reply with quote

That is the alternative way of setting up.

Beware though. With this you don't know how many bits of resolution the PWM is actually generating. Note that it is setting up the timer for you.....
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