Interrupt. incoming Lab. Interrupt an asynchronous signal indicating the need for attention hardware interrupt/software interrupt call “interrupt service.

Slides:



Advertisements
Similar presentations
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
Advertisements

Chung-Ta King National Tsing Hua University
Interrupts Disclaimer: All diagrams and figures in this presentation are scanned from the book “Microprocessors and Programmed Logic” authored by Kenneth.
68HC11 Polling and Interrupts
Mark Neil - Microprocessor Course 1 Timers and Interrupts.
Chapter 11 Multiple interrupts CEG Microcomputer Systems CEG2400 Ch11 Multiple Interrupts V4c
Intro to AVR ATtiny2313 CS423 Dick Steflik. AVR ATtiny2313.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
Communication Lab - Interrupts 1/13 Sequential Programming  Our C++ programs are sequential ( סדרתיים), they start at the first instruction and end at.
Butterfly I/O Ports CS-212 Dick Steflik. I/O for our labs To get data into and out of our Butterfly its a little trickier than using printf and scanf.
AVR Programming CS-212 Dick Steflik. ATmega328P I/O for our labs To get data into and out of our Arduino its a little trickier than using printf and.
Chapter 6 Interrupts (I. Scott Mackenzie).
External & internal Interrupts. Interrupt Sources There are 21 different interrupts and each one has its own vector located in a predefined location at.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
AVR CPU Core & 8 bit AVR Instruction Set
인터럽트의 개요 Interrupt의 처리 과정
1 Lab 1: Introduction. 2 Configure ATMEL AVR Starter Kit 500 (STK500), a prototyping/development board for Lab1. ATmega16 ( V) is the chip used.
Robotics Research Laboratory Louisiana State University.
Interrupt.
Microprocessors 1 MCS-51 Interrupts.
Lecture 8 Interrupts. 2  Introduction  Interrupt organization  Interrupt summary  Enabling and disabling interrupts  Interrupt priority  Interrupt.
Counter/Timer/PWM. incoming Lab. Counter counter is a device which stores the number of times a particular event or process has occurred synchronous/asynchronous.
Robotics Research Laboratory Louisiana State University.
AVR Programming: Interrupts September 17, What are interrupts? An asynchronous signal indicating the need for an event to be handled A synchronous.
CHAPTER 6 INTERRUPTS AND THE 8259 CHIP. What happens on interrupt? Micro automatically saves (on stack) the FR (flag register), IP (instruction pointer),
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.
Application of Interrupt and Timer : Measurement of Motor Speed.
ECE 447 Fall 2009 Lecture 7: MSP430 Polling and Interrupts.
Timers and Interrupts Mark Neil - Microprocessor Course.
Application of Interrupt and Timer : Motor Position Control.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
Mark Neil - Microprocessor Course 1 Timers and Interrupts.
kashanu.ac.ir Microprocessors Interrupts Lec note 8.
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
The 8051 Microcontroller Chapter 6 INTERRUPTS. 2/29 Interrupt is the occurrence of a condition an event that causes a temporary suspension of a program.
Chap.6.3 UART.
GUIDED BY PROFFESOR NILESH DESAI GROUP NO:-8 CHANDRASHIKHA SINGH( ) KURUP SHUBHAM VALSALAN( ) SAURAV SHUBHAM( )
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
INSTITUTE: INSTITUTE:PARUL INSTITUTE OF TECHNOLOGY BRANCH : BRANCH :B.E. E.C.5 TH SEM. SUBJECT:MICROCONTROLLER & INTERFACING TOPIC:AVR INTTRUPT TOPIC:AVR.
Chapter 11 INTERRUPTS PROGRAMMING
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
The process starts from the I/O device
Computer Architecture
Interrupts In 8085 and 8086.
Unit - 1 Interrupts M.Brindha AP/EIE
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
8085 Interrupts.
Interrupt.
Chapter 11 Multiple interrupts
ATmega103 Timer0 and Interrupts
* * * * * * * 8051 Interrupts Programming.
Lecture 8 Interrupts.
Interrupts Interrupt is a process where an external device can get the attention of the microprocessor. The process starts from the I/O device The process.
Interrupt Source: under
Interrupts.
Interrupt.
Interrupts 1/18/2019.
Interrupt Source: under
Interrupt Chapter 10.
PIC18 Interrupt Programming
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

Interrupt

incoming Lab. Interrupt an asynchronous signal indicating the need for attention hardware interrupt/software interrupt call “interrupt service routine”(interrupt handler, interrupt routine) interrupt source/interrupt vector/interrupt priority

