![]() |
Confused about Interrupts
why is it that in setting up priority levels for interrupts, the parent intcon number changes:
INTCON3bits.INT2IP = 0; // Pin 1 INTCON2bits.INT3IP = 0; // Pin 2 INTCON2bits.RBIP = 0; // Pins 3, 4, 5, 6 but in setting up edge select, pin 1 and pin 2 are both intcon2bits: INTCON2bits.INTEDG2 = 1; // Pin 1 INTCON2bits.INTEDG3 = 1; // Pin 2 and then when setting interrupt flags, they both turn into 3s? INTCON3bits.INT2IF = 0; // Pin 1 INTCON3bits.INT3IF = 0; // Pin 2 INTCONbits.RBIF = 0; // Pins 3, 4, 5, 6 (not to mention pins 3,4,5,6 going from 2 to no number) i got this code from the interrupts_for_dummies pdf in the white pages, so i'm assuming that this is correct code. is it all just arbitrary, or what? what am i missing here? :ahh: |
Re: Confused about Interrupts
Hardly arbitrary. Read chapter 10 of PICmicro® 18C MCU Family Reference Manual
|
Re: Confused about Interrupts
indeed. The documentation usually helps :-P.
INTCON3 is an 8-bit register in the microcontroller. Since there are 8 bits, it can hold 8 binary values. The reason there are multiple INTCON (interrupt control) registers is that there are more than 8 binary values needed to control interrupts. Seriously, if you're doing something as low level as interupts, scan the datasheet and get familiar with the processor. It'll do you good in the end. |
Re: Confused about Interrupts
alright, understood.
but it'd still be nice if they at least tried to be a little consistent... |
Re: Confused about Interrupts
To the interrupt-capable amongst us, an additional conundrum. From reading Interrupts for Dummies, it appears that Dig IO pins 1-6 can be used for interrupts.
Why then, does Kevin's encoder routine use pins 1 and 6 for one side and 2 and 8 for the other? If you want to use other Hall encoders, how many can you use? is 6 the magic number, or is only 2? (pins 1 and 2) Jon from Team 236 Quote:
|
Re: Confused about Interrupts
Quote:
|
Re: Confused about Interrupts
This is in the encoder.c file:
Five things must be done before this software will work * correctly on the FRC-RC: * * 1) The left encoder's phase-A output is wired to digital input * one and the phase-B output is wired to digital I/O six. * * 2) The right encoder's phase-A output is wired to digital input * two and the phase-B output is wired to digital I/O 8. * * 3) Digital I/O pins one, two, six and eight are configured as * inputs in user_routines.c/User_Initialization(). If you notice * that the encoder only counts in one direction, you forgot to * do this step. * * 4) A #include statement for the encoder.h header file must be * included at the beginning of each source file that calls the * functions in this source file. The statement should look like * this: #include "encoder.h". * * 5) Initialize_Encoders() must be called from user_routines.c/ * User_Initialization(). * has it been changed? Jon Quote:
|
Re: Confused about Interrupts
Quote:
|
Re: Confused about Interrupts
Quote:
3) Digital I/O pins one, two, six and eight are configured as inputs in user_routines.c/User_Initialization(). If you notice that the encoder only counts in one direction, you forgot to do this step. -Kevin |
Re: Confused about Interrupts
Kevin,
So for quadrature sensors, how many can we use? I would like to use 2 others, for a total of 4 (including the L & R wheel ones). Is that possible? Which pins should I use? Jon Quote:
|
Re: Confused about Interrupts
yes, but I think he wants help setting up the interrupt code to support 4 interrupts, versus the two it already has. I have the same problem. I'm gonna try to add to Mr. Watson's template to handle 2 more quadrature encoders (phase a and b encoders), and I'll test it on last year's bot. I may, however, need a little help on referencing digitals 3-6 as interrupts, since they are banded together.
|
Re: Confused about Interrupts
Quote:
|
| All times are GMT -5. The time now is 22:23. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi