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

Question about the new #preprocessor configurations.....

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



Joined: 27 Oct 2010
Posts: 28

View user's profile Send private message

Question about the new #preprocessor configurations.....
PostPosted: Fri Jan 17, 2014 6:56 pm     Reply with quote

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
Code:
set_pwm_duty()

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

View user's profile Send private message

PostPosted: Fri Jan 17, 2014 7:51 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jan 17, 2014 8:38 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jan 17, 2014 10:37 pm     Reply with quote

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

View user's profile Send private message

Have the same manual....
PostPosted: Sat Jan 18, 2014 11:29 am     Reply with quote

When you told me that I though I was wrong. But after looking into it came to the same conclusion: I'm right Shocked


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

View user's profile Send private message

PostPosted: Sat Jan 18, 2014 12:08 pm     Reply with quote

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.
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