incoming Lab. 생활 속에 인터럽트 영화 감상 문자 영화 정지 답신 재생 중요 스팸 …5678… 시간 Gom playercell phone interrupt

incoming Lab. program with or without interrupt b = *ADC0; c = *ADC1; a = b+c; i=0; while(i<10){ a += b; i++; } b = *ADC0; c = *ADC1; a = b+c; i=0; while(i<10){ a += b; i++; } without interrupt with interrupt if ( a>10 ) a = c; else a = b; interrupt service routine(ISR)

incoming Lab. interrupt is an asynchronous event b = *ADC0; c = *ADC1; a = b+c; i=0; while(i<10){ a += b; i++; } if ( a>10 ) a = c; else a = b; b = *ADC0; c = *ADC1; a = b+c; i=0; while(i<10){ a += b; i++; } if ( a>10 ) a = c; else a = b; ISR

incoming Lab. c.f.) function in program b = *ADC0; c = *ADC1; a = b+c; func(); i = 0; while(i<10){ a += b; i++; } b = *ADC0; c = *ADC1; a = b+c; i=0 while(i<10){ a += b; i++; } void func(){ if ( a>10 ) a = c; else a = b; }

incoming Lab. ATmega128 interrupt Source (I) 35 개

incoming Lab. ATmega128 interrupt Source (II)

incoming Lab. Interrupt 처리 과정 Interrupt request from an interrupt source 예 ) INT0 Signal If masked, ignore the interrupt. Program counter(PC) is saved. PC is changed to the program address according to the interrupt source 예 ) PC <= 0x0002 Jump to the Interrupt Service Routine (ISR) 예 ) jmp EXT_INT0 (PC <= EXT_INT0) After the end of ISR, PC is restored.

incoming Lab. Interrupt Vector Table memory address of an interrupt service routine

incoming Lab. External Interrupt : INT0~INT7 INT0~INT3 : PD0~PD3 (Port D) INT4~INT7 : PE4~PE7 (Port E)

incoming Lab. Global Interrupt Enable SREG(Status Register) I (7 bit) : Global Interrupt Enable 전체 인터럽트를 허용하도록 설정하는 비트 ‘1’ : interrupt enable ‘0’ : interrupt disable SEI : ‘1’ 로 변경 (interrupt enable) CLI : ‘0’ 으로 변경 (interrupt disable)

incoming Lab. EIMSK register External Interrupt MaSK register External Interrupt (INT0~INT7) 의 허용 여부를 제어 ‘1’ : enable ‘0’: disable 예 ) EIMSK = 0xA4; address : 0x59

incoming Lab. External Interrupt Control Register (EICRA, EICRB) Interrupt Trigger Level trigger  low level : ‘0’ 상태이면 interrupt trigger  high level : ‘1’ 상태이면 interrupt trigger Edge trigger  rising edge : ‘0’ -> ‘1’ 이면 interrupt trigger  falling edge : ‘1’ -> ‘0’ 이면 interrupt trigger EICRA, EIRCB 0x5A 0x6A

incoming Lab. EICRA, EICRB

incoming Lab. 예 ) Enable Interrupt INT0, rising edge DDRD &= 0xFE; /* PD0 : interrupt source, input */ EICRA = 0x03; EIMSK = 0x01; sei(); /* global interrupt enable */  SEI instruction 의 C code, mnemonic code  cli(); /* global interrupt disable */ INT7, falling edge; DDRE &= 0xEF; /* PE7 : interrupt source, input */ EICRB = 0x80; EIMSK = 0x80; sei(); /* global interrupt enable */

incoming Lab. Interrupt Service Routine ISR(vector, attributes) Format of WinAVR  C:\WinAVR \doc\avr-libc\avr-libc-user- manual.pdf 의 p.233 ~ vector : interrupt source  p.237 의 표 참조  예 ) INT0_vect : external interrupt 0 (PD0) attributes : interrupt 속성, 생략 가능 예 ) ISR(INT0_vect) { … } /* external interrupt 0 (PD0) 가 발생할 때 ISR */

incoming Lab. Interrupt Vector Table Initialize WinAVR : ISR(vector, attributes) ISR 의 시작 번지가 자동으로 해당 vector table 에 저장 in general ( 예 ) unsigned int *ivt; ivt = (unsigned int *)0x0002; *ivt = int_service_routine;  /* C program 에서는 함수의 이름이 주소를 나타냄 */ … void int_service_routine(){ /* interrupt service routine */ … }

incoming Lab. Interrupt Priority & EIFR 인터럽트의 우선 순위 두 개 이상의 인터럽트가 동시에 발생될 경우 하위 주소의 인터럽트가 상위 주소의 인터럽트 보다 우선 순위가 높다 예 ) INT0 > INT1 > … > USART0 > … interrupt flag register (EIFR) External Interrupt (INT0~INT7) 의 발생 여부를 나타냄

incoming Lab. Interrupt 실습 #include int main(){ DDRD = 0x18; EICRA = 0x02; /* falling edge */ EIMSK = 0x01; /* left S/W interrupt enable */ sei(); /* SEI instruction 의 C code, mnemonic code */ while(1); return 0; }

incoming Lab. falling edge or rising edge

incoming Lab. Interrupt Service Routine ISP(INT0_vect) { PORTD |= 0x10; }

incoming Lab. In flash program memory 0x0000 : jmp 0x0054 0x0002 : jmp 0x00a0 … 0x0054 : …. … 0x00a0 : …. …. …. : reti Reset or Restart INT0 (left S/W) main program interrupt service routine

incoming Lab. Interrupt 실습 : LED 다시 켜기, while 문만 변경 #include int main(){ … sei(); while(1) { if( (PIND & 0x01) == 1 ) PORTD &= 0xEF; } return 0; }

incoming Lab. Interrupt 실습 : INT1 (RIGHT) #include int main(){ DDRD = ________; EICRA = ________; EIMSK =________; sei(); while(1); return 0; }

incoming Lab. Interrupt Service Routine ISR(INT1_vect) { PORTD |= 0x10; }

incoming Lab. 실습 : INT0, INT1 모두 사용 #include int main(){ DDRD = ________; EICRA = ________; EIMSK =________; sei(); while(1); return 0; }

incoming Lab. 실습 : INT0, INT1 모두 사용 ISP(INT0_vect) /* Left S/W => LED Off */ { PORTD |= 0x10; } ISR(INT1_vect) /* Right S/W => LED On */ { PORTD &= 0xEF; }

incoming Lab. main switch problem : wait-polling int main() { … while (1) { cmd = rxd_char(); if( main S/W is left) { Motor Off; } else { switch(cmd){ case … unsigned char rxd_char() { unsigned char data; while( (UCSR0A & 0x80) == 0) ; data = UDR0 ; return data ; }

incoming Lab. one possible solution : still polling int main() { … while (1) { if( (UCSR0A & 0x80) != 0 ) cmd = UDR0 ; if( main S/W is left) { Motor Off; } else { switch(cmd){ case …

incoming Lab. solution with interrupt (I) int main() { … while (1) { cmd = rxd_char(); if( main S/W is left) { Motor Disable; } else { switch(cmd){ case … ISR(INT0_vect) { Motor Disable; } main S/W interrupt

incoming Lab. solution with interrupt (II) int main() { … while (1) { cmd = rxd_char(); if( … ) { Left Motor Disable; } else if (… ) { RightMotor Disable; } else { switch(cmd){ case … ISR(INT0_vect) { Left Motor Disable; } left S/W interrupt ISR(INT1_vect) { Right Motor Disable; } right S/W interrupt

incoming Lab. USART Interrupt USART0 사용 USCR0B Register RXCIE0 (7 bit) = ‘1’; USCR0B : ’18’ -> ’98’

incoming Lab. USART0 Interrupt Service Routine ISR(USART0_RX_vect) { Cmd_U0 = UDR0; /* Cmd_U0 : global 변수 */ } … unsigned char Cmd_U0; /* global 변수 선언 위치 */ int main() { …

incoming Lab. 변수의 허용 범위 block : {} 내의 선언문 및 실행문 block 내에서 선언된 변수는 block 내에서 만 유효 Example) int a = 2; printf(“%d\n”,a); { int a = 3; printf(“%d\n”,a); } printf(“%d\n”,a);

incoming Lab. USART0 interrupt program #include unsigned char Cmd_U0; int main(){ /* 초기화 code, Port I/O, USART0, Interrupt Enable */ while(1){ switch(Cmd_U0) { case : … } return 0; }

incoming Lab. USART0 interrupt 실습 ‘n’ : LED on, ‘f’ : LED off switch(Cmd_U0){ case ‘n’ : PORTD &= 0xEF; break; case ‘f’ : PORTD |= 0x10; break; default : }

incoming Lab. 실습 과제 모든 input 은 interrupt 로 처리 Left S/W 를 이용하여 left motor enable/disable ‘0’ : Disable ‘1’ : Enable Right S/W 를 이용하여 right motor enable/disable ‘0’ : Disable ‘1’ : Enable UART 통신을 이용하여 Motor 제어 Key map 정의  예 ) R : right forward, r : right backward