![]() |
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 } } |
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.
|
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 changedwhich is where this comes into play: Code:
if(Port_B_Delta & 0x10) // did external interrupt 3 change state? |
| All times are GMT -5. The time now is 23:51. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi