View previous topic :: View next topic |
Author |
Message |
RossJ
Joined: 25 Aug 2004 Posts: 66
|
Why is a loop included in disable_interrupts? |
Posted: Tue Aug 28, 2007 12:17 am |
|
|
Hello,
The code generated (18F2620) to disable global interrupts is as follows...
Code: |
.................... disable_interrupts(GLOBAL);
00028: BCF FF2.6
0002A: BCF FF2.7
0002C: BTFSC FF2.7
0002E: BRA 002A
|
FF2.6 and FF2.7 are INTCON.GIEL and INTCON.GIEH respectively. Does anyone know why PCH includes the loop? I have never seen any Microchip documentation or errata that offer an explanation.
/Cheers, Ross. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah Guest
|
|
Posted: Tue Aug 28, 2007 3:18 am |
|
|
Add though the following:
I was told by an engineer at Microchip, that on _most_ 18 chips, it is not necessary. They added a latch, so that interrupts are automatically disabled during accesses to the INTCON register.
If you look at some of the Mcrochip examples for some 18 chips, they do just simply access the bits, and don't bother to loop. However there are quite a few erratas for interrupt enable/disable on some chips, and a few bring back the need to do this on specific chips. I'd suspect that CCS, are 'playing it safe', and assuming that the latch doesn't work...
Best Wishes |
|
|
RossJ
Joined: 25 Aug 2004 Posts: 66
|
|
Posted: Tue Aug 28, 2007 4:54 am |
|
|
Thankyou both.
/Cheers, Ross. |
|
|
|