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

How do you enable 4 PWM outputs on PIC18F4320?

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







How do you enable 4 PWM outputs on PIC18F4320?
PostPosted: Fri Jun 13, 2003 3:41 am     Reply with quote

I am having trouble enabling the 4 PWM outputs available on the PIC18F4320 - it's part of the Enhanced CCP module.

I would like to use them as 4 separate PWM's all running off TMR2 but with different duty cycles.

In the data sheet it says (16.0 ECCP Module) - 'The ECCP module differs from the CCP with the addition of an enhanced PWM mode, which allows for 2 or 4 output channels...'

CCP1CON allows you to setup ECCP
CCP1CON<3:0>
1100 = PWM mode; P1A, P1C active high; P1B, P1D active high

but then...
CCP1CON<7:6>
00 = Single output; P1A modulated; P1B, P1C, P1D assigned as port pins????????????????

Does this mean that the ECCP only allows these 4 PWM outputs to be used as part of the Bridge modes??
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515205
R.J.Hamlett
Guest







Re: How do you enable 4 PWM outputs on PIC18F4320?
PostPosted: Fri Jun 13, 2003 5:25 am     Reply with quote

:=I am having trouble enabling the 4 PWM outputs available on the PIC18F4320 - it's part of the Enhanced CCP module.
:=
:=I would like to use them as 4 separate PWM's all running off TMR2 but with different duty cycles.
:=
:=In the data sheet it says (16.0 ECCP Module) - 'The ECCP module differs from the CCP with the addition of an enhanced PWM mode, which allows for 2 or 4 output channels...'
:=
:=CCP1CON allows you to setup ECCP
:=CCP1CON<3:0>
:=1100 = PWM mode; P1A, P1C active high; P1B, P1D active high
:=
:=but then...
:=CCP1CON<7:6>
:=00 = Single output; P1A modulated; P1B, P1C, P1D assigned as port pins????????????????
:=
:=Does this mean that the ECCP only allows these 4 PWM outputs to be used as part of the Bridge modes??

Basically yes.
The possible output configurations, are illustrated as figures 16.2 onwards. You can have a total of four outputs, but only two at a time carry PWM signals.
I have never 'played' with trying to generate four signals like this, on the new chips, but two possible solutions exist:
The first is that you may be able to use the units in CCP mode. You would have to look to see if you can have four seperate CCP outputs?.
The second (if the frequencies needed are not too high), is to consider a 'phase machine', driven off one timer, probably with the interrupt handler written in assembler, to control the four pins. I have done this in the past on chips with less sophisticated CCP modules.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515206
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