View previous topic :: View next topic |
Author |
Message |
mcr1981
Joined: 27 Oct 2010 Posts: 28
|
Question about the new #preprocessor configurations..... |
Posted: Fri Jan 17, 2014 6:56 pm |
|
|
Hello.
I searched the forum for:
Code: | set_pwm_duty_percent()
#use pwm |
and found no results that were adequate for me.
I'm trying to use these new pre-processing configurations. I've managed to get the OC running with 100 Hz and 1000 Hz with this line of code:
Code: | #use pwm(OC1,TIMER=1,FREQUENCY=100,DUTY=50) |
and it outputs the correct frequency with it's correct duty cycle.
If I try to use the
Code: | set_pwm_duty_percent() |
the compiler complaints and will not compile arguing that the function is not defined.
If I use the
I can modify the duty with the integer value adequate for a percentage, but not the percentage it self like the function set_pwm_duty_percent() implies (have to take the resolution bits and scale).
The PCD manual states something about STREAM = id for one to use the built in functions (_bif)
Associates a stream identifier with the PWM signal. The identifier may be used in functions like pwm_set_duty_percent().
It might be my lack of knowledge of the English language, but can't seem to make it work.
Have anyone used this new feature?
Thanks.
EDIT:
I use Mplab X and PCD (5.016). |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 17, 2014 7:51 pm |
|
|
Quote: | I searched the forum for:
set_pwm_duty_percent() |
In the PCM/PCH compiler manual, it says the actual function name is:
Quote: | pwm_set_duty_percent() |
which is different from your search.
Always post your PIC. |
|
|
mcr1981
Joined: 27 Oct 2010 Posts: 28
|
|
Posted: Fri Jan 17, 2014 8:38 pm |
|
|
PCM programmer wrote: | Quote: | I searched the forum for:
set_pwm_duty_percent() |
In the PCM/PCH compiler manual, it says the actual function name is:
Quote: | pwm_set_duty_percent() |
which is different from your search.
Always post your PIC. |
set_pwm_duty_percent() is the one that's listed on page 128 of the PCD manual. Did not bother looking for it later in the manual (did a search and obviously did not find anything).
When I get my hands on the laptop will test this.
Using 24FV32KA302. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 17, 2014 10:37 pm |
|
|
The current PCD manual, dated 08-Oct-13 also calls the function this:
Quote: | pwm_set_duty_percent |
You're using vs. 5.016, which is a very current version (5.017 is the latest)
so you should be using the most current PCD manual:
http://www.ccsinfo.com/downloads.php#manuals |
|
|
mcr1981
Joined: 27 Oct 2010 Posts: 28
|
Have the same manual.... |
Posted: Sat Jan 18, 2014 11:29 am |
|
|
When you told me that I though I was wrong. But after looking into it came to the same conclusion: I'm right
If you look at the #use pwm page you'll see that it tells you to use the set_pwm_duty_percent() in page 128.
Although it says October 8th in the download page, the actual manual says September 2013.
Will upgrade to 5.017 also.
Thanks.
PS:
It does work, the function. It makes the linear relation with math, that's why it says it's slower than the set_pwm_duty() one.
Reminds me of a function in Arduino, can't rember it now.
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jan 18, 2014 12:08 pm |
|
|
I agree. That's at the end of the #use PWM section. That's a bug in the
manual and should be reported to CCS, except that the manual has so
many little bugs, that it really needs to be printed, redlined, and mailed
to CCS. I don't have the energy to do that.
I didn't see that at the end of #use PWM, because I went directly to the full
section on the pwm_set_duty_percent() function itself. I didn't look at the
#use PWM section. |
|
|
|