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

#use pwm feature

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



Joined: 13 Jul 2017
Posts: 135
Location: IZMIR

View user's profile Send private message Send e-mail

#use pwm feature
PostPosted: Sat Jan 04, 2020 2:35 pm     Reply with quote

What do you think about the #use pwm property, which is the ccs c compiler property. With this feature, I can apply this to more than one pin.Well, you can apply to a pin that doesn't have this hardware, that is it doesn't have a (CCP) pin. How can this be? We also need to add something extra to the output we apply. Or do we see a square wave as a result of the values that we set directly from the output? If so, what is the difference between CCP and #use pwm? which one makes sense to use.
Code:

Setting up the software PWM is simple and easy. Any desired options for duty cycle, period, frequency, etc. may be set while only using one line of code. Below is an example that illustrates the setup of a typical PWM with two outputs, a frequency of 1 kHz, and a duty cycle of 75%.

#use pwm(output=pin_a4, output=pin_b3, timer=1, frequency=1kHz, duty=75)

_________________
Es
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jan 05, 2020 6:04 am     Reply with quote

I have an older version of the compiler

#USE PWM().section.

Selects the PWM pin to use, pin must be one of the CCP pins.

As for how it works, cut a small program,compile , then dump the listing. CCS doesn't hide any of the code.

Others who have a newer compiler may reply
ertansuluagac



Joined: 13 Jul 2017
Posts: 135
Location: IZMIR

View user's profile Send private message Send e-mail

PostPosted: Sun Jan 05, 2020 6:34 am     Reply with quote

compiler 5.092

In my opinion you know wrong. I think it can be used without CCP. Because CCS C wrote an example. I have tried. it worked at Proteus. I'm gonna set up Boarda circuit and try. But, I would like to get detailed information. So what's the difference with CCP. Will something extra be added to the circuit entrance? It is used for what purposes.
I think that Ttelmah knows best.
Smile Smile Smile
_________________
Es
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jan 05, 2020 6:47 am     Reply with quote

All the 'details' are in the compiled code. If you set to 'symbolic', the listing will show you exactly what it's doing to setup/load various registers as well as how it's not using CCP. PIC ASM ( instructions) are easy to learn and understand, all in the PIC datasheet. The CCS manual will give 'basic' how-to-use information, to KNOW what's happening and why, you need to read the datasheet for register configs and instruction set.
Since my compiler is older, I can't create a program that uses that preprocessor directive.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Sun Jan 05, 2020 7:28 am     Reply with quote

Ideally #USE PWM, wants a PWM or CCP pin.
However the later compilers can produce a _low frequency_ PWM
using a timer interrupt.
Downsides are:
1) Uses a lot of processor time.
2) Limited frequency.
3) Limited resolution.
4) Not as accurate.

Basically if you setup a PWM on a pin that doesn't support a hardware PWM,
then the processor will generate a timer interrupt, and drive a PWM using this
It changes the time programmed to reset the timer, according to the 'on'
and 'off' times needed. Accuracy will then be affected if any other interrupts
are in use.
The compiler will give you a warning message when this is used, giving the
minimum and maximum duty cycles that can be supported (depends on
how long it'll take to get into and out of the interrupt).
ertansuluagac



Joined: 13 Jul 2017
Posts: 135
Location: IZMIR

View user's profile Send private message Send e-mail

PostPosted: Mon Jan 06, 2020 11:11 am     Reply with quote

Thank you very much.
_________________
Es
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