View previous topic :: View next topic |
Author |
Message |
cLuciano
Joined: 27 Dec 2006 Posts: 8
|
Disable Low Priority Interrupts |
Posted: Mon Aug 27, 2007 2:21 am |
|
|
How i can disable only the low priority interrupts |
|
|
Ttelmah Guest
|
|
Posted: Mon Aug 27, 2007 3:06 am |
|
|
This is just a case of CCS, not giving you all the 'define' options they should. Something like (check the data sheet for your chip, and that the two bits are the top two bits of the INTCON register):
Code: |
#define HIGH_ON 0xF280
#define LOW_ON 0xF240
disable_interrupts(GLOBAL);
enable_interrupts(HIGH_ON);
|
Should enable the high priority interrupts only.
Best Wishes |
|
|
cLuciano
Joined: 27 Dec 2006 Posts: 8
|
|
Posted: Mon Aug 27, 2007 3:16 am |
|
|
Supposing all the interruptions are already enabled.
Is correct the following procedure to disable only the low priority interruptions:
#inline
void disable_interrupts_lowPriority(void)
{
#asm
loop:
bcf INTCON,GIEL
btfsc INTCON,GIEL
goto loop
#endasm
} |
|
|
Ttelmah Guest
|
|
Posted: Mon Aug 27, 2007 9:55 am |
|
|
It is unnecessary to use assembler for this sort of thing:
Code: |
#byte INTCON=0xFF2
#bit GIEL=INTCON.6
while (GIEL) GIEL=0;
|
The loop shown, is not needed on most PICs (just set GIEL=0). Check the data sheet on this. On most, interrupts are _disabled_ automatically when you access the INTCON register. There are a few, with an erratum, where interrupts are left enabled, and the instruction will get missed, if an interrupt occurs while the bit is being cleared. There are also some, where it is advised, that you should disable the interrupts, before changing any bit in this register, and some others, where this only applies when using the 'MOVFF' instruction. Really safer to disable, and then set just the required bit.
Best Wishes |
|
|
|