cancel
Showing results for 
Search instead for 
Did you mean: 

Clearing external interrupts in str730

f98pp
Associate II
Posted on May 23, 2007 at 06:15

Clearing external interrupts in str730

5 REPLIES 5
f98pp
Associate II
Posted on May 22, 2007 at 07:06

Hi,

I have enabled the external interrupt pins in STR730 by doing:

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_TRI_TTL;

GPIO_InitStructure.GPIO_Pins = GPIO_PIN_8 ;

GPIO_Init (GPIO5, &GPIO_InitStructure);

EIC_ExternalITTriggerConfig(EXTIT06_IRQChannel,EXTIT_TRIGGER_Falling);

EIC_IRQChannelPriorityConfig( EXTIT06_IRQChannel, 5);

EIC_IRQChannelConfig( EXTIT06_IRQChannel , ENABLE );

And in the ISR, I have:

void EXTIT06_IRQHandler (void)

{

EIC_IRQPendingBitClear(EXTIT06_IRQChannel);

}

void EIC_IRQPendingBitClear(u8 IRQChannel)

{

if(IRQChannel

{

EIC->IPR0 |= 0x0001 << IRQChannel;

}

else

{

EIC->IPR1 |= 0x0001 << (IRQChannel-32);

}

}

The interrupt is triggered, but I don't seem to be able to clear the pending interrupt with EIC_IRQPendingBitClear

Regards

Binh

kleshov
Associate II
Posted on May 22, 2007 at 10:29

It's in the manual:

Quote:

The EIC_IPR is a read/clear register, so writing a ‘0’ has no effect, while writing a ‘1’ resets the related bit. Therefore, refrain from using read-modify instructions to avoid corruption of the EIC_IPR status. Most of the EIC pending bits are related to a peripheral pending bit. The peripheral pending bit must be cleared prior to clearing the EIC pending bit. Otherwise the EIC pending bit will be set again and the interrupt routine will be executed twice.

There are two mistakes in your code. First, you shouldn't use a read-modify-write sequence (such as |=) to clear a bit in EIC_IPRx. Use a simple assignment. Second, clear the corresponding peripheral interrupt pending bit (XTI_PRx in your case).

By the way, in my programs I don't use the STR7x standard library. In my opinion, it is little more than a set of simple wrappers for the MCU registers. The library may give you a false sense of security ('they took care of everything for me'). But in reality it does not excuse you from actually reading the manual. Naturally, there are bugs in the library itself. Besides, writing to MCU registers directly takes up less space in yout text editor window 🙂

Regards,

- mike

f98pp
Associate II
Posted on May 22, 2007 at 12:31

Thanks for pointing out the problem, but there don't seem to be any peripheral pending bit (XTI_PRx) availiable for external interrupt pins. If I only clear the EIC pending bit (by simple assignment), the interrupt seems to be issued recursively until stack space is exhausted, which I interpret from the quote as a result of the interrupt being executed twice when not clearing the periperhal bit.

The manual at section 7.8.1 does mention resetting ''the interrupt pending bit'', but the location of this bit is not mentioned. One could assume that the manual is referring to the EIC interrupt pending bit.

So, is there a peripheral interrupt pending bit for the external interrupt lines or what?

Regards

Binh

kleshov
Associate II
Posted on May 23, 2007 at 03:31

Sorry, I was assuming that external interrupts on the STR730 are similar to those on the STR710, which I'm working with. Having read the relevant part of the STR730 manual, I can see they are different. With edge-triggered interrupts no clearing of peripheral pending bits should be needed. Try inspecting the contents of the configuration registers EITExx to make sure that the interrupt is configured as edge-triggered.

- mike

f98pp
Associate II
Posted on May 23, 2007 at 06:15

I solved it, my mistake was doing:

EIC_ExternalITTriggerConfig(EXTIT06_IRQChannel,EXTIT_TRIGGER_Falling);

EXTIT06_IRQChannel was the wrong flag to use.

The correct flag to use is EXTERNAL_IT6:

EIC_ExternalITTriggerConfig(EXTERNAL_IT6,EXTIT_TRIGGER_Falling);

Thanks for the suggestion to check the trigger flags Mike!

Binh