Page 1 of 1

GIEH status in interrupt routine

PostPosted: Wed Dec 02, 2020 5:50 pm
by Keno
In order for PIC to issue an interrupt, GIEH (Global Interrupt Enable, High priority) must be enabled among other things. This seems logical, looking at interrupt logic scheme. However, should this bit be changed during interrupt function?

According to one source, GIEH is only set (GIEH = 1) in the main function and left unchanged. However, according to some other source, GIEH is also set in main function, but when interrupt function starts, it is cleared (GIEH = 0) and before this function ends, GIEH is set.

Brez naslova.png
Brez naslova.png (138.88 KiB) Viewed 11160 times


Should GIEH be altered during interrupt function (for some reason)?

Keno

Re: GIEH status in interrupt routine

PostPosted: Thu Dec 03, 2020 3:06 am
by AussieSusan
The setting and clearing of the GIE bit around an ISR is done by the hardware, NOT by you in your code. I'm not sure which MCU you are referring to but I think it is the same for all of the smaller ones (e.g. PIC18 and below). Read up on the way the interrupts are processed in the data sheet and also I think it is described in the 'return from interrupt' instruction description.
Therefore you should only set the bit as part of your initialisation code and forget it after that.
Susan

Re: GIEH status in interrupt routine

PostPosted: Mon Dec 07, 2020 6:46 am
by ric
As above. That diagram appears to be from one of the 8 bit PIC datasheets, but this has been posted in the 16 bit forum.
n.b. PIC16Fxxx device are NOT "16 bit core".