Reading External Interrupts on Port E

Hello all,
I am new to Dynamic C and using a rabbit 3000 board. I am enabling external interrupts PE4 and PE0. I then try to read the bit in the interrupt service routine to see which one was triggered. However PEDR just always reads what it was in board init (0xE7). Should it change? What am I doing worng?

//board int
WrPortI(PECR, &PECRShadow, PECRShadow&0x00); //clear all bits to pclk/2

WrPortI(PEFR, &PEFRShadow, PECRShadow&0x00); //clear all bits to normal function

WrPortI(PEDR, &PEDRShadow,0xE7); //set bits 7,6,5,2,1,0 output high and
//set bits 4,3 output low

WrPortI(PEDDR, &PEDDRShadow, PEDDRShadow|0xFB); //set bits 7,6,5,4,3,2,1,0 to output

//set isr handler
SetVectExtern3000(0, &buttonPress_isr_S2);
SetVectExtern3000(1, &buttonPress_isr_S3);

//enable interrupt
WrPortI(I0CR, &I0CRShadow, 0x0D); // enable external INT0
//PG1 shorted to PE0,
//button S2 hrs
//falling edge,

debug root interrupt void buttonPress_isr_S2()
int ilocal;
ilocal= RdPortI(PEDR); //shouldn’t this tell me what edge trigger?

I would have assumed that at the very minimum you would need to set bits 0 and 4 as inputs if you want to be able to read the external state connected to them which requires setting PEDDR to 0xEE.

You might also need to set PEFR to 0x11 to enable special functions on those pins.


Thank you for the reply.

I tried using the values you specified and the values 0x00 as below

WrPortI(PEDDR, &PEDDRShadow, 0x00 ); // set port E as all inputs
WrPortI(PEFR, &PEFRShadow, 0x00); //clear all bits to normal function

However the value of PEDR still does not change once the ISR is triggered. I know that the ISR is set properly because the code goes into the ISR. But once I read PEDR in the interrupt routine the value is still the same as previously set. Any suggestions?


Looking at the documentation for the Rabbit 3000 and the sample code with Dynamic C 10.64 in extint_3000.c, the value of the current state of the port pin should be readable.

Unless the pulse on the input is very short?

You have set the pin to interrupt on either edge. How are you examining the value of ilocal? is it by storing it somewhere else or by putting a breakpoint in the interrupt routine?


I have a breakpoint set in the interrupt routine. Then I view the value of ilocal via the watch window.

I am using a button press from to generate the pulse. I have a wire that connects button(pin PG0) to PE0(external interrupt).

Does the button have to be held down at the time I read PEDR?
I hope this is not the case.

I’m afraid the button does have to be held down at that point. You can set the break point after the point where the port is read and should be able to see the value captured when the interrupt triggered.