cancel
Showing results for 
Search instead for 
Did you mean: 

Interrupt priorities

lseletron
Associate II
Posted on May 10, 2007 at 08:20

Interrupt priorities

4 REPLIES 4
lseletron
Associate II
Posted on May 07, 2007 at 01:36

Hi,

I am using 72325.

I have OC interrupts for both TimerA and TimerB. I found that if TimerA OC Interrupt occurs soon after TimerB OC Interrupt and while the execution is in TimerB_ISR, TimerB_ISR will be interrupted by TimerA_ISR:

TimerB_ISR()

{

int a=3;

int b=4;

// TimerA_ISR is called here

int c=5;

}

I guess this is normal and one should take care if variables are changed in both ISR etc.

My question is:

Will TimerA_ISR (being higher priority) be interrupted by TimerB_ISR in case TimerB OC interrupt happens soon after TimerA and while the execution is inside TimerA_ISR?

Thank you

laurent239955_stm1
Associate II
Posted on May 09, 2007 at 14:05

Hi,

It looks like you are using the nested interrupt mode (refer to 7.4 section in the datasheet). In this case you have programmed software priorities and the TimerA one is higher than the TimerB one, so TB ISR is interrupted.

Except if you change the software priorities, the TimerB will never interrupt the TimerA ISR.

best regards

Laurent

lseletron
Associate II
Posted on May 09, 2007 at 22:20

Hi,

I have not changed any priorities.

How do I know which mode I am using?

The datasheet is not very verbose on the subject, actually I think ST should have dedicated a whole chapter on interrupt priorities, modes etc.

Thank you

laurent239955_stm1
Associate II
Posted on May 10, 2007 at 08:20

Hi,

The software prioriies for Timer A and B are set in ISPR3 by bits I0_8, I1_8 for Timer A and bits I0_9, I1_9 for Timer B (refer to sectio 7.5).

If all ISPRx are at FFh I'm surprised that one interrupt subroutine can be interrupted by another one !

In order to avoid any tools intrusion, you can check if this case occurs, by setting an I/O at the beginning of the interrupt routine and to clear it at the end and check with an oscillator if the two I/Os are both set, or any other mechanism based on the semaphore principle.

Best regards

Laurent