CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Examine interrupt status

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Bieli



Joined: 15 Sep 2003
Posts: 9

View user's profile Send private message

Examine interrupt status
PostPosted: Sat Oct 25, 2014 4:09 am     Reply with quote

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

View user's profile Send private message

Re: Examine interrupt status
PostPosted: Sat Oct 25, 2014 5:36 am     Reply with quote

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: 1931
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Oct 25, 2014 5:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Oct 25, 2014 4:11 pm     Reply with quote

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! Smile

VAM
Bieli



Joined: 15 Sep 2003
Posts: 9

View user's profile Send private message

PostPosted: Sun Oct 26, 2014 6:40 am     Reply with quote

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: 1931
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Oct 26, 2014 7:14 am     Reply with quote

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!!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group