View previous topic :: View next topic |
Author |
Message |
Bieli
Joined: 15 Sep 2003 Posts: 9
|
Examine interrupt status |
Posted: Sat Oct 25, 2014 4:09 am |
|
|
Hello All,
How can I examine is interrupt is enable or disable?
I use enable_interrupts(INT_TIMER1);, disable_interrupts(INT_TIMER1); to activate or deactivate it but I'd like to check is it on or off.
Regards
Bieli |
|
|
VernonAMiller
Joined: 11 Sep 2014 Posts: 25 Location: Contoocook, NH
|
Re: Examine interrupt status |
Posted: Sat Oct 25, 2014 5:36 am |
|
|
Bieli wrote: | Hello All,
How can I examine is interrupt is enable or disable?
I use enable_interrupts(INT_TIMER1);, disable_interrupts(INT_TIMER1); to activate or deactivate it but I'd like to check is it on or off.
Regards
Bieli |
You can just look in the proper Interrupt Control (INTCON) register to see if the bit is set. The enable_interrupts() function just sets a bit in one of the INTCON registers, and you can test that same bit to see if the interrupt is enabled.
For example, here is the code that enable_interrupts() generates for Timer0 on a PIC18F2685:
Code: |
.................... enable_interrupts(INT_TIMER0);
0065C: BSF INTCON.T0IE
|
Read the datasheet for your processor, and maybe look at the code the compiler generates for your PIC for enable_interrupts() and use that as your guide.
VAM |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sat Oct 25, 2014 5:59 am |
|
|
Or do it the easy way...
Look on page 56 of the current CCS manual under Interrupts.
There you will find Interrupt_Enabled()
The details are on page 80.
It always helps to read the manual! _________________ Google and Forum Search are some of your best tools!!!! |
|
|
VernonAMiller
Joined: 11 Sep 2014 Posts: 25 Location: Contoocook, NH
|
|
Posted: Sat Oct 25, 2014 4:11 pm |
|
|
dyeatman wrote: | Or do it the easy way...
Look on page 56 of the current CCS manual under Interrupts.
There you will find Interrupt_Enabled() |
DOH! Forgot about that one. That's what I get for answering in a hurry too early in the morning!
VAM |
|
|
Bieli
Joined: 15 Sep 2003 Posts: 9
|
|
Posted: Sun Oct 26, 2014 6:40 am |
|
|
Thanks for suggestion.
There was no Interrupt_Enabled() function in my help (5.030) but I found
interrupt_active() looks it work same.
Regards
Bieli |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sun Oct 26, 2014 7:14 am |
|
|
No, Interrupt_Active checks to see if the Interrupt has been activated (fired)
due to an event. However, along the lines of what VernonAMiller wrote
earlier, you did not say which processor so here is a generic example
#byte CtlReg = getenv("SFR:PIE1") // get Timer 1 Interrupt Enable register
#bit Tmr1IEn = CtlReg.0 // get the Enable bit
<or, go after the bit directly.... >
#bit TMR1IEn=GETENV("BIT:TMR1IE")
<then>
if (Tmr1IEn) ....... // now we can test it
**** Remember, you have to read the datasheet for your processor
to get the correct bit/register names. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
|