View previous topic :: View next topic |
Author |
Message |
JaSoN
Joined: 05 Jul 2006 Posts: 15
|
Interrupts disabled during call to prevent re-entrancy |
Posted: Thu Aug 10, 2006 5:57 am |
|
|
Hi, I have an I2C_read() and I2C_write command in the timer interrupt, the compiler show some warning as:
>>> Warning 216 : Interrupts disabled during call to prevent re-entrancy: @I2C_WRITEU_1_59_60_20000000
>>> Warning 216 : Interrupts disabled during call to prevent re-entrancy: @I2C_READU_1_59_60_20000000
how can I eliminate these warning? |
|
|
sjbaxter
Joined: 26 Jan 2006 Posts: 141 Location: Cheshire, UK
|
|
Posted: Thu Aug 10, 2006 6:25 am |
|
|
Set a global flag in the timer interrupt and do the main work in the main while() loop (based on the status of the flag). when you have completed the work, i.e. read and write to an I2C device, reset the flag.
In some cases, you may need to disable the interrupt during the work operation.
As a rule, do as little as possible in an interrupt handler. _________________ Regards,
Simon.
Last edited by sjbaxter on Thu Aug 10, 2006 6:27 am; edited 1 time in total |
|
|
neil
Joined: 08 Sep 2003 Posts: 128
|
|
Posted: Thu Aug 10, 2006 6:25 am |
|
|
You should never make calls like read/write of peripherals from within an interrupt routine. Create a flag that is set by the interrupt and test for it in main, so you can do your I2C read/write from main.
This assumes that your main loop runs fast and is not impeded by calls to delays or sits waiting for an event to complete. My main loop *only* polls around checking event flags and goes off and services a task when the flag becomes true.
hope this helps. |
|
|
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
|
Posted: Thu Aug 10, 2006 6:36 am |
|
|
From the FAQ _________________ I came, I saw, I compiled. |
|
|
JaSoN
Joined: 05 Jul 2006 Posts: 15
|
|
Posted: Thu Aug 10, 2006 7:45 am |
|
|
Thanks, the warning is solved..
I want to ask if I want to program a function in timer interrupt, when a SSP interrupt comes, will the timer interrupt be disabled? |
|
|
grasspuddle
Joined: 15 Jun 2006 Posts: 66
|
|
Posted: Thu Aug 10, 2006 10:28 am |
|
|
when you enter an interrupt, interrupts are automatically disabled
unless you have a high priority interrupt get called when a low priority interrupt is running |
|
|
Ttelmah Guest
|
|
Posted: Thu Aug 10, 2006 12:02 pm |
|
|
It depends to an extent what you mean.
The interrupt _flag_ will still be set, but the response to this flag, will not occur, till you exit the first interrupt.
Best Wishes |
|
|
Guest
|
|
Posted: Sat Jan 26, 2008 4:32 pm |
|
|
It seems that the compiler doesn't distinguish between high and low priority interrupts when "disabling interrupts to prevent re-entrancy". If I have a complex low-priority interrupt that is a possible source of re-entrancy, shouldn't I be able to have a high priority interrupt interrupt it? Seems like there ought to be a way to include only low-priority interrupts in the re-entrancy calculation... |
|
|
|