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

PIC18F4431 & Power PWM

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



Joined: 07 Dec 2009
Posts: 7
Location: Bradford, West Yorkshire

View user's profile Send private message

PIC18F4431 & Power PWM
PostPosted: Wed Apr 28, 2010 10:13 am     Reply with quote

I am trying to get PWM3 (RB3 on PWM Generator #1) working on the Power PWM Module for the PIC18F4431 (QFN) but for some reason it gives me an 'Invalid PWM Combination' error.

My code is:
Code:

setup_power_pwm_pins( PWM_OFF, PWM_ODD_ON, PWM_OFF, PWM_OFF );
setup_power_pwm( PWM_CLOCK_DIV_4 | PWM_FREE_RUN, 2, 0, 999, 0, 0, 32 );

I have set PWM channel 1 to 'PWM_ODD_ON' and disabled the rest.
I want a frequency of 1KHz with an 8MHz Internal RC Oscillator.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 28, 2010 1:07 pm     Reply with quote

What's your compiler version ?

In vs. 4.107, CCS has commented out the PWM_OFF option, in 184431.h:
Code:

// Constants used for SETUP_POWER_PWM_PINS() are:
//#define PWM_OFF         0
#define PWM_ODD_ON        1
#define PWM_BOTH_ON       2
#define PWM_COMPLEMENTARY 3
dmccric



Joined: 07 Dec 2009
Posts: 7
Location: Bradford, West Yorkshire

View user's profile Send private message

PostPosted: Thu Apr 29, 2010 2:14 am     Reply with quote

I am on version 4.101 and I have noticed that define is uncommented but it is still in the file but further at the top.

I was wondering that I might have a compiler issue.
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Thu Apr 29, 2010 2:28 am     Reply with quote

The reason for the compiler 'moan' though, is that the chip doesn't support the combination you are trying for....
Look at register 17-3 in the data sheet. Do you see any combination here that gives PWM on PWM3 alone?.
Depending on what else you want to do, you may be able to get this 'functionally', by selecting the option that gives PWM1, _and_ PWM3 as outputs, and using the output override ability on PWM1 to give logic outputs when needed.

Best Wishes
dmccric



Joined: 07 Dec 2009
Posts: 7
Location: Bradford, West Yorkshire

View user's profile Send private message

PostPosted: Fri Apr 30, 2010 3:02 am     Reply with quote

for some reason someone has designed the hardware for this and add overkill. I am using the HIP4081 Full bridge fet driver which drives 4 fets.

So i only need 3 pins to drive the motor:

RB3/PWM3 -> PWM_EN
RB1/PWM1 -> PWM_FWD
RB4/PWM5 -> PWM_RVS


For Forward and Reverse I simply complement RB1 & RB4 and then PWM RB3, this could have been done by using the simpler CCP PWM but I did not design the hardware.

I am using the simulator to see my PWM signals but I only want RB3 to PWM and keep getting 'Invalid PWM Combination'.
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Fri Apr 30, 2010 5:56 am     Reply with quote

As I have said, the hardware won't do this.
What you need to do, is set PWM_ODD_ON, for both the first two combinations, and then use the output override ability to trun RB1 on/off, rather than output_high, or low. This overrides the PWM 'stream' on this pin, leaving RB3 as the only one outputting a PWM.

Best Wishes
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