Home/Support/Support Forum/How to use external interrupts - beware of example code
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

How to use external interrupts - beware of example code

0 votes
the external interrupt example code works fine but not when copied over to another program
asked Jun 26, 2013 in Rabbit Software by esterer New to the Community (2 points)

Please log in or register to answer this question.

1 Answer

0 votes
The example code sets all of port E to inputs which only works if your setup is this way. If it's not, then weird things happen.
You can watch the return code to see:

rc = RdPortI(PEDDRShadow); //if a bit is set, it's an output
rc = rc & 0xCF;
WrPortI(PEDDR, &PEDDRShadow, rc); // just make PE4 and PE5 as inputs. Leave the rest alone


The second problem is that they enable PE0 and PE1 as interrupts. On the SBC2100 these are not external interrupts. Only PE4 and PE5 come out to one terminal.
So when enabling interrupts, don't enable them like in the example code.
WrPortI(I0CR, &I0CRShadow, 0x23); // enable external INT0 on PE4, rising edge priority 3
WrPortI(I1CR, &I1CRShadow, 0x23); // enable external INT1 on PE5, rising edge, priority 3
You can find the definition of the control register bits in the processor documentation.

Since there is only one input terminal, you get both interrupts 0 and 1 with one pulse. You can use the same routine for both interrupts but if you are incrementing a counter you will get 2 counts per pulse.
SetVectExtern3000( 0,my_isr);
SetVectExtern3000( 1,my_isr);

It will actually work with only one enabled interrupt but there could be a problem with missing pulses - see the tech note.
answered Jun 26, 2013 by esterer New to the Community (2 points)
...