|
|
View previous topic :: View next topic |
Author |
Message |
Nick Alexeev Guest
|
How to determine whether interrupt is enabled or disabled? A |
Posted: Sun Nov 24, 2002 8:10 pm |
|
|
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 |
Posted: Mon Nov 25, 2002 5:11 am |
|
|
:=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 |
Posted: Mon Nov 25, 2002 11:42 am |
|
|
:=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 |
Posted: Mon Nov 25, 2002 2:14 pm |
|
|
:=:=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 |
|
|
|
|
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
|