Download presentation
Presentation is loading. Please wait.
Published bySuhendra Muljana Modified over 6 years ago
1
IT863 Mikrokontroler dan Antarmuka Perangkat Digital
IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id Sesi 8 Real time clock, interupt, latency
2
InterrupT What is the use of interrupts in microprocessor?
In system programming, an interrupt is a signal to the processor emitted by hardware or software indicating an event that needs immediate attention. An interrupt alerts the processor to a high-priority condition requiring the interruption of the current code the processor is executing. ( IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id What is the use of interrupts in microprocessor? An interrupt is a condition that causes the microprocessor to temporarily work on a different task, and then later return to its previous task. Interrupts can be internal or external. (
3
Cara kerja CPU: CPU RAM IR
CPU in a microcontroller sequentially executes the user’s program fetching them one by one from the memory to the Instructor Register (IR) in the CPU and then decoding each of instructions in the CPU and running them in that sequence. IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id RAM CPU repeat... IR X=x-2+y Fetching until X>100|x=Z
4
Cara kerja interrupt: CPU RAM IR
CPU in a microcontroller sequentially executes the user’s program fetching them one by one from the memory to the Instructor Register (IR) in the CPU and then decoding each of instructions in the CPU and running them in that sequence. IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id RAM CPU repeat... IR X=x-2+y Fetching until X>100|x=Z
5
Interrupt working units
Bagian-bagian yang membuat interrupt dapat dilakukan IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id (Ying Bai : Practical Microcontroller Engineering with ARM Technology : 2016 Chapter 5 page 262)
6
Interrupt working units (2)
global exception/interrupt control register under the control of the CPU By resetting or setting certain bits in this global interrupt control register. local exception/interrupt control register related to some associated events or devices. can be accessed and controlled by the programmer exception or interrupt vector table a collection of the entry addresses of the interrupt service routines device-dependent or interrupt-source-dependent each different exception or interrupt source has a different unique vector IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id
7
“So,what are interrupts?”
IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id Hampir semua processor memiliki interupsi. Interupsi memungkinkan kita untuk merespon even eksternal selagi melakukan hal lain. Misalnya, jika Anda memasak makan malam Anda dapat menempatkan kentang untuk memasak selama 20 menit. Daripada menatap jam selama 20 menit Anda mungkin mengatur timer, dan kemudian pergi menonton TV. Ketika timer berdering, Anda meng“interupsi" menonton TV untuk melakukan sesuatu dengan kentang.
8
Interrupt di Arduino interrupt() noInterrupt() attachInterrupt()
detachInterrupt() IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id
9
Interrupt() & noInterrupt()
void setup() {} void loop() { noInterrupts(); // critical, time-sensitive code here interrupts(); // other code here } Re-enables interrupts (after they've been disabled by noInterrupts()). IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id Disables interrupts (you can re-enable them with interrupts()). Area KRITIS, realtime
10
attachInterrupt INGAT!!!! Menggunakan interrupt pada pin tertentu
Board Digital Pins Usable For Interrupts Uno, Nano, Mini, other 328-based 2, 3 Mega, Mega2560, MegaADK 2, 3, 18, 19, 20, 21 Micro, Leonardo, other 32u4-based 0, 1, 2, 3, 7 Zero all digital pins, except 4 MKR1000 Rev , 1, 4, 5, 6, 7, 8, 9, A1, A2 Due all digital pins IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id INGAT!!!!
11
Note Inside the attached function, delay() won't work and the value returned by millis() will not increment. Serial data received while in the function may be lost. You should declare as volatile any variables that you modify within the attached function. See the section on ISRs below for more information. Using Interrupts IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id Interrupts are useful for making things happen automatically in microcontroller programs, and can help solve timing problems. Good tasks for using an interrupt may include reading a rotary encoder, or monitoring user input. using an interrupt can free the microcontroller to get some other work done while not missing the input
12
ISR – Interrupt Service Routines (a fixed program)
IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id ISR – Interrupt Service Routines (a fixed program)
13
When writing an Interrupt Service Routine (ISR):
Keep it short (KISS!) Make variables shared with the main code volatile IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id Variables shared with main code may need to be protected by "critical sections" Don't use delay () Don't do serial prints Don't try to turn interrupts off or on
14
Contoh IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id
15
Use your mind Sensor Perangkat untuk mengindera (sense)
TASK : Eksplorasi dalam 30 menit a. PIR b. Ultrasonic c. Flame d. Gas IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id Use your mind
16
Referensi Ying Bai : Practical Microcontroller Engineering with ARM Technology : 2016 Chapter 5 page 261 IT863 by MTM - IF UNPAS 2016 tirta.mulia[at]unpas.ac.id
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.