cancel
Showing results for 
Search instead for 
Did you mean: 

Question about interrupt

guillaume23
Associate II
Posted on April 10, 2013 at 14:13

Hi all,

I have a specific needs for a project.

In this project I use a STM8AL3L66 but my question is a general question about the interrupt in the STM8 family.

Is that an interrupt can be interrupted by the same interrupt (itself) ?

I know (according to the datasheet) that an interrupt can interrupt an other interrupt (in nested mode) :

0690X00000604zWQAQ.png

But I wish to know if this kind of behavior is possible :

0690X00000604GwQAI.png

Associates code :

INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_COM_IRQHandler, 23)

{

         if(state == a) longTask();

         else shortTask();

}

I don't know if my question is obvious, if it does not, let me know and I'll try to explain better.

P.S : Sorry for my english, this is not my mother language.

#stm8-interrupt
3 REPLIES 3
fggnrc2
Associate II
Posted on April 10, 2013 at 14:31

The answer to your question is YES: an interrupt handler can be interrupted by another interrupt handler and even by itself.

This behaviour is obtained when your interrupt handler enables interrupt within its body.

Please, be informed that you must be careful in doing this, because this action corrupts the stack if you doesn't clear the interrupt source flag before enabling interrupts again.

Regards,

EtaPhi

guillaume23
Associate II
Posted on April 10, 2013 at 14:38

Ok, thus, when the program enter in the interrupt handler, I have to :

   - clear the corresponding interrupt flag

   - and activate the interrupt -----> because interrupt are disable when the program jump in an interrupt handler ?

Just for example, it could be done by this way :

INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_COM_IRQHandler, 23)

{

    TIM1->SR1 &= 0xFE; // Clear Timer 2 overflow flag

    enableInterrupts();

    .........

}

guillaume23
Associate II
Posted on April 10, 2013 at 15:26

After some tests, everythings works fine.

As Etaphi says,  I had to enabled interrupt in coressponding interrupt handler.

Thanks,

Regards.