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

PWM's on the 18f4680

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



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PWM's on the 18f4680
PostPosted: Tue Aug 04, 2009 9:15 am     Reply with quote

I have a board that uses an 18F452, but I desperately need more rom space. I would like to keep everything else as close as possible. I started looking at the 18F4680. Right now I use 2 PWM signals. The 4680 has 1 CCP and an enhanced CCP. It looks to me that the Enhanced CCP has 4 pwm's but they are not independent, but can only be used as Half or full bridge drivers. It does have a single pwm mode where it says it acts like CCP1. I'm assuming that means that I can't use the regular ccp1 and the enhanced ccp1, does anyone know if that is true?
The data sheet talks about each one by itself, but I don't see where it says if they can be used at the same time. Does anyone have any experience with this?
Thanks
Ringo
_________________
Ringo Davis
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 04, 2009 3:36 pm     Reply with quote

I don't have your PIC, but I do have an 18F4620. It also has an ECCP
module for CCP1, and a normal PWM module for CCP2. The following
program shows how to setup both CCP modules for normal PWM.
Code:

#include <18F4620.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
 
 //=================================
void main()
{
// Setup for 3.9 KHz pwm frequency with 4 MHz oscillator.
setup_timer_2(T2_DIV_BY_1, 255, 1); 

// Setup the ECCP for PWM in normal mode on Pin C2.
setup_ccp1(CCP_PWM);
set_pwm1_duty(100);   // 40% duty cycle
   
// Setup CCP2 for PWM output on pin C1. 
setup_ccp2(CCP_PWM);
set_pwm2_duty(50);   // 20 % duty cycle

while(1);
}
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Tue Aug 04, 2009 3:52 pm     Reply with quote

Cool thanks, That is what I was hoping for.
Ringo
_________________
Ringo Davis
Ttelmah
Guest







PostPosted: Wed Aug 05, 2009 3:07 am     Reply with quote

It is also worth looking at the data sheet 'again'.
If you look at the section for the CCP, you get the line:

"PIC18F4585/4680 devices have two CCP1
(Capture/Compare/PWM) modules. CCP1, discussed in
this chapter, implements standard Capture, Compare
and Pulse-Width Modulation (PWM) modes.
ECCP1 implements an Enhanced PWM mode. The
ECCP1 implementation is discussed in Section 16.0
“Enhanced Capture/Compare/PWM (ECCP1)
Module”."

Then at the start of the ECCP section, you get:
"Capture,
Compare and single output PWM functions of the
ECCP1 module are the same as described for the
standard CCP1 module."

I must admit, the early MicroChip data sheets were far superior to the current offerings, in terms of clarity, but If you look at the above, and think about what it is saying, you have two modules, one CCP, and one ECCP. The standard operating modes of the ECCP module, are identical to a CCP, but then it has the 'extra' modes 'on top'.

Best Wishes
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Wed Aug 05, 2009 7:32 am     Reply with quote

It was the line
"Compare and single output PWM functions of the
ECCP1 module are the same as described for the
standard CCP1 module."

That gave me doubts. When it said "Same as" I did not know if that meant it was one or the other.
Also, how to use it with the compiler was another question. But now I see that you use it like it was a second CCP.
Ringo
_________________
Ringo Davis
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