SlideServe
Menu
Préférences
© SlideServe · v2026

Interrupts

tejano avatar
15 diapositives · 299 Views · Oct 13, 2014

Interrupts. Microprocessor and Interfacing 261214. Example: Writing a Game. Need to Check Keyboard Input. Method 1: Using a Loop Program keeps checking for keyboard input. While (1) [ If Key = Right Then moveRight ElseIf Key = Left Then moveLeft End If ].

Interrupts - slide 1
01 / 15Interrupts
1 / 17

Télécharger la présentation

Interrupts
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Interrupts Microprocessor and Interfacing261214

  2. Example: Writing a Game Need to Check Keyboard Input

  3. Method 1: Using a LoopProgram keeps checking for keyboard input While (1) [ If Key = Right Then moveRight ElseIf Key = Left Then moveLeft End If ]

  4. Mothod II: Use KeyPress EventRuns only when there is a keyboard interrupt KeyPressEvent(Key) If Key = Left Then MoveLeft ElseIf Key = Right Then MoveRight End If End Subroutine

  5. What’s the Difference BetweenMethod I - Method II ?

  6. Method I : Software Polling Method II : Event or Interrupt Driven

  7. I/O Handling Techniques • Software Polling • Interrupts • Direct Memory Access (DMA)

  8. Benefits of Using Interrupts • Consumes much less CPU • Especially when interrupt generated by hardware • Cleaner & Simpler Code • Allows Basic Parallel Processing

  9. Exercise: Program a PIC Microcontroller • Blink an LED every 0.5 sec • Also receives serial data from the computer What’s wrong with this program? While (1) { output_toggle(LED); delay_ms(500); data = getchar(); }

  10. A better program, but not best While (1) { output_toggle(LED); delay_ms(500); if (kbhit()) { data = getchar(); } }

  11. How do we fix the problem? Available Commands • Getchar() – wait and return serial data • Output_toggle(LED) • Time() – returns current time (in ms) • Kbhit() – returns true if serial data is available

  12. Solution Software Polling IntcurrentTime; Char data; startTime = time(); While (1) { if (time() – startTime > 500) { output_toggle(LED); startTime = time(); } if (kbhit()) { data = getchar(); } }

  13. Same Program with Timer Interrupt timerISR() { output_toggle(LED); } Main() { setupTimer(); while (1) { data = getchar(); } }

  14. Interrupt Handling

  15. Multi-Interrupt Handling