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 CCS Technical Support

How to determine whether interrupt is enabled or disabled? A

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







How to determine whether interrupt is enabled or disabled? A
PostPosted: Sun Nov 24, 2002 8:10 pm     Reply with quote

Colleagues,

I have a function, which bit-bangs to serial LCD, and I have a trouble of handling the timing. Obviously timing can be disrupted by the interrupt, so I want to disable several interrupts before LCD output and re-enable them after. I could simply write this:

void char_to_LCD()
{
disable_interrupts(global);
// bit-bang code
enable_interrupts(global);
}

, but what if interrupts were not enabled before the call to char_to_LCD(); I don't want to enable them after.

Question: how can I tell, if certain (or global) interrupt(s) is enabled or disabled?

Ultimately I want to get something like this:

void char_to_LCD()
{
short iFlag = 0;
if (is_global_enabled())
{
iFlag = 1;
disable_interrupts(global);
}

// bit-bang code

if (iFlag)
{
enable_interrupts(global);
}
}

Thanks in advance!

Nick

P.S. I'm morally prepared to write it in assembly.
___________________________
This message was ported from CCS's old forum
Original Post ID: 9349
R.J.Hamlett
Guest







Re: How to determine whether interrupt is enabled or disable
PostPosted: Mon Nov 25, 2002 5:11 am     Reply with quote

:=Colleagues,
:=
:=I have a function, which bit-bangs to serial LCD, and I have a trouble of handling the timing. Obviously timing can be disrupted by the interrupt, so I want to disable several interrupts before LCD output and re-enable them after. I could simply write this:
:=
:=void char_to_LCD()
:={
:= disable_interrupts(global);
:= // bit-bang code
:= enable_interrupts(global);
:=}
:=
:=, but what if interrupts were not enabled before the call to char_to_LCD(); I don't want to enable them after.
:=
:=Question: how can I tell, if certain (or global) interrupt(s) is enabled or disabled?
:=
:=Ultimately I want to get something like this:
:=
:=void char_to_LCD()
:={
:= short iFlag = 0;
:= if (is_global_enabled())
:= {
:= iFlag = 1;
:= disable_interrupts(global);
:= }
:=
:= // bit-bang code
:=
:= if (iFlag)
:= {
:= enable_interrupts(global);
:= }
:=}
:=
:=Thanks in advance!
:=
:=Nick
:=
:=P.S. I'm morally prepared to write it in assembly.
The actual register address details will depend on your PIC, but (for instance), for the global bit on the 16F87x family, you can code as:
#bit GIE=0xB.7

short int intwason;
intwason=GIE;
disable_interrupts(GLOBAL);
//Bit bang code

if (intwason) enable_interrupts(GLOBAL);

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 9376
Nick Alexeev
Guest







Re: How to determine whether interrupt is enabled or disable
PostPosted: Mon Nov 25, 2002 11:42 am     Reply with quote

:=The actual register address details will depend on your PIC, but (for instance), for the global bit on the 16F87x family, you can code as:
:=#bit GIE=0xB.7
:=
:=short int intwason;
:=intwason=GIE;
:=disable_interrupts(GLOBAL);
:=//Bit bang code
:=
:=if (intwason) enable_interrupts(GLOBAL);
:=
:=Best Wishes

Thanks for the response! I was thinking about something like this, but stubled, because could not find the address. Are interrupt registers memory mapped (I didn't find it in PIC18F442 data sheet)?

Sincerely,
Nick
___________________________
This message was ported from CCS's old forum
Original Post ID: 9399
R.J.Hamlett
Guest







Re: How to determine whether interrupt is enabled or disable
PostPosted: Mon Nov 25, 2002 2:14 pm     Reply with quote

:=:=The actual register address details will depend on your PIC, but (for instance), for the global bit on the 16F87x family, you can code as:
:=:=#bit GIE=0xB.7
:=:=
:=:=short int intwason;
:=:=intwason=GIE;
:=:=disable_interrupts(GLOBAL);
:=:=//Bit bang code
:=:=
:=:=if (intwason) enable_interrupts(GLOBAL);
:=:=
:=:=Best Wishes
:=
:=Thanks for the response! I was thinking about something like this, but stubled, because could not find the address. Are interrupt registers memory mapped (I didn't find it in PIC18F442 data sheet)?
:=
:=Sincerely,
:=Nick
Yes the interrupt controls are all mapped into the RAM. Look at page 45 an onwards for the locations. On the 18F data sheets for some reason Microchip moved away from printing the addresses alongside the names in the section of the sheet referring to the registers, and instead you have to look them up in this seperate table!. INTCON is 0xFF2, and the global enable is bit 7, and bit 6 is the PIE enable (for low priority sources).

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 9413
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