1 / 19

ECE 447: Lecture 7

ECE 447: Lecture 7. Polling and Interrupts. Main Program. Polling routine. Service device #1. Signal from device #1?. Service device #2. Signal from device #2?. Signal from device #N?. Service device #N. Cycle continuously. ECE 447: Polling. ECE 447: Interrupt.

Download Presentation

ECE 447: Lecture 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECE 447: Lecture 7 Polling and Interrupts

  2. Main Program Polling routine . . . . . . . Service device #1 Signal from device #1? Service device #2 Signal from device #2? Signal from device #N? Service device #N Cycle continuously ECE 447: Polling

  3. ECE 447: Interrupt

  4. Event / Interrupt Pin STRA - Strobe A Interrupt PA0 - Input Capture 3 (IC3) PA1 - Input Capture 2 (IC2) PA2 - Input Capture 1 (IC1) PA3 - Input Capture 4/ Output compare 5 (IC4/OC5) PA7 - Pulse Accumulator Input (PAI) ECE 447: External Edge Sensitive Interrupts

  5. Event / Interrupt Pin IRQ - maskable interrupt, may be ignored by setting a bit in a “mask” register. XIRQ - non-maskable interrupt, can not be ignored, no “mask” register available. ECE 447: External Level Sensitive Interrupts Non-Maskable Interrupts are usually reserved for critical events (i.e. unrecoverable errors)

  6. ECE 447: Interrupt Service Routines

  7. ECE 447: Interrupt Vectors

  8. ECE 447: Interrupt Vector Jump Table

  9. ECE 447: Register Structure of 68HC11 Accumulators A and B or A B 7 0 7 0 D Double Accumulator D 0 15 X-index register IX 0 15 Y-index register IY 0 15 Stack Pointer SP 0 15 Program Counter PC 0 15 Condition Code Register 7 0 CCR S X H I N Z V C

  10. CCR 7 0 S X H I N Z V C carry / borrow overflow zero negative I-interrupt mask half-carry (from bit 3) X-interrupt mask stop disable ECE 447: Condition Code Register

  11. set cleared interrupt disabled interrupt enabled 1. by RESET 2. whenever an interrupt occurs 3. using SEI 4. using TAP 1. by RTI 2. using CLI 3. using TAP set cleared interrupt disabled interrupt enabled 1. by RESET 2. whenever an interrupt occurs 1. by RTI 2. using TAP ECE 447: Setting and Clearing Interrupt Masks I - interrupt mask X - interrupt mask

  12. ECE 447: Condition Code Instructions 1. set a flag 1  flag SE [C, V, I] 2. clear a flag 0  flag CL [C, V, I] 3. change all flags A  CC TAP 4. read all flags CC  A TPA

  13. CC Register Mask 0 - interrupt enabled 1 - interrupt disabled Local Enable Flag 1 - interrupt enabled 0 - interrupt disabled Jump Table Address Interrupt Source Vector Address TMSK1,IC3I TMSK1,IC2I TMSK1,IC1I TMSK2, RTII — PIOC, STAI — — — CONFIG, NOCOP OPTION,CME Timer input capture 3 Timer input capture 2 Timer input capture 1 Real-time interrupt IRQ (external pin) + STRA XIRQ Software interrupt Illegal opcode trap COP failure Clock monitor fail I I I I I X NA NA NA NA FFEA-EB FFEC-ED FFEE-EF FFF0-F1 FFF2-F3 FFF4-F5 FFF6-F7 FFF8-F9 FFFA-FB FFFC-FF 00E2-00E4 00E5-00E7 00E8-00EA 00EB-00ED 00EE-00F0 00F1-00F3 00F4-00F6 00F7-00F9 00FA-00FC 00FD-00FF ECE 447: 68HC11 Interrupts

  14. CC Register Mask 0 - interrupt enabled 1 - interrupt disabled Local Enable Flag 1 - interrupt enabled 0 - interrupt disabled Jump Table Address Interrupt Source Vector Address TMSK2,PAII TMSK2,PAOVI TMSK2,TOI TMSK1,I4/O5I TMSK1,OC4I TMSK1,OC3I TMSK1,OC2I TMSK1,OC1I Pulse accumulator input edge Pulse accumulator overflow Timer overflow Timer input capture 4/ output compare 5 Timer output compare 4 Timer output compare 3 Timer output compare 2 Timer output compare 1 I I I I I I I I FFDA-DB FFDC-DD FFDE-DF FFE0-E1 FFE2-E3 FFE4-E5 FFE6-E7 FFE8-E9 00CA-00CC 00CD-00CF 00D0-00D2 00D3-00D5 00D6-00D8 00D9-00DB 00DC-00DE 00DF-00E1 ECE 447: 68HC11 Interrupts

  15. CC Register Mask 0 - interrupt enabled 1 - interrupt disabled Local Enable Flag 1 - interrupt enabled 0 - interrupt disabled Jump Table Address Interrupt Source Vector Address — I I — SCCR2,RIE SCCR2,RIE SCCR2,TIE SCCR2,TCIE SCCR2,ILIE SPCR, SPIE FFC0-D5 FFD6-D7 FFD8-D9 — 00C4-00C6 00C7-00C9 Reserved SCI Serial System • receive data register full • receiver overrun • transmit data register empty • transmit complete • idle line detected SPI serial transfer complete ECE 447: 68HC11 Interrupts

  16. PC7-PC0 PORTC PORTCL STRA Reading PORTC reads data currently present on input lines Reading PORTCL reads data latched in the input register using a falling or rising edge of STRA PORTC - unsychronized input PORTCL - synchronized input ECE 447: Port C & CL

  17. PC7:PC0 DATA1 DATA2 STRA PIOC, EGA DATA2 read DATA1 read PIOC, STAF PIOC, STAI interrupt STAF is reset by a two-step process: 1) read PIOC 2) read PORTCL ECE 447: When a Strobe Occurs

  18. #include <hc11e9.h> while (!PIOC & STAF); a = PORTCL; ECE 447: Polling for STRA

  19. STRA interrupt has the same Vector Address and the same Jump Table Address as IRQ Interrupt service routine should contain checking for a source of the interrupt Example: #include <hc11e9.h> #define STAF_STAI (STAF | STAI) if (PIOC & STAF_STAI == STAF_STAI) { STRA routine } else { IRQ routine } ECE 447: Interrupt Service Routine for STRA

More Related