cancel
Showing results for 
Search instead for 
Did you mean: 

changing irq handler

gurnett2
Associate II
Posted on October 25, 2012 at 16:17

What is the best way to change the irqhandler to be used. I have a number of situations where the operations need to change depending on what the board is doing. Don't want to have a load of ifs or switches inside the isr, so my idea was to simply stop irq, change default handler and then resume. Is this possible?

Thanks

Michael
This discussion is locked. Please start a new topic to ask your question.
4 REPLIES 4
Posted on October 25, 2012 at 17:03

You'd need to place the vector table in RAM (512 byte boundary), or have multiple copies of the table in flash.

You could also keep a function pointer, and have the routine call that, adding a single indirect jump.

Using a switch/case or if-else-if construct wouldn't be that inefficient.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gurnett2
Associate II
Posted on October 25, 2012 at 19:36

Thanks for the answer clive1. Would I be correct that if it was you doing it you would go with the switch, if else option

Thanks

Michael

Posted on October 25, 2012 at 21:16

If I have 4, or more, different behaviours I'd probably go with a switch/case

For 2 or 3, the if/else

void DMA2_Stream0_IRQHandler(void)
{
if (mode == 1)
{
/* Test on DMA Stream Half Transfer interrupt */
if (DMA_GetITStatus(DMA2_Stream0, DMA_IT_HTIF0))
{
/* Clear DMA Stream Half Transfer interrupt pending bit */
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_HTIF0);
// Process first half of sample buffer
}
/* Test on DMA Stream Transfer Complete interrupt */
if (DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0))
{
/* Clear DMA Stream Transfer Complete interrupt pending bit */
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);
// Process second half of sample buffer
}
}
else if (mode == 2)
{
// ..
}
else
{
// ..
} 
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gurnett2
Associate II
Posted on October 25, 2012 at 21:21

Thank you ever so much for your help.

-Michael