PDA

View Full Version : Disable/Enable in Interrupts



Ioannis
- 28th September 2006, 17:36
If I have a group of Subroutines on top of my program and don't want these to be interrupted, can only one Disable on top and Enable on bottom be enough? Or every sub must have their own pair?

Is this correct:

On Interrupt Goto myint

Disable
Sub1
Return

Sub2
Return
Enable

Disable
myint:
Resume
Enable

main:
'my main loop with interrupts enabled
End

Thanks, Ioannis

sougata
- 28th September 2006, 17:48
Hi,

The Enable/Disable are compiler directives which does or does not put the PBP int checking codes into you routine. So this should work. Remember strictly for PBP interrupts. Another way is to turn off the individual interrupt settings only keeping the Global INT turned on i.e., INTCON = $80. If you have other peripheral interrupts then they should be turned off too. (By only clearing the PIE bits perhaps) Mention your PIC and interrupts used.

Ioannis
- 28th September 2006, 17:59
Thanks for the reply.

The PIC is 16F877 and interrupts are coming from the UART module.

My concern is if the disable directive needs to be inserted in every subroutine. Logicaly not as it is directive and covers all the block of commands until it finds the Enable pair.

Ioannis

elcrcp
- 13th June 2015, 18:39
This would also work but I think it would cause problems for you. For example;
if you call sub2 before calling sub1, then interrupts wont be disabled
if you call sub1 and return to main, then again interrupts wont be enabled until you call sub 2

So my suggestion is to disable - enable interrupts on each subroutine individually.

Ioannis
- 15th June 2015, 07:47
Thanks, although back from the dead!

:)

Ioannis