150 likes | 357 Views
ECT 357. Ch 9 Interrupt’s. Today’s Quote: A person’s true character is revealed by what he does when no one is watching. Obey them not only to win their favor when their eye is on you, but like slaves of Christ, doing the will of God from your heart. Ephesians 6:6. Interrupt Uses.
E N D
ECT 357 Ch 9 Interrupt’s
Today’s Quote: A person’s true character is revealed by what he does when no one is watching. Obey them not only to win their favor when their eye is on you, but like slaves of Christ, doing the will of God from your heart. Ephesians 6:6
Interrupt Uses • Serial Communications • External I/O Access • Completion of Processes • Timers/Counters • Automatic Executions
Interrupt Timing The time it takes to process one interrupt routine must be less than the time between interrupt calls. If there are several interrupts, the total of the interrupts must be less than the time between any of the interrupt calls.
Terms • Latency- The time it takes from when an interrupt is requested until it starts to be processed • Handler- a subroutine which determines what interrupt routine will be processed and in what order. • Critical Region- a portion of code that must be run contiguously that can’t be interrupted by an interrupt.
Interrupt Sources • Timers (0,1,2,3) • Capture/Compare/PWM • Serial Peripheral Interface • I2C Interface • UART • External (0,1,2,RB) • Low Voltage • A/D • Parallel Slave Port
Low Priority Interrupt Initialization • IPEN=0 (Low Interrupts Only) (RCON) • Set Priority Bit (Low) • Set Edge Sensitivity • Set Local Enable Bit • Set Direction Bit (TRISB) • Set Port Bit Type • Clear Flag Bit • GIEL=1 (INTCON) enable low priority ints
Low Priority Interrupt Entry • CPU completes execution of current instruction • GIEL (Global Interrupt Enable) bit is cleared • Contents of the program counter are saved • Program counter loaded with 0x0018
Low Priority Interrupt Handler Execution • Save STATUS Register • Save WREG if used • Test Interrupts For Servicing • Run Interrupt Subroutines • Restore WREG • Restore STATUS register
Low Priority Interrupt Exit • Retfie instruction resets GIEL bit • The saved contents of the program counter are restored • Program counter is loaded with address of next instruction where it left off.
High Priority Interrupt Initialization • IPEN=1 (Low and High Interrupts) (RCON) • Set Priority Bit (High) • Set Edge Sensitivity • Set Local Enable Bit • Set Direction Bit (TRISB) • Set Port Bit Type • Clear Flag Bit • GIEH=1 (INTCON) enable high priority interrupts
High Priority Interrupt Entry • CPU completes execution of current instruction • GIEH (Global Interrupt Enable) bit is cleared • Contents of the program counter, STATUS register, working register, and bank select register are saved • Program counter loaded with 0x0008
High Priority Interrupt Handler Execution • Test Interrupts For Servicing • Run Interrupt Subroutines
High Priority Interrupt Exit • Retfie FAST instruction resets GIEH bit • Contents of the program counter, STATUS register, working register, and bank select register are restored. • Program counter is loaded with address of next instruction where it left off.
External Interrupts • PORTB is used for external interrupts • Set Direction Bit (TRISB) • Set Port Bit Type • B0-2 External Interrupt Pins • B4-7 port change pins (RBIF bit in INTCON)