|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? ![]() Last edited by karch : 29-01-2005 at 04:12. |
|
#2
|
||||
|
||||
|
Re: Confused about Interrupts
Hardly arbitrary. Read chapter 10 of PICmicro® 18C MCU Family Reference Manual
|
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
Re: Confused about Interrupts
alright, understood.
but it'd still be nice if they at least tried to be a little consistent... |
|
#5
|
||||
|
||||
|
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:
|
|
#6
|
||||
|
||||
|
Re: Confused about Interrupts
Quote:
|
|
#7
|
||||
|
||||
|
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:
|
|
#8
|
||||
|
||||
|
Re: Confused about Interrupts
Quote:
|
|
#9
|
||||
|
||||
|
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 |
|
#10
|
||||
|
||||
|
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:
|
|
#11
|
|||
|
|||
|
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.
|
|
#12
|
||||
|
||||
|
Re: Confused about Interrupts
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| White Paper Discuss: Interrupts for Dummies | CD47-Bot | Extra Discussion | 5 | 29-01-2005 03:24 |
| FYI about using PWM 13-16 with interrupts | cabbagekid2 | Programming | 6 | 22-01-2005 00:54 |
| INT2 and INT3 interrupts not working | Mercutio | Programming | 4 | 01-02-2004 13:27 |
| Problem with interrupts on the PIC | Mike Betts | Programming | 7 | 16-12-2003 21:26 |
| Finding myself quite confused... | Alphawolf829 | Robotics Education and Curriculum | 8 | 16-12-2002 20:19 |