[En-Nut-Discussion] Hanging Interrupts on PIO

Lost Jedi lostjedi32 at yahoo.com
Thu Apr 29 10:39:08 CEST 2010


Hi,

Using Ethernut 4.8.0 with an AT91SAM7x 256K chip.
Having a weird problem with the interrupts/interrupt handler hanging after a couple of times on my PIO(A/B).

Here's how I'm initialising the interrupt :-
	outr(PMC_PCER, _BV(PIOB_ID)); 				//enable clock PIOB
	outr(PIOB_PER, _BV(19)| _BV(20)| _BV(21)); 		//INTA,B,C
	
// Interrupt enable - GPIO B pins
	outr(PIOB_CODR, _BV(19)| _BV(20)| _BV(21)); 		//Clear output data reg
//	outr(PIOB_PUER, _BV(19)| _BV(20)| _BV(21)); 		//Pull Up enable reg
	outr(PIOB_OWDR, _BV(19)| _BV(20)| _BV(21)); 		//
	outr(PIOB_ODR, _BV(19)| _BV(20)| _BV(21)); 		//Output disable i.e. enable input
	outr(PIOB_IFER, _BV(19)| _BV(20)| _BV(21)); 		
	
	NutRegisterIrqHandler(&sig_PIOB, interrupt, NULL);
//	NutIrqSetPriority(&sig_PIOB, 1); 			
//	NutIrqSetMode(&sig_PIOB, NUT_IRQMODE_LOWLEVEL); 	
	outr(PIOB_IER, _BV(19)| _BV(20)| _BV(21)); 		//enable interrupt
	s2 = inb(PIOB_ISR);					//clear ISR
	NutIrqEnable(&sig_PIOB);

The Interrupt handler :-
void interrupt(void *arg)
{
	pinset++;
	s[0] = inr(PIOB_ISR);
	pinset++;
}

I've deliberately set pinset++ twice, so I know if the pinset value is even it would mean the interrupt has hopefully exited the interrupt handler routine. When the pinset++ value when checked, its always even.

Have added another routine that helps me read the PIOA_ISR each time it hangs, and sure enough the ISR is unread. The interrupt handler starts working once i've read i.e. cleared the ISR this way, till it hangs once again.

A slight anomaly I noticed was that another pin is also registering an interrupt in the ISR. In this case, PB3 - the TX pin of the Ethernet. This is odd, since i haven't enabled the IER for that pin and neither am I using the Ethernet port. Checking PIOB_IMR before and after the interrupts hang shows that the pin isn't enabled as an interrupt either.

Any clues on whats happening?

Thanks in advance for any help! :)


      




More information about the En-Nut-Discussion mailing list