EmbeddedRelated.com
Forums

External Interrupt using RCM5400W

Started by elol...@gmail.com April 6, 2010
Hi, I'm having problems with external interrupt using a RCM5400W by PE0,

May somebody show me any sample code of external interrupt PE0 or PE1.

I need a sample about external interrupt configuration and interrupt service routine, thanks for help me.
--- In r..., elolmos@... wrote:
>
> Hi, I'm having problems with external interrupt using a RCM5400W by PE0,
>
> May somebody show me any sample code of external interrupt PE0 or PE1.
>
> I need a sample about external interrupt configuration and interrupt service routine, thanks for help me.
>

Try this.

#class auto

unsigned int count0, count1;

void my_isr0();
void my_isr1();

void main()
{
count0 = 0;
count1 = 0;

WrPortI(PEDDR, &PEDDRShadow, 0x00); // set port E as all inputs

SetVectExtern3000(0, my_isr0);
SetVectExtern3000(1, my_isr1);
// re-setup ISR's to show example of retrieving ISR address using GetVectExtern3000
SetVectExtern3000(0, GetVectExtern3000(0));
SetVectExtern3000(1, GetVectExtern3000(1));

//WrPortI(I0CR,&I0CRShadow,0x07);
WrPortI(I0CR,&I0CRShadow,0x05);
//WrPortI(I0CR,&I0CRShadow,0x0B); // External Interrupts
WrPortI(I1CR, &I1CRShadow, 0x09); // enable external INT1 on PE1, rising edge, priority 1
while ( count0 < 2000) {

// output the interrupt count every second
costate {
printf("counts = %3d %3d\n", count0, count1);
waitfor(DelaySec(1));
}
}

// final counts
printf("counts = %3d %3d\n", count0, count1);
}
/****** interrupt routines ******/

nodebug root interrupt void my_isr0()
{
count0++;
}
nodebug root interrupt void my_isr1()
{
count1++;
}

On May 18, 2011, at 6:07 AM, wilson05 wrote:
> WrPortI(PEDDR, &PEDDRShadow, 0x00); // set port E as all inputs

You should be careful to only modify the bits of PEDDR for the pins you're trying to set up. Other peripherals on the chip may be using pins from Port E as outputs, and the WrPortI() will screw things up!

-Tom