|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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
|
||||
|
||||
|
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
|
||||
|
||||
|
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 which is where this comes into play: Code:
if(Port_B_Delta & 0x10) // did external interrupt 3 change state?
{
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |