View previous topic :: View next topic |
Author |
Message |
future
Joined: 14 May 2004 Posts: 330
|
PWM and two ccp at the same time? |
Posted: Sat Aug 01, 2009 2:15 pm |
|
|
Hi,
Can I have a pwm signal at ccp1 pin and 2 ccp interrupts working at the same time? It is a PIC18F.
Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Aug 01, 2009 2:25 pm |
|
|
See this example file:
Quote: | c:\Program Files\PICC\Drivers\Ex_Servos.c |
It has interrupt routines for both CCP1 and CCP2. |
|
|
future
Joined: 14 May 2004 Posts: 330
|
|
Posted: Sat Aug 01, 2009 2:33 pm |
|
|
Thank you for the answer.
Yes, both CCP interrupts working is fine. Let me explain better this time.
Both CCP interrupt only (no CCP1/CCP2 pin toggling just comparator match) plus PWM using timer2 on CCP1 pin. |
|
|
Ttelmah Guest
|
|
Posted: Sat Aug 01, 2009 2:51 pm |
|
|
Only on chips with a third CCP.
Some of the chips wth the ECCP module, have this as well as the standard two CCP's. The same registers are used on a CCP, to record the count values, _or_ to control it as a PWM. You can't perform both functions with one module.
Best Wishes |
|
|
future
Joined: 14 May 2004 Posts: 330
|
|
Posted: Sat Aug 01, 2009 3:25 pm |
|
|
Ok, the chip is the PIC18F4620, with ECCP. It is not clear to me in the datasheet if it is possible to do what I want.
The family I see with more than 2 ccp is the dspic. Do you know one of the 18F with 3 ccp? |
|
|
Ttelmah Guest
|
|
Posted: Sun Aug 02, 2009 2:28 am |
|
|
The ECCP on your chip, replaces CCP1.
If you look at Figure 16-1, you will see that the ECCP, has only one set of CCP registers (meaning only one capture possible), so your chip has a total of just two channels.
Chips in the 18J family (like the 18J50), have two normal CCP channels, _plus_ one or more ECCP modules, rather than having the ECCP replacing one of the normal CCP channels, and (for this example), there are three separate ECCP modules, rather than just a single register set, with multiple outputs, giving up to five CCP channels.
Generally, the 'extra' CCP channel chips, are all higher pin count devices, since implementing multiple channels all supporting capture or PWM, means lots of pins are needed. Chips like the 18F87J10, are the 'smallest', offering the extra channels I know of.
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah Guest
|
|
Posted: Mon Aug 03, 2009 2:36 am |
|
|
Yes, that ought to do what is wanted.
The funny thing was, I was 'sure' I had used a 40pin device wth an extra PWM, but could not find it when I looked.
Best Wishes |
|
|
|