Go to Post When we got it tuned to the point where we were (reasonably) confident it wouldn't slam into Dave's ankle, we quit for the evening. - Kevin Watson [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 22-06-2005, 14:18
ImmortalAres ImmortalAres is offline
Registered User
no team
 
Join Date: May 2005
Location: Clarkson University
Posts: 33
ImmortalAres is an unknown quantity at this point
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
  #2   Spotlight this post!  
Unread 22-06-2005, 16:11
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
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?
__________________

  #3   Spotlight this post!  
Unread 22-06-2005, 17:24
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
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.
  #4   Spotlight this post!  
Unread 23-06-2005, 11:13
ImmortalAres ImmortalAres is offline
Registered User
no team
 
Join Date: May 2005
Location: Clarkson University
Posts: 33
ImmortalAres is an unknown quantity at this point
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?
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can we load 2004 code? colt527 Programming 5 15-02-2005 19:48
Need Advice On Code Out Of Box...New To This gemccnp Programming 4 30-01-2005 18:57
Operator Interface code RiotingNerd Programming 5 07-02-2004 21:13
Rookie Programmer has question about the default code DanL Programming 3 26-01-2002 19:59


All times are GMT -5. The time now is 00:16.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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