Difference between Global Interrupt Enable  and Peripheral Interrupt Enable bit - Page 1
Forum section: electronics / beginners

author: khatus
author_rank: Regular Contributor
timestamp: February 02, 2020, 10:11:40 am
content: Hi guys! what is the difference between Global Interrupt Enable and Peripheral Interrupt Enable bit in pic 18f micro controller?What is their function?

author: Psi
author_rank: Super Contributor
timestamp: February 02, 2020, 10:28:13 am
content: I don't know that chip, but i would expect that 'global' turns on/off all interrupts in the entire chip and peripheral only turns on/off interrupts for that peripheral

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: February 02, 2020, 10:43:13 am
content: PIE only disables a subset of interrupts, GIE disables all of them. It's a bit of a hang-over from earlier architectures.

author: khatus
author_rank: Regular Contributor
timestamp: February 02, 2020, 01:58:37 pm
content: what is unmasked interrupt

author: aheid
author_rank: Regular Contributor
timestamp: February 02, 2020, 03:30:13 pm
content: https://www.jedec.org/standards-documents/dictionary/terms/interrupt-mask

author: aheid
author_rank: Regular Contributor
timestamp: February 02, 2020, 03:38:08 pm
content: As an example, say you're using a timer to trigger the ADC to start conversion. You might not care about the interrupt the timer generates when it triggers, but you do care about the interrupt the ADC triggers when the conversion is done.In this case you don't want to disable all (global) interrupts, nor all the peripheral interrupts, but only the timer interrupt. So you mask the timer interrupt, and ensure the ADC interrupt is unmasked.

author: ggchab
author_rank: Frequent Contributor
timestamp: February 02, 2020, 03:41:25 pm
content: Interrupts not disabled by their bit in PIE.

author: IDEngineer
author_rank: Super Contributor
timestamp: February 02, 2020, 09:25:10 pm
content: Here's the logic diagram for one PIC18F family's interrupt system:Granted it looks daunting but if you trace the signals you're asking about, it will become clear what they do and how they affect other signals.In text:1) Individual interrupt sources must have their flags enabled in the associated Peripheral Interrupt Enable (PIE) register2) The overall interrupt system must be enabled via the Global Interrupt Enable (GIE) flag#1 above means that individual peripherals might generate interrupt requests, but unless their individual interrupt ENABLE flag is set, those interrupts will not be recognized (even if the rest of the interrupt system is enabled and recognizing interrupts from other, individually enabled peripheral interrupts).#2 above means that, no matter what individual peripheral interrupts may or may not be enabled, NO interrupts will be recognized unless the Global Interrupt Enable flag is set. This is a "master flag" for the interrupt system. It is important to note that even if the entire interrupt system is disabled via the GIE, individual interruptrequestflags can continue to be set and if the GIE is later set, those interrupts (whose individual interruptenableflags are also set) will immediately be recognized via the logic diagram above. In other words, if you have one or more set interrupt request flags and then you enable GIE, you're going to get an immediate interrupt even if the event that set the interrupt request flag occurred some time in the past.Does this help?

author: Ian.M
author_rank: Super Contributor
timestamp: February 03, 2020, 12:22:21 am
content: The PIC18 PEIE bit (in non-prioritised interrupt mode) is only there for legacy compatibility to facilitate porting PIC16 assembler code as its in exactly the same bit position in the INTCON SFR, which has the same bit layout and functionality as its PIC16 implementation. This was of some relevance to assembler programmers back at the turn of the millennium, but nowadays a C programmer using non-prioritised interrupts should just set and forget PEIE, as it provides an extra layer of interrupt masking for so-called 'peripheral' interrupts that one just doesn't need.However if you are using interrupt priorities, that bit position becomes GIEL and you cant use prioritised interrupts without a full understanding of it and GIEH.

author: MianQi
author_rank: Newbie
timestamp: November 23, 2020, 04:25:50 am
content: I found this Application Note: TB3263 - Getting Started with ADCC for PIC18(http://ww1.microchip.com/downloads/en/Appnotes/TB3263-Technical-Brief-DS90003263A.pdf), when I tried the 4th example - ADCC Spike Detection. There was a line in the demo code: "INTERRUPT_PeripheralInterruptEnable();", when I built it in MPLAB, it was prompted:warning: implicit declaration of function 'INTERRUPT_PeripheralInterruptEnable' is invalidbut, when I went to search "INTERRUPT_PeripheralInterruptEnable" in files generated by MCC, I couldn't fint it. I used PIC18F57Q43 on Curiosity Nano board for testing, if it was said this macro just for compatibility with PIC mid-range chips, could I comment this line? When I commented it, it seemed that the result saw in Data Visualizer was not intended, anyone know why and how to?the code is here:Code:/**Generated Main Source FileCompany:Microchip Technology Inc.File Name:main.cSummary:This is the main file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUsDescription:This header file provides implementations for driver APIs for all modules selected in the GUI.Generation Information :Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.6Device : PIC18F57Q43Driver Version : 2.00*//*(c) 2018 Microchip Technology Inc. and its subsidiaries.Subject to your compliance with these terms, you may use Microchip software and anyderivatives exclusively with Microchip products. It is your responsibility to comply with third partylicense terms applicable to your use of third party software (including open source software) thatmay accompany Microchip software.THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHEREXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANYIMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESSFOR A PARTICULAR PURPOSE.IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KINDWHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIPHAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TOTHE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALLCLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNTOF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THISSOFTWARE.*/#include "mcc_generated_files/mcc.h"/*Main application*//** void main(void){// Initialize the deviceSYSTEM_Initialize();// If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts// If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global Interrupts// Use the following macros to:// Enable the Global Interrupts//INTERRUPT_GlobalInterruptEnable();// Disable the Global Interrupts//INTERRUPT_GlobalInterruptDisable();while (1){// Add your application code}}*//**End of File*/uint16_t volatile errVal;void ThresholdISR(void);void main(void){SYSTEM_Initialize();INTERRUPT_GlobalInterruptEnable();INTERRUPT_PeripheralInterruptEnable();ADCC_SetADTIInterruptHandler(ThresholdISR);ADCC_DischargeSampleCapacitor();ADCC_StartConversion(channel_ANA0);while (1){;}}void ThresholdISR(void){errVal = ADCC_GetErrorCalculation();PIR1bits.ADIF = 0;}