Go to Post Can't engineers be jesters? - danielkitchener [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 28-01-2008, 20:59
cprogrammer's Avatar
cprogrammer cprogrammer is offline
Registered User
FRC #1595 (Gremlins)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Washington
Posts: 42
cprogrammer will become famous soon enoughcprogrammer will become famous soon enough
Question PORTB Help

I was looking through Kevin's Encoder program and noticed that in order to use the extra encoders, Kevin had to use the bundled interrupts. In order to distinguish between the interrupts, Kevin used PORTB to see which of the 4 fired. I was wondering what the PORTB extacly is, and how can I implement this myself.

Thanks Stephen

else if (INTCONbits.RBIF && INTCONbits.RBIE) // encoder 3-6 interrupt?
{
Port_B = PORTB; // remove the "mismatch condition" by reading port b
INTCONbits.RBIF = 0; // clear the interrupt flag
Port_B_Delta = Port_B ^ Old_Port_B; // determine which bits have changed
Old_Port_B = Port_B; // save a copy of port b for next time around

if(Port_B_Delta & 0x10) // did external interrupt 3 change state?
{
#ifdef ENABLE_ENCODER_3
Encoder_3_Int_Handler(Port_B & 0x10 ? 1 : 0); // call the encoder 3 interrupt handler (in encoder.c)
#endif
}
if(Port_B_Delta & 0x20) // did external interrupt 4 change state?
{
#ifdef ENABLE_ENCODER_4
Encoder_4_Int_Handler(Port_B & 0x20 ? 1 : 0); // call the encoder 4 interrupt handler (in encoder.c)
#endif
}
if(Port_B_Delta & 0x40) // did external interrupt 5 change state?
{
#ifdef ENABLE_ENCODER_5
Encoder_5_Int_Handler(Port_B & 0x40 ? 1 : 0); // call the encoder 5 interrupt handler (in encoder.c)
#endif
}
if(Port_B_Delta & 0x80) // did external interrupt 6 change state?
{
#ifdef ENABLE_ENCODER_6
Encoder_6_Int_Handler(Port_B & 0x80 ? 1 : 0); // call the encoder 6 interrupt handler (in encoder.c)
#endif
}
}

Last edited by cprogrammer : 28-01-2008 at 21:38.
  #2   Spotlight this post!  
Unread 28-01-2008, 22:03
tseres's Avatar
tseres tseres is offline
obsessed with FIRST...
FRC #1565 (Think Tank Tech)
Team Role: Leadership
 
Join Date: Apr 2007
Rookie Year: 2007
Location: Cambridge, ON
Posts: 305
tseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of light
Re: PORTB Help

dont worry about it. FYI though, it's an I/O port on the microcontroller. (i know this cuz i'm trying to learn the PIC). for more info, look to the pic18f8722 data sheet, but try to avoid going into the chip architechture oif at all possible, unless you really want to.
__________________


  #3   Spotlight this post!  
Unread 28-01-2008, 23:00
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 325
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: PORTB Help

PORTB is a register value for each of (1-7)? digital_io. It says what each bit is in the datasheet, I would suggest taking a look at that.

basically

Code:
Port_B_Delta = Port_B ^ Old_Port_B; // determine which bits have changed
that line uses the XOR to compare the new value to the old one. so if you have 10010101 as your old one and 10000101 as your new one the "Port_B_Delta" will be 00010000 which is also = 0x10 in hex and = 16 in our regular number system.

which is where this comes into play:
Code:
if(Port_B_Delta & 0x10) // did external interrupt 3 change state?
{
or something like that...
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -
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
Grab Frame - Help Help Help... nmihailidis Programming 2 04-03-2007 14:44
section 'InterruptVectorLow' type is non-overlay (was: HELP HELP HELP!!!!!) naor52 Programming 14 24-02-2007 01:19
Help: How do we get a teacher to help? (was: Help) ChaosAlchimey General Forum 13 21-01-2007 11:57


All times are GMT -5. The time now is 19:13.

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