Multiple interrupt handling -S12DP512

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multiple interrupt handling -S12DP512

1,457 Views
pon
Contributor I

I am using S12DP512 MC with two interrupt routines, one with timer module it’s create 2 ms interrupt, Other one is SCI interrupt for transmission and receiving. The SCI interrupts are enabled within the 2ms interrupt routines. Can we use this way of interrupts? I am doubt that when SCI interrupt enabled, will 2ms interrupt be lost?  plese help me.

Labels (1)
0 Kudos
2 Replies

327 Views
mke_et
Contributor IV
There shouldn't be any problem if you write the code correctly.

Just one thing to be careful of, and that's how much time you spend IN an interrupt. As you get more and more interrupts in a system, there's the possibility that they ALL could happen in a timeframe where they all get stacked up. You have to make sure that no interrupt could occur more than once in the TOTAL time that it could be held off.

That's normally not a problem, but if you start using commands to activate functions from the serial link, be careful of how much time you spend in background.

I ran into an issue when I used a part at 8Mhz and I was taking port interrupts and doing math on the times as well as running 2 timers and handling serial stuff. I ended up making all my ISRs tight and quick, doing little more than doing what was needed for the hardware and putting the data in a 'queue' for that portion of my project. Then I had a foreground task that just serviced all the queues until they were empty. I could hang up in foreground for as long as necessary doing math or even waiting for something else, but the interrupts would keep happening and nothing ever got lost. Well, at least as I didn't overflow a queue buffer!
0 Kudos

327 Views
JimDon
Senior Contributor III
Your question is not entirely clear, but here is some information.

- When you are in the Timer interrupt, unless you did a cli, the processor interrupts are off, so the SCI interrupt would not happen until you reuturn from the timer interrupt.

- There is no reason why the 2ms interrupt should be lost, unless there is a bug in the code, like not clearing the SCI interrupt in the interrupt handler, but the the whole program should crash.

0 Kudos