cancel
Showing results for 
Search instead for 
Did you mean: 

st72521 ext int problem

ari
Associate II
Posted on April 11, 2006 at 11:30

st72521 ext int problem

1 REPLY 1
ari
Associate II
Posted on April 11, 2006 at 11:30

hello all,

i've problem triggering external interrupts and would like to confirm what've done wrong..

interrupt vector

void (* const _vectab[])() = {

NULL, /* 0xFFE0 pwmart*/

NULL, /* 0xFFE2 i2c*/

it_AVD, /* 0xFFE4 avd*/

it_sci, /* 0xFFE6 sci*/

it_timeB, /* 0xFFE8 timerb*/

it_timeA, /* 0xFFEA timera*/

it_spi, /* 0xFFEC spi*/

CAN_Interrupt, /* 0xFFEE can*/

it_ei3, /* 0xFFF0 pb4..7*/

it_ei2, /* 0xFFF2 pb0..3*/

it_ei1, /* 0xFFF4 pf0..2*/

it_ei0, /* 0xFFF6 pa0..3*/

it_clock, /* 0xFFF8 mcc*/

NULL, /* 0xFFFA tli*/

it_trap, /* 0xfffc trap*/

_stext, /* 0xfffe main*/

};

cpu initialization

/*

pb0..3 = outputs

pb4..6 = digital inputs (encoder)

pb7 = output

*/

PBDR = 0x80;

PBDDR = 0x8f;

PBOR = 0x8f;

EICR = 0x40;

i'd like to use pb4 and pb5 for encoder input for both channels, and i need to have external interrupt 3 triggered on any edge of these inputs.

interrupt routine

@interrupt void it_ei3(void)

{

encoder.extint++; // increase debug counter

if ((!(encoder.olda & BIT4)) && (PBDR & BIT4)) { // a rising edge

if (!(PBDR & DIN5)) encoder.counter++; // increase counter

else encoder.counter--; // decrease counter

}

encoder.olda = (PBDR); // store old state

}

In above, encoder is volatile structure, and even the counter value is not changed, also the debug counter does not count - which means that external interrupt is never triggered.

I just cannot figure out what's wrong with these settings. Please help!