https://ww1.microchip.com/downloads/en/DeviceDoc/31008a.pdfView attachment 312286
Hi. Does anybody know why my professor sets the GIE bit as 0 in the beginning of the intterupt function? Shouldn't it be set as 1 for the interrupt to work?
Your professor sets the GIE bit to 1 as the ISR completes the instructions and then returns ready for the next interrupt.The Global Interrupt Enable bit, GIE (INTCON<7>), enables (if set) all un-masked interrupts or
disables (if cleared) all interrupts. Individual interrupts can be disabled through their corresponding enable bits in the INTCON register. The GIE bit is cleared on reset.
The “return from interrupt” instruction, RETFIE, exits the interrupt routine as well as sets the GIE
bit, which allows any pending interrupt to execute.
The INTCON register contains these interrupts: INT Pin Interrupt, the RB Port Change Interrupt,
and the TMR0 Overflow Interrupt. The INTCON register also contains the Peripheral Interrupt
Enable bit, PEIE. The PEIE bit will enable/disable the peripheral interrupts from vectoring when
the PEIE bit is set/cleared.
When an interrupt is responded to, the GIE bit is cleared to disable any further interrupt, the
return address is pushed into the stack and the PC is loaded with 0004h. Once in the interrupt
service routine the source(s) of the interrupt can be determined by polling the interrupt flag bits.
Generally the interrupt flag bit(s) must be cleared in software before re-enabling the global interrupt to avoid recursive interrupts.
Once in the interrupt service routine the source(s) of the interrupt can be determined by polling
the interrupt flag bits. Individual interrupt flag bits are set regardless of the status of their
corresponding mask bit or the GIE bit.
But this means that setting the GIE as 0 is not needed. As the pic does that by itself right?https://ww1.microchip.com/downloads/en/DeviceDoc/31008a.pdf
Your professor sets the GIE bit to 1 as the ISR completes the instructions and then returns ready for the next interrupt.
Joey is spot on here. That's the reason for the atomic RETFIE instruction that the compiler will use at the end of the declared interrupt handler.I'd love to see the resulting .asm. GIE=1 in the handler will likely result in a race condition if another interrupt is triggered at any time after the GIE=0 and before the context switch back is complete.
It has been my experience that most of them are NOT as smart as they think they are. Most of them are legends in their own minds.Joey is spot on here. That's the reason for the atomic RETFIE instruction that the compiler will use at the end of the declared interrupt handler.
The learned professor has whiffed this one.
| Thread starter | Similar threads | Forum | Replies | Date |
|---|---|---|---|---|
|
|
New Member here | General Electronics Chat | 38 | |
| S | Please help clarifying connections here | PCB Layout , EDA & Simulations | 24 | |
|
|
Hi. New here. Car battery reads 11.78V | Power Electronics | 61 | |
| U | Blink camera power dilema, going crazy here. | General Electronics Chat | 32 | |
| M | What's Going On Here? | General Electronics Chat | 6 |