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

Odd Error: PWM output pin @0 already used for PWM1 [SOLVED]

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



Joined: 17 Sep 2003
Posts: 97
Location: Atlanta, GA, USA

View user's profile Send private message

Odd Error: PWM output pin @0 already used for PWM1 [SOLVED]
PostPosted: Tue Dec 04, 2018 1:48 pm     Reply with quote

Hi, I'm working with a PIC18F67K40 which uses PPS pins and I'm compiling with V5.078.

For this project I thought I'd try the #use pwm" functions along with pwm_set_duty_percent() for the first time. But there is an error I do not understand. The header has this:
Code:
///// Variable Speed Fan /////
#pin_select CCP4OUT=PIN_G3
#use pwm(CCP4, TIMER=2, FREQUENCY=100, DUTY=50, STREAM=PWM_FAN)

///// Variable Speed Pump /////
#pin_select CCP5OUT=PIN_G4
#use pwm(CCP5, TIMER=5, FREQUENCY=100, DUTY=50, STREAM=PWM_PUMP)


When I try to compile, I get the error:
Quote:
Error#99 Option invalid PWM output pin @0 already used for PWM1

This error points to the second #use line in the header file. I have selected two different pins, two different CCP ports, and two different timers. Any suggestions on what I have setup incorrectly here?

Thanks,
Kyle


Last edited by kda406 on Thu Dec 06, 2018 10:37 am; edited 5 times in total
kda406



Joined: 17 Sep 2003
Posts: 97
Location: Atlanta, GA, USA

View user's profile Send private message

PostPosted: Tue Dec 04, 2018 2:02 pm     Reply with quote

I discovered a minor typo. The second #use pwm line should be timer 6, not timer 5.
Code:
#use pwm(CCP5, TIMER=6, FREQUENCY=100, DUTY=50, STREAM=PWM_PUMP)

However, after fixing that, I still have the same error as the original post.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Dec 04, 2018 2:12 pm     Reply with quote

Look at page 229 in the data sheet.
On this chip, PPS doesn't have a 'free hand' to remap peripherals. CCP1 &
CCP2 can only be mapped to ports C & E.
gaugeguy



Joined: 05 Apr 2011
Posts: 286

View user's profile Send private message

PostPosted: Tue Dec 04, 2018 2:21 pm     Reply with quote

I wonder if it might be an error to bring up with CCS. CCP4 & CCP5 can be mapped to ports E and G and the default for CCP4 is RG3 and for CCP5 is RG4
kda406



Joined: 17 Sep 2003
Posts: 97
Location: Atlanta, GA, USA

View user's profile Send private message

PostPosted: Tue Dec 04, 2018 2:22 pm     Reply with quote

I'm using CCP4 & CCP5 which are on on ports E & G. I've called out port G pins.
dluu13



Joined: 28 Sep 2018
Posts: 395
Location: Toronto, ON

View user's profile Send private message Visit poster's website

PostPosted: Tue Dec 04, 2018 2:31 pm     Reply with quote

What happens if you try to only turn on one CCP module at a time?
kda406



Joined: 17 Sep 2003
Posts: 97
Location: Atlanta, GA, USA

View user's profile Send private message

PostPosted: Tue Dec 04, 2018 2:33 pm     Reply with quote

Great question! If I remark out either one, the other works - Build Successful.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Dec 04, 2018 2:40 pm     Reply with quote

I must admit it does sound like a compiler issue.
You could try setting up the PWM's not using #use, and using the 'inline' pin_select command, and see if this gets round the problem.
Though the compiler should combine all #PIN_SELECT lines into one set of settings, it is worth seeing if disabling the PPS1WAY fuse might affect things.

The 'heading', makes me think the compiler believes he is setting PWM1, and therefore complains about the port being used.....
kda406



Joined: 17 Sep 2003
Posts: 97
Location: Atlanta, GA, USA

View user's profile Send private message

PostPosted: Wed Dec 05, 2018 11:00 am     Reply with quote

I already had PPS1WAY disabled. I upgraded to the latest (v5.081) and the problem persists. I will report the problem to CCS.

Thanks,
Kyle
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Dec 05, 2018 11:19 am     Reply with quote

It actually does it on the second #use PWM, even without a pin select at all.
I suspect it is a fault in the #use PWM. If I get time I was going to try setting
up the PWM without using the #use, and see if it still gives an issue.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Dec 05, 2018 2:55 pm     Reply with quote

Can confirm, it does build correctly, if you use the setup_timer, and setup_ccp, rather than #use PWM.
Obviously you don't get an automatic scaling to give 0-100 out, but the #PIN_SELECT's all work, and the PWM seems to setup right. On MPLAB sim, they both give outputs.
kda406



Joined: 17 Sep 2003
Posts: 97
Location: Atlanta, GA, USA

View user's profile Send private message

PostPosted: Wed Dec 05, 2018 2:59 pm     Reply with quote

I can confirm that. Using the setup_ccpX() and setup_timer_X() method seems to compile and work.

I sent in the report to CCS about #use pwm, but have not heard back from them.
kda406



Joined: 17 Sep 2003
Posts: 97
Location: Atlanta, GA, USA

View user's profile Send private message

PostPosted: Thu Dec 06, 2018 10:35 am     Reply with quote

CCS sent me a working solution.
Code:
#use pwm(CCP4, output=PIN_G3, TIMER=2, FREQUENCY=100, DUTY=50, STREAM=PWM_FAN)
#use pwm(CCP5, output=PIN_G4, TIMER=6, FREQUENCY=100, DUTY=50, STREAM=PWM_PUMP)

It compiles and seems to work for the two PWM outputs on the two PPS assigned CCP channels.

They were not very verbose, but it appears the originally posted code was correct, and they mentioned adding a fix in an upcoming release. For now, we can just use this very similar code.

Thanks for the help folks!!!!!

-Kyle
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Dec 06, 2018 2:16 pm     Reply with quote

Yes, it did look to be an internal issue with the command.
At least you are running now... Smile
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