Timer + Interrupt difficulties

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

Timer + Interrupt difficulties

432 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Sepheriod on Wed Jul 25 08:06:43 MST 2012
Hello, I'm using an LPC 11c24 MCU and my program consists of 2 ISR's ran by 2 seperate timers. timer_32_0 and timer_32_1

timer_32_0 runs on 1hz and the ISR takes about 150 mS to handle all the instructions in the ISR

timer_32_1 runs on 1000hz and is done in a few microseconds.

These timers have to run at the same time.

But the problem now is that when timer_32_0 is active for that 150 mS timer_32_1 is inactive.

if I change around the NVIC priorities timer_32_1 is always active and timer_32_0 is never called.

NVIC_SetPriority(TIMER_32_1_IRQn, 4);

is there a way to work around this problem?
0 Kudos
3 Replies

398 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Wed Jul 25 10:27:04 MST 2012
First, interrupt service taking 150 ms ia a serious conceptual flaw -> rethink your project. The interrupt service should not wait for anything.

Second, if something must happen 1000 times per second and something other once per second, you should use only one timer interrupt, do the 1000 Hz stuff in ISR, then decrement a counter - if decremented to 0, do the 1 Hz stuff and reload the counter with 1000.
0 Kudos

398 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Wed Jul 25 09:46:09 MST 2012

Quote: Sepheriod
Hello, I'm using an LPC 11c24 MCU and my program consists of 2 ISR's ran by 2 seperate timers. timer_32_0 and timer_32_1

timer_32_0 runs on 1hz and the ISR takes about 150 mS to handle all the instructions in the ISR

timer_32_1 runs on 1000hz and is done in a few microseconds.

These timers have to run at the same time.

But the problem now is that when timer_32_0 is active for that 150 mS timer_32_1 is inactive.

if I change around the NVIC priorities timer_32_1 is always active and timer_32_0 is never called.

NVIC_SetPriority(TIMER_32_1_IRQn, 4);

is there a way to work around this problem?



Yes, switch you brain on, set a flag in your interrupt and let the work do your main :eek:

Writing 150ms Interrupts deserves punishment ;)
0 Kudos

398 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Wed Jul 25 08:58:46 MST 2012
Seems an interrupt ack problem to me.
I don't know the LPC11xx timers details, but I had similar problems on LPC2148 which has one ISR, common to all functions of a single timer.

Angelo
0 Kudos