gnupic: CCP in compare mode problem with PIC16F877


Previous by date: 9 May 2002 09:08:43 -0000 Re: CCP in compare mode problem with PIC16F877, Ulrich Dziergwa
Next by date: 9 May 2002 09:08:43 -0000 gputils-0.10.3, Craig Franklin
Previous in thread: 9 May 2002 09:08:43 -0000 Re: CCP in compare mode problem with PIC16F877, Ulrich Dziergwa
Next in thread:

Subject: Re: CCP in compare mode problem with PIC16F877
From: massimiliano ruggeri ####@####.####
Date: 9 May 2002 09:08:43 -0000
Message-Id: <3CDA39D7.AE3F6FEB@cemoter.bo.cnr.it>

Hi all,
Thank you very much Josef, Ulrich and Stefano for the answer.

I have a backup solution: the solution is to use the CCPx modules
using the software interrput on match (the pin status remain unchanged),
using the CCPx match interrupt to reset the RCx pin and using the TIMER1
interrupt (on overflow with agood prescaler and preset for my base period for PWM)
to set the RCx pin; it runs properly. Total: 3 interrupt.

What I'm trying, is to use the Compare modules in the classical manner:
The TIMER1 (setting a right prescaler and preset) is used to have the
period that's necessary to have my desired frequency;
using the TIMER1 interrupt on overflow, I can set the PIN RC1 and RC2 high,
and (i believe) when the CCPx module match the actual TIMER1 value,
then without a interrupt, the PIN switch to low value.
In this way with only a interrupt I can control two PWM.

But unfortunately it seems not possible.

And I think that isn't a compiler problem or register setting, because I tryed this also using ICE2000
emulator, setting directly the pin status: You change RC1 status, you do a step and
someone (?) reset the pin!!!!!
Only if you change the CCP mode, then you can change the pin status.
Then I think that what Josef sed ("I believe you cannot access the RC1 & RC2 via PORTC
when the compare module controls the pin. ...") Is right!

If we use the CCP compare mode, reprogramming the "mode" (with CCP1CON and CCP2CON) and
match value every half period (every high pin status period and low pin status period)
of a PWM, then it runs (probably), but what's the difference on using classic interrupt software procedure?
Then next time I will buy a micro without CCP and I will save money!

Interrupt is good, but in my project i will use also interrupt for a CAN communication using the MCP2510 from
microchip and other interrupt for 3 frequential inputs from a hall effect sensor (flywheel).....
and also I tryed to use interrupt, but remeber that you must take in cont the interrupt latency time
(@ 4MHz with no prescaler for TIMER1, then TIMER1 runs @ 1MHz, it will be around 23 - 27 counts of TIMER1).

Using CCP in compare mode, you have the chance to be more precise, but I don't have now the final solution to do this.
What I see, is that the CCP in interrupt software mode is good and you don't have the problem of reprogramming
different values in TIMER1 (to identify the switch time for both pins), and also the interrupt are very fast (only two bit reset).

But it isn't the best way!

Best regards

and thank you for all.

Max

--------------
Massimiliano Ruggeri
CEMOTER - C.N.R.
National Research Council Of Italy
Fluid Power Group
####@####.####
www.cemoter.bo.cnr.it



Snail Instruments wrote:

> Hi Massimiliano,
>
> I believe you cannot access the RC1 & RC2 via PORTC when the compare module controls the pin. There is also limitation on using two compares: "The compare(s) should be configured for the special event trigger, which clears TMR1".
>
> What do you need to achieve - a low frequency PWM on two pins? I cannot come up with a strightforward solution right now, but it doesn't sound impossible.
>
> Regards,
>
> Josef


Previous by date: 9 May 2002 09:08:43 -0000 Re: CCP in compare mode problem with PIC16F877, Ulrich Dziergwa
Next by date: 9 May 2002 09:08:43 -0000 gputils-0.10.3, Craig Franklin
Previous in thread: 9 May 2002 09:08:43 -0000 Re: CCP in compare mode problem with PIC16F877, Ulrich Dziergwa
Next in thread:


Powered by ezmlm-browse 0.20.