POLITEKNIK SULTAN IDRIS SHAH JABATAN PENGAJIAN POLITEKNIK DAN KOLEJ KOMUNITI KEMENTERIAN PENDIDIKAN TINGGI All Rights Reserved Publication 2023 This eBook is written by the author and the copyright is protected. It is not allowed to copy in any form and in any way possible, such as electronically, photocopy, mechanics, recording, or any form without the author’s permission. The content of this eBook is not guaranteed to be suitable for every reader, nonetheless, all the content is based on author’s own experiences. Published by Politeknik Sultan Idris Shah Sungai Lang, 45100 Sungai Air Tawar Selangor No. Tel : 03 3280 6200 No. Fax : 03 3280 6400 Laman web : https://psis.mypolycc.edu.my Cataloguing-in-Publication Data Perpustakaan Negara Malaysia A catalogue record for this book is available from the National Library of Malaysia eISBN 978-967-2860-81-5
THE EMBEDDED BOOK: Fundamental of Using PIC18F Published by Zainora Bt. Kamal ludin, Nurain Bt. Mohamad Izzuan Wong & Kalaivani a/p Ramachandran
First Edition Ministry of Higher Education All Rights Reserved Publication 2023 This eBook is written by the author and the copyright is protected. It is not allowed to copy in any form and in any way possible, such as electronically, photocopy, mechanics, recording, or any form without the author’s permission. The content of this eBook is not guaranteed to be suitable for every reader, nonetheless, all the content is based on author’s own experiences. Published by: Politeknik Sultan Idris Shah, Sungai Lang, 45100 Sungai Air Tawar, Selangor, MALAYSIA. Phone : 03 3280 6200 Fax : 03 3280 6400 Website : https://psis.mypolycc.edu.my Cataloguing-in-Publication Data Perpustakaan Negara Malaysia A catalogue record for this book is available from the National Library of Malaysia eISBN 978-967-2860-81-5
TABLE OF CONTENTS LESSONS Preface i 1. Introduction to Embedded System and PIC Programming in C • Terms of Embedded System, Microcontroller & Microprocessor • Microcontroller VS Microprocessor • Digital input output TRISx, PORTx, LATx • Byte vs Bit – TRIS • Byte vs Bit – PORT • LATx • Minimum Connection for PIC18F • Structure of C program for PIC • Time delay using for loop 1. Pic Programming For I/O Manipulation 2. Pic Programming For Logic And Arithmetic Operation Let’s Try Tutorial 1 2 3 4 5 5 6 6-7 8 8 10 15 19 Synopsis ii EXERCISES TUTORIAL 1
2. PIC Timer Programming in C • Function of Timer • T0CS (Timer0 clock source) • TMR0IF (Timer0 interrupt flag) • Steps to Program TIMER0 in 16-bit mode • Simple read T0CON Table • Example Timer0 function/Subroutine • Formula for Timer Delay Calculation using 16 bit mode • Finding value to be loaded into the Timer • Finding value to be loaded into the Timer If desired time delay in • Finding value if given TMR0H & TMR0L also XTAL • Prescaler and generating a Large Time Delay • Counter Programming steps 3. Timer Let’s Try Tutorial 2 21 22 23 23 24 25 25 26 26 27 28 28 30 37 LESSONS EXERCISES TUTORIAL 2
Editor: Zainora Binti Kamal ludin Nurain Binti Mohamad Izzuan Wong Kalaivani A/P Ramachandran P S I S LESSONS 3. Interrupt Programming in C • A micro controller can serve multiple devices • Interrupt vs Polling • Steps in Executing Interrupt • Source of interrupts in the PIC18 • Register in interrupts • Interrupt source bits control • Programming external interrupt • Syntax writing to call interrupt flag and Interrupt Enable • Programming TIMER Interrupt • PortB-Change Interrupt 4. Interrupt Let’s Try Tutorial 3 39 39 40 41 42 42 43 43 44 44 46 52 EXERCISES References 53 Bibliography 54 TUTORIAL 3
This e-book is written by Mrs. Zainora, Mrs. Nurain, and Mrs. Kalaivani to help you quickly understand and review after completing each lesson. Presented in the form of tables and smart art that are organized to lighten the visual eye and not burden the reader's mind. Who This Book Is For This book provides comprehensive notes and exercises for embedded systems for people who: • Already studied PIC18F • Are familiar with C programming • Want to strengthen PIC18 knowledge Long notes make it difficult for you to focus on important content. With the existence of this book, it is expected to help you understand and master it quickly. How This Book Is Organized The book comprises the following 3 (THREE) chapters: • Introduction to Embedded System andPIC Programming in C • PIC Timer Programming in C • Interrupt Programming in C How to Contact Us Find us at : Jabatan Kejuruteraan Elektrik Politeknik Sultan Idris Shah Sungai Lang, 45100 Sungai Air Tawar Selangor PREFACE i
The Embedded Book: Fundamentals of Using PIC18F covers the basic concept of a microcontroller system based on the Peripheral Interface Controller (PIC). In lesson 1, students will learn the concept of an embedded system, the structure of C programming for the PIC18F, recognize digital input and output, write time delays and i/o operations. Lesson 2 will discuss the concept of a timer, the register used for a timer, and the C program for a timer. Then, in Lesson 3, we will focus on the concepts of interrupt and PIC interrupt programming in C. The exercises for every lesson are provided to help students quickly understand the concept covered by each lesson. SYNOPSIS ii
LESSONS 1 Introduction to Embedded System and PIC Programming in C 1
•Definition : An embedded system is a special-purpose computer system designed to perform one or a few dedicated functions often with real-time Embedded system •Definition : A microcprocessor A single chip that contains a whole CPU Has the ability to fetch and execute instructions stored in memory Has the ability to access external memory , external I/O and other peripherals Microprocessor •Definition : A microcontroller is a single integrated circuit containing processor core, memory, programmable input/output peripherals Microcontroller Terms of Embedded System, Microcontroller & Microprocessor
Microcontroller Microprocessor Cost Cheaper Expensive Speed Slower (in MHz range) Faster (in GHz range) Purpose Special General Dependen cy Single chip has almost all components Need external components to be able to interact Resources Limited Unlimited All in single chip CPU & several supporting chips Microcontroller VS Microprocessor 3
I/O Port pins • PIC18F4580 40-pin chip • 36 pins are inputoutput • Vdd (Vcc) 2 pins • Vss (GND) 2 pins PIC18F4580 has 5 ports • PORTA – 8 pins • PORTB – 8 pins • PORTC – 8 pins • PORTD – 8 pins • PORTE – 4 pins Code instruction for i/o handling • TRISx: Data Direction register for module ‘x’ • PORTx: PORT register for module ‘x’ • LATx: Latch register for module ‘x’ Depending on the family member Digital input output TRISx, PORTx, LATx 4
BYTE (8 bits) BIT (1 bit) TRISx where x is the port A,B,C, D or E TRISxbits.Rxy where x is the port A,B,C, D or E and y is the bit (0-7) Example : TRISB = 0B11111111 ; //PORTB as input TRISD = 0B00000000 ; //PORTD as output Example : TRISBbits.RB2 = 1 ; //pin RB2 as input TRISDbits.RD5 = 0 ; //pin RD5 as output Remember!!! • TRIS = 1; input • TRIS = 0; output Byte vs Bit - TRIS 5 BYTE (8 bits) BIT (1 bit) PORTx where x is the port A,B,C, D or E PORTxbits.Rxy where x is the port A,B,C, D or E and y is the bit (0-7) Example : PORTB = 0B11111111 ; //all pins at PORTB are HIGH PORTD = 0B00000000 ; //all pins at PORTD are LOW Example : PORTBbits.B2 = 1 ; //pin RB2 is HIGH PORTDbits.RD5 = 0 ; //pin RD5 is LOW Byte vs Bit - PORT Quick Tips
• The latch register reads and modifies the write operation on the value of I/O pin • Stored the output data that is to be passed on to the external hardware • A write to the LATx register has the same effect as write to the PORTx register Minimum Connection for PIC18F ➢ Power supply circuitry (VDD & VSS) ➢ Oscillator circuitry (OSC1 & OSC2) ➢ Reset circuitry (MCLR) 6 Figure 1.1 : Minimum Connection LATx
Button Active Low Active High Pressed 0 1 Not Pressed 1 0 Remember!!! • Active low circuit • The switch place beside ground • Active high circuit • The switch place beside power supply 7 Figure 1.2 : Minimum Connection Table 1.1 : Truth table button Quick Tips
void MSDelay (unsigned int itime) { unsigned int i; unsigned char j; for (i=0;i<itime;i++) for (j=0;j<165;j++); } Time delay using for loop >>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<< End 8 #include <p18f4580.h> #pragma config OSC = HS #pragma config FCMEN = OFF #pragma config IESO = OFF #pragma config PWRT = OFF #pragma config WDT = OFF #pragma config MCLRE = ON #pragma config PBADEN = OFF #pragma config LVP = OFF #pragma config XINST = OFF //declaration constant void main (void) //main function { // declaration of input/output port while(1) //infinite loop { //write main program } } Structure of C program for PIC
Exercise 1 9
Pic Programming For I/O Manipulation 1. A microcontroller a heart of embedded system. Describe this statement by referring to the definition of embedded system. [3 marks] 2. Explain the function of TRISx register in I/O with an example of C language program using bit addressable. [4 marks] 3. List two advantages and two disadvantages of microcontroller. [4 marks] 4. Explain the function of TRISx, PORTx and LATx. [6 marks] 5. Figure below shows the connection between input devices and output devices with PIC microcontroller. Write the C language to configure the input/output port using bit addressable and byte addressable. [8 marks] 6. A programmer decides to use two DC motors at pin RB6 and RB7. while the LED at pin RA5 and two digital sensors at pin RB0 ad RB1 in his circuit. Write the input output initialization for the program using bit addressable format in C language. [6 marks] Temperature sensor Door sensor Smoke sensor Buzzer LED Motor RB0 RC1 RC2 RB5 RC7 RB6 10
SOLUTION Pic Programming For I/O Manipulation 1. Definition of Embedded System: An embedded system is a special-purpose computer system designed to perform one or a few dedicated functions often with real-time. 2. The function of TRISx is as a Data direction register whether Read or Write (Input or Output) to the microcontroller which can be done by setting the TRIS bit for the relevant port. For example: TRISAbit.RA2=1 //make Port A2 as input TRISDbits.RD4=0 //make Port D4 as output 3. D 4. TRISx register : Declare the I/O ports as an INPUT or OUTPUT by (1=INPUT) and (0=OUTPUT). PORTx register : The PORTx register determines whether the power level output should be HIGH or LOW of the output pins. LATx register : For reads and write operation on the value of I/O pin and stored the output data that is to be passed on to the external hardware. Write to LATx register has same effect as a write to the PORTx register 11
SOLUTION Pic Programming For I/O Manipulation 5. Using bit addressable: TRISBbits.TRISB0=1; TRISCbits.TRISC2=1; TRISCbits.TRISC7=1; TRISCbits.TRISC1=0; TRISBbits.TRISB5=0; TRISBbits.TRISB6=0; Using byte addressable: TRISB=0b00000001 @ 0x01 TRISC=0b10000100 @ 0x84 12
SOLUTION Pic Programming For I/O Manipulation 6. C program: #include <p18f4580.h> void main(void) { TRISBbits.RB6 = 0; TRISB = 0X03; TRISBbits.RB7 = 0; TRISA = 0X20; TRISAbits.RA5 = 0; @ TRISBbits.RB0 = 1; TRISBbits.RB1 = 1; while() { } } 13
Exercise 2 14
0x9A>>3 Pic Programming For Logic and Arithmetic Operation 1. Referring to the Figure below, calculate the value of registers PORTA, PORTB and PORTC after each instruction. [6 marks] 2. Solve the following shift operation: void main (void) { TRISA = 0; TRISC = 0; TRISD = 0; A=0b01010101; B=0b10101010; PORTA=A + B; PORTB=A | B; } 15
SOLUTION Pic Programming For Logic and Arithmetic Operation 1. PORTA = A + B PORTA = A | B 0 1 0 1 0 1 0 1 + 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 0 X F F 0 1 0 1 0 1 0 1 | 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 0 X F F 16
SOLUTION Pic Programming For Logic and Arithmetic Operation 2. 0x9A>>3=0x13 Shift right 3 times >>3 1 0 0 1 1 0 1 0 0 1 0 0 1 1 0 1 0 0 1 0 0 1 1 0 0 0 0 1 0 0 1 1 1 3 17
Tutorial 1 18
Let’s try Tutorial 1 19 SCAN ME “Most people fail, not because of lack of desire, but, because of lack of commitment.” –Vince Lombardi
LESSONS 2 PIC Timer Programming in C 20
Functions of the timer are: 1. Generate a time delay 2. As a counter to count events happening outside the microcontroller Timer in PIC18F4580: Clock source can be internal or external Basic register of the timer: • PIC18 has 16 bits wide timer: Low Byte -TMRxL & High Byte – TMRxH • Each timer has TxCON – timer control-timer control-for setting mode operation. X can be Timer 0, 1, 2, 3. Internal clock: Fosc/4 is feed for generating Timer • 1/4th of the frequency of the crystal oscillator on the OSC1 and OSC2 pins (Fosc/4) is fed into the timer • Usually used to generate a time delay **Focs → crystal oscillator 21 Table 2.1 Figure 2.1 : Crystal Oscillator
External clock: used as Counter (only Timer2 cannot be used as counter) • By choosing the external clock option, we feed pulses through one of the PIC’s pins. • Usually used as a counter To decide whether the clock source is internal (Fosc/4) or external • T0SC = 0 , Fosc/4 is used as clock source and in this case, timer used as delay generation • T0SC = 1 , Clock source is external which comes from RA4/T0CKI and in this case timer used as counter T0CS (Timer0 clock source) External Internal 22 Figure 2.2 : RA4/T0CKI feed digital wave Figure 2.3 : External and Internal pin
Load value into TOCON (8bit or 16bit): (T0CON = 0bxxxxxxxx;) Load TMROH & TMROL initial count value ( TMR0H = 0x??; TMR0L = 0x??;) Start timer with instruction (T0Conbits.TMR0ON=1;) Keep monitoring the timer flag (TMR0IF) to see if it raised .Get out of the loop when TMR0IF become High (while(INTCONbits.TMR0IF==0); Stop the timer (T0CONbits.TMR0ON=0;) Clear the TMR0IF flag for next round INTCONbits.TMR0IF=0 Steps to Program TIMER0 in 16-bit mode TMR0IF (Timer0 interrupt flag) • TMR0IF bit is part of the INTCON (interrupt control) register • When the timer reaches its maximum value of FFFFH , it rolls over to 0000H and TMR0IF is set to 1 (flag bit is raised) 23 Figure 2.1 : Crystal Oscillator Figure 2.4 : Steps of programming Timer0
Bit Name 1 0 7 TMR0ON – Tirner0 On/Off Control bit Enable (start) Tirner0 Stop Timer0 6 T08BIT – Timer0 8-bit / 16-bit selector bit Timer0 an 8-bit timer/counter Timer0 a 16-bit timer/counter 5 T0CS - Timer0 Clock Source Select bit External clock from RA4/T0CK1 pin (event counter) Internal clock (Fosc/4 from XTAL oscillator) – time delay 4 T0SE - Timer0 Source Edge Select bit Increment on H-to-L transition on TOCKI pin Increment on Lto-H transition on T0CKI pin 3 PSA – Timer0 prescaler assignment bit Timer0 prescaler is NOT assigned. Timer0 clock input bypasses prescaler Timer0prescaleris assigned. Timer0 clock input comes from prescaler output. 2-0 T0PS2:T0PS0 - Timer0 Prescaler Select bits 111 = 1:256 , 110 = 1:128 , 101= 1:64 100 = 1:32 , 011 = 1:16 , 010 = 1:8 001 = 1:4 , 000 = 1:2 Simple read T0CON Table TMR0ON T08BIT TOCS TOSE PSA TOPS1 TOPS0 24 Table 2.2: T0CON table
void T0Delay () { T0CON = 0X08; // Timer0, 16 bit mode, no prescaler TMR0H = 0XFF; //load TH0 TMR0L = 0XF2; //load TL0 T0CONbits.TMR0ON = 1; //turn on timer while (INTCONbits.TMR0IF == 0); //wait for TF0 to roll over T0CONbits.TMR0ON = 0; //turn off timer INTCONbits.TMR0IF = 0; //clear TF0 } Example Timer0 function/Subroutine Formula for Timer Delay Calculation using 16 bit mode No.count (hex) = (FFFF – YYXX) + 1 No.count(decimal) = 65536 – NNNN Tdelay = number of counts x timer (osc) x prescaler *Delay equal to half wave (1/2 waveform) Delay 25
Finding value to be loaded into the Timer EXAMPLE 1 Assume that XTAL = 10Mhz, write a program to generate a square wave with a period of 10 ms on pin PORTB.3 Divide the desired time delay by TimeOSC (65536 –n (from step1)) Convert step2 to HEX ----YYXX (result) TMR0H=YY TMR0L=XX SOLUTION STEPS: Finding value to be loaded into the Timer If desired time delay in EXAMPLE 1 Assume XTAL=10Mhz, modify the program to generate a square wave of 2kHz frequency on pin PORTB3. SOLUTION STEPS: T=1/f = 1/2kHz = 500µ Delay is ½ portion of high portion pulses = ½ x 500µ = 250µ 500µ/0.4µ=625 655536 – 625 = 64911 Convert to HEX : FD8F TMR0H=8F TMR0L=FD 26 Figure 2.5 : Steps to load value into Timer Figure 2.6 : Steps to load value into Timer if desired time given
Finding value if given TMR0H & TMR0L also XTAL EXAMPLE 3 Write a C18 program to toggle only the PORTC.RC3 bits continuously with some delay. Use Timer0, 16 bit mode, and no prescaler options to generate the delay (square wave of 50% duty cycle). Set the register TMR0H = 35H and TMR0L = 00H . Then, calculate the amount of time delay generated by the timer. Assume that XTAL = 10Mhz SOLUTION STEPS: Register value, 3500 → 13568 13568 = 65536 − = 65536 − 13568 = 51968 Time delay, = × X 1 = 51968 × 0.4 = 20.7872 Tick counter frequency, = 1 = 1 2.5 = 0.4 Frequency input, = 4 = 10 4 = 2.5 State the information where; TMR0H=35 TMR0L=00 NO PRESCALALER = 1 27 Figure 2.7 : Steps to load value into Timer if TMR0L and TMR0H also XTAL given
Prescaler and generating a Large Time Delay Counter Programming steps Counter: use pulse outside the PIC18 that increment the TH & TL register TOCS=1; counter counts up as pulses are fed from PORTA.RA4 The pin is called TOCKI (Timer0 clock input) Another application:- -Digital clock display in LCD -Fed external square wave of 60Hz frequency into Timer -Nice digital clock (but no accurate) XTAL Oscillator Devide by 4 (f/4) Divide value of prescaler (f/prescaler) Large Time Delay: TMRXX >>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<< End 28 Figure 2.8 : Steps to generate large Time Delay Figure 2.9 : Steps to generate large Time Delay
Exercise 3 29
EXERCISE 3 : Timer 1. Explain the function of prescaler to generate a large time delay. [4 marks] 1. Construct a single instruction to enable and disable the Timer 0 and Timer 1 interrupt, enable external hardware interrupt at RB0 (INT0), RB1 (INTI1), RB2 (INT2) and lastly disable all the interrupt. [8 marks] 1. Build a C program for main() function to make LED1 on port RB0 and LED2 on port RB1 blink alternately for each 2 second continuously. You are given a sub function for time delay as below. [6 marks] void Delay_1ms(unsigned int x) { for(;x>0;x--) __delay_ms(1); } 4. A programmer decides to toggle all LED of PORTC 45000 times on a project board. Write the coding using C language for the task. (Initial value of PORTC=C7H). Assume no delay time is required. [10 marks] 30
SOLUTION EXERCISE 3 : Timer 1. Function of prescaler: 2. • Prescaler means controlling the incrementing value in timer registers • It is used to reduce a high frequency electrical signal to a lower frequency by integer division. • Example: If we assign the prescaler value 1:2 in OPTION_REG. The TMRO register value will be incremented by one for two cycles. • If we assign the prescaler value 1:4 in OPTION_REG. The TMRO register value will be incremented by one for four cycles. Interrupt Sources\ Enable Interrupt Disable Interrupt Timer0 INTCONbits.TMRO1E=1 ; INTCONbit.TMR01E=0 Timer1 PIE1bit.TMR1IE=1; PIE1bit.TMR1IE=0; RB0(INT0) INTCONbits.INT0IE=1; - RB1(INT1) INTCON3bits.INT1IE=1; - RB2(INT2) INTCON3bits.INT2IE=1; - Disable All Interrupt INTCONbit.GIE=0; 31
SOLUTION EXERCISE 3 : Pic Programming For I/O Manipulation 3. #include <p18f4580.h> #define LED1 PORTBbits.RB0 #define LED2 PORTBbits.RB1 void void MSDelay (unsigned int itime); void main(void) { TRISB = 0X03; while() { LED1 = ~LED1 MSDelay(2000); LED2 = ~LED2 MSDelay(2000); } } void MSDelay (unsigned int itime) { unsigned int i; unsigned char j; for (i=0;i<itime;i++); for (j=0;i<165;j++); } 32
SOLUTION EXERCISE 3 : Pic Programming For I/O Manipulation 4. #include<118f458.h> void main (void) { Unsigned int z; TRISC=0; for(z=0;z<45000;z++) { PORTC=0xC7; //C7=11000111 PORTC=0x38; //~C7=00111000 @PORTC=~PORTC } while(1) } 33
SOLUTION EXERCISE 3 : Timer 5. #include <p18f4580.h> #define LED PORTCbits.RC3 void T0Delay (void); void main (void) { TRISCbits.RC3 = 0; LED = 0; while (1) { LED = ~LED; T0Delay (); } } void T0Delay () { T0CON = 0X08; TMR0H = 0X35; TMR0L = 0X00; T0CONbits.TMR0ON = 1; while (INTCONbits.TMR0IF == 0); T0CONbits.TMR0ON = 0; INTCONbits.TMR0IF = 0; } 34
SOLUTION EXERCISE 3 : Timer Frequency input, = 4 = 10 4 = 2.5 Tick counter frequency, = 1 = 1 2.5 = 0.4 *Time delay, = × x Prescalar(1) = 51968 × 0.4 = 20.7872 Register value, 3500 → 13568 = 65536 − = 65536 − 13568 = 51968 *No.count(decimal) = 65536 – NNNN (TMR0HTMR0L)dec *Tdelay = number of counts (n) x timer (osc) x prescaler T0CON=0x08; 35
Tutorial 2 36
Let’s try Tutorial 2 37 SCAN ME “If you want something you’ve never had, you must be willing to do something you’ve never done.” – Thomas Jefferson
LESSONS 3 Interrupt Programming in C 38
Interrupt Interrupt method: is the signal send to the microcontroller to mark the event that requires immediate attention. The microcontroller stops whatever it is doing upon receiving an interrupt signal and serves the device. The program associated with interrupt is called the interrupt service routine (ISR) or interrupt handler The advantage of interrupt: microcontroller can serve many devices which each device can get the attention based on the priority. Interrupt are used to avoid tying down the microcontroller. PollingPolling method: is a situation where the microcontroller accesses at the exact time interval the external devices and gets the required information. The microcontroller continuously monitors the status of a given device; when the status condition is met, it performs the service. The polling cannot assign priority because it checks all the devices in a round robin fashion. Polling tie up the microcontroller in one activity. Using 2 (TWO) ways in which the controller treats the device: i. Polling ii. Interruptions A micro controller can serve multiple devices 39 Interrupt vs Polling Method Table 3.1 : Interrupt vs Polling
Finishes instruction on main ( ) Save address of the next instruction (PC) Interrupt vector table invoke Helps the microcontroller to GO TO the address of ISR 0008h or 0018h Start to execute the end instruction until RETFIE Finish its interrupt instruction Execute the rest of main ( ) instruction Steps in Executing Interrupt 40 Figure 3.1 : Interrupt Service Routine invoke Figure 3.2 : Steps of Interrupt Execute
Step in Executing Interrupt External Source Internal Peripheral Sources • RB0 (INT0), RB1 (INT1) & RB2 (INT2) ✓ Can be used to connect external interrupting sources ✓ Keypad or switches • PORTB Interrupt (RB1) ✓ Change in logic levels of pin RB4 – RB7 • Timer (0 - 3) • ADC • Serial I/O • CCP (Compare capture pulsewidth modulation) Source of interrupts in the PIC18 Table credit to Ali Mazidi 2023…. 41 Table 3.2 : PIC18 Interrupt source Figure 3.3 : PIC18F4580 Interrupt external source pins