Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Question about kevin's code (http://www.chiefdelphi.com/forums/showthread.php?t=38690)

ImmortalAres 22-06-2005 14:18

Question about kevin's code
 
the code found here: http://kevin.org/frc/edu_accel_lcd.zip

contains the following

Code:


// initialize CCP modules 2 & 3
        TRISEbits.TRISE7 = 1;                // set CCP pins to inputs
        TRISGbits.TRISG0 = 1;

        PIE2bits.CCP2IE = 0;                // disable the CCP interrupts
        PIE3bits.CCP3IE = 0;

        T3CONbits.T3CCP1 = 0;                // CCP 2 captures timer 1, CCP 3 captures timer 3
        T3CONbits.T3CCP2 = 1;

        CCP2CON = 0x05;                                // initialize CCP modules to capture on each rising edge
        CCP3CON = 0x05;

        IPR2bits.CCP2IP = 0;                // CCP modules use the low priority interrupt
        IPR3bits.CCP3IP = 0;                //

        PIR2bits.CCP2IF = 0;                // make sure the interrupt flags are zero before...
        PIR3bits.CCP3IF = 0;                //

        PIE2bits.CCP2IE = 1;                // enable the CCP interrupts
        PIE3bits.CCP3IE = 1;                //

my question is about the 2 lines

Code:


T3CONbits.T3CCP1 = 0;                // CCP 2 captures timer 1, CCP 3 captures timer 3
T3CONbits.T3CCP2 = 1;

this doesn't make sense to me. can someone please explain what's going on, the comment doesn't seem to match the code or does it and i'm jsut missing it

Thanks

Ryan M. 22-06-2005 16:11

Re: Question about kevin's code
 
I think that it means that whichever one you set to 1 will be the one that works.

That help any?

Dave Flowerday 22-06-2005 17:24

Re: Question about kevin's code
 
Quote:

Originally Posted by ImmortalAres
my question is about the 2 lines

Code:


T3CONbits.T3CCP1 = 0;                // CCP 2 captures timer 1, CCP 3 captures timer 3
T3CONbits.T3CCP2 = 1;

this doesn't make sense to me. can someone please explain what's going on, the comment doesn't seem to match the code or does it and i'm jsut missing it

Take a look at the datasheet, page 152, specifically figure 16-1. Notice Kevin is setting T3CCP1 to 0 and T3CCP2 to 1, which corresponds to T3CCP<2:1> = 10 in that figure. This shows that timers 1 and 2 are connected to CCP1 and CCP2, and timers 3 and 4 are connected to CCP3, 4, and 5. Then look at table 16-1 in the upper right corner, which says that in capture mode, timers 1 and 3 are available. You can check the settings of CCP2CON and CCP3CON to see that they are being set to capture mode, so you can conclude from all this that CCP2 captures timer 1 and CCP3 captures timer 3, just like the comment says.

ImmortalAres 23-06-2005 11:13

Re: Question about kevin's code
 
Quote:

Notice Kevin is setting T3CCP1 to 0 and T3CCP2 to 1, which corresponds to T3CCP<2:1> = 10 in that figure.
i didn't realize that was what occurred. If i reversed it, T3CCP1 to 1 and T3CCP2 to 0 i should get the T3CCP<2:1> = 01 configuration correct?


All times are GMT -5. The time now is 04:39.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi