Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR

Size: px
Start display at page:

Download "Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR"

Transcription

1 Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR

2 Objectives To become familiar with interrupts on the AVR Maskable and non-maskable Initialization Triggers To develop interrupt service routines (ISRs) to handle interrupts To understand the sequence of events that occur when an IRQ occurs

3 Interrupts Interrupts are asynchronous changes in program flow that occur as a result of events outside the running program. They are usually hardware related:examples: button press, timer expiration, peripheral device needs data, etc Interrupt conditions are independent of the program. Interrupts can happen at any time (asynchronous)

4 Maskable/Non-maskable Interrupts in general can be divided into two kindsmaskable and non-maskable. A maskable interrupt is an interrupt whose trigger event is not always important: The program can decide if the event should be recognized or ignored and can be disabled/enabled A non-maskable interrupt is so important that it should never be ignored The processor will always jump to this interrupt when it happens The reset button is an example.

5 Interrupts on the ATmega32 External interrupt inputs are pins INT2 -INT0 They are triggered by: A high-to-low transition (a falling edge) on one of these pins A low-to-high transition (a rising edge) on one of these pins A low level on one of these pins They are initialized by: MCUCSR Register for INT2:0.

6 AVR Operating Mode o Normal AVR perform main routine continuously. o Interrupt AVR perform special routine upon receiving input request (asynchronous). AVR receives input request from internal or external. Each interrupt has its own routine referred as interrupt service routine (in short ISR). AVR Atmega32 has allocated three inputs for external interrupts and many for internal interrupts. The interrupts are prioritized and vectored. Each interrupt has its vector number and orderly locates interrupt priority.

7 Interrupt versus Polling o AVR responded method to inputs: Interrupt o An asychronous event to make AVR deviating to a special program from the main program. The AVR run the special program after it is being triggered by an input. o Upon receiving the input signal, AVR stops its current main program, deviate to the special program, finish and back running the main program. o Special program that belongs to interrupt event is called an interrupt service routine (ISR) or aninterrupt handler. Polling o The AVR always inspects all input request routinely; when the status is received, AVR branches to the assigned program.

8 Interrupt vs Polling Efficient use of CPU Interrupts Can serve many devices, which each device get attention of the CPU based on the priority assigned to it. The CPU can ignore (mask) a device request for service. Avoid tying down the CPU, thus the waste time can be used to perform some useful tasks. Polling Not and efficient use of CPU Cannot assign priority, it checks all devices in a round-robin fashion. Cannot ignore device request. Wastes much CPU time by polling device that do not need service.

9 Interrupt Vector Table (AVR Atmega32 Interrupt List) 9

10 Interrupt Vector Table for ATmega32 (ATmega32A) 10

11 Interrupt Service Routine o For every interrupt, there must be ISR, since when an interrupt is invoked, AVR runs the ISR. o Generally, for every ISR there is a fixed location in memory that holds the address of its ISR. o The group of memory locations set aside to hold the addresses of ISRs s called interrupt vector table. o Vector interrupt is used to bridge between the triggering interrupt input and the interrupt s assigned (software) task. o All interrupts involved are vectorily initialized at the beginning of the AVR main program to provide link to its own interrupt service routine. ISR hasits own AVR task. ISR is located after the AVR main program and each ISR contains RETI as its last line.

12 Steps in executing an interrupt o Upon activation of an interrupt, the AVR goes through the following steps: 1. It finishes the instruction it s currently executing and saves the address of the next instruction (PC) on the stack. 2. Jumps to a fixed location in memory called the interrupt vector table. The interrupt vector table directs the AVR to the address of ISR. 3. AVR starts execute the ISR until reaches the last instruction of the subroutine, RETI. 4. Upon executing RETI, AVR returns to the place where it was interrupted gets the PC address from the stack.

13 Steps in executing an interrupt PB0 PB1 (INT2) PB2 (OC0/AIN0) PB3 (SS) PB4 (MOSI) PB5 (MISO) PB6 (SCK) PB7 RESET VCC GND XTAL2 XTAL1 (RXD) PD0 (TXD) PD1 (INT0) PD2 (INT1) PD3 (OC1B) PD4 (OC1A) PD5 (ICP) PD ATmega32 PC: 000D 000E 000A F 000C 000B SP Stack VCC PA0 (ADC0) PA1 (ADC1) PA2 (ADC2) PA3 (ADC3) PA4 (ADC4) PA5 (ADC5) PA6 (ADC6) PA7 (ADC7) AGND AVCC PC7 (TOSC2) PC6 (TOSC1) PC5 (TDI) PC4 (TDO) PC3 (TMS) PC2 (TCK) PC1 (SDA) PC0 (SCL) PD7 (OC2) Address A 000B 000C 000D 000E 000F Code #INCLUDE <avr/interrupt.h> void isr(into.vect) unsigned char int0data ; int0data=portc^0x08; PORTC = int0data; } int main () { DDRC = 1 << PC3 ; //PC.3 = output PORTD=1 << PD2 ;//pull-up activated GICR= 1<<INT0 ;//Enable INT0 SEI() ;//Set I (Enable Interrupts) num1= 3 ; num2 = 4 ; sum = num1 + num2 ; while (1); return 1; }

14 Interrupt Units in AVR

15 Enabling and Disabling An Interrupt o Upon reset, all interrupts are disabled (masked) none will be responded to by AVR if they are activated. o The interrupt must be enabled (unmasked) for AVR to respond to them. o How? The D7 bit of SREG responsible to enable and disable the interrupt globally. o Bit D7 (I) of SREG must be set HIGH to allow interrupt to happen by using SEI instruction, I = 1. To disable use CLI instruction, I = 0. o But there are some I/O registers holding interrupt enable bits even though I = 1, i.e. TIMSK register has interrupt enable bit for Timer0, Timer1 and Timer2.

16 Enabling and Disabling An Interrupt

17 External Interrupt Programming

18 Programming External Interrupt o There are three external hardware interrupt: o INT0 located on pin PD2, vector table location $2 o INT1 located on pin PD3, vector table location $4 o INT3 located on pin PB2, vector table location $6 o The hardware interrupts must be enabled before they can take effect. o This is done using INTx bit located in the GICR register.

19 Programming External Interrupt o Example: the following instruction enable INT0. GICR = 0x40 ; // Enable external interrupt INT0 (PD2 pin 16) o The INT0 is a low-level-triggered interrupt by default when a low signal is applied to pin PD2, the controller will be interrupted and jump to location $0002 in the vector table to service ISR.

20 o Example: Assume that the INT0 pin is connected to a switch that is normally high. Write a program that toggles PORTC.3, whenever the INT0 pin goes low. #include <avr/io.h> #include <avr/interrupt.h> void ISR(INT0_vect) { portc = ~portc ; //toggle PC3 } void initint(void ) { ddrd = ddrd ~ (1 << int0) ; // portd2 as input portd = portd 1 << int0 ; // pull-up portd2 gicr = 1 << int0 ; // enable int0 mcucr = 0b ;// low level input trigger sei () ; // enable global interrupt } int main (void) { ddrc = ddrc 1 << portc3 ; // portc3 as output portc = portc 1 << portc3 ; // initial PC3 high initint(); while (1) { // loop forever wait for INT0 interrupt What } happen by time micro-p execute RETI and return INT0 still 1 ; LOW? } Programming External Interrupt

21 Programming External Interrupt o Example: Assume that the INT0 pin is connected to a switch that is normally high. Write a program that toggles PORTC.3, whenever the INT0 pin goes low. What happen by time micro-p execute RETI and INT0 still LOW?

22 Programming External Interrupt: Edge vs Level Triggered o There are two types of activation for the external hardware interrupts: o Level triggered INT0 & INT1 o Edge triggered INT0, INT1 & INT2. o The ISC2 bit of the MCUCSR register indicate whether INT2 is active in the falling edge or rising edge.

23 Programming External Interrupt: Edge vs Level Triggered o The bits for the MCUCR register indicate the trigger option of INT0 and INT1.

24 Programming External Interrupt: Edge vs Level Triggered o Example: show the instruction (a) make INT0 falling edge triggered, (b) make INT1 triggered on any change, and (c) make INT2 rising edge triggered. a) MCUCR = 0X02 b) MCUCR = (1<<ISC10) ; //MCUCR = 0x04 c) MCUCR =(1<<ISC2) ; // MCUCR = 0x40

25 Programming External Interrupt: Edge vs Level Triggered o Example: Rewrite previous switch example, so that whenever INT0 goes low, it toggles PORTC.3 only once.

26 Example Assembly codes that initialised External Interrupt INT0 and INT1 only //Iniltialise STACK //Enable INT0 and INT1 ddrd = ddrd ~ (1<< Int0) ; //set INT0 pin as input portd = portd 1<< int0 ; //enable pull-up resistor on INT0 pin ddrd = ddrd ~ (1 << int1) ; //set INT1 pin as input portd = portd 1<<int1 ; //enable pull-up resistor on INT1 pin gicr = 0b ; //enable INT0 and INT1 // Set INT0 and INT1 to detect falling edge MCUCR = 0b ; // mcucr = 0x0A //Enable Global Interrupt sei() ; 26

27 Example C/C++ codes that initialised External Interrupt INT0 and INT1 only /*The codes to Initialise Stack by default will be generated by the C/C++ compiler. The following statements will only set DDRD2, PD2, INT0 and ISC01, and Clear ISC00. Other bits in respective registers are untouched so setting of other interrupts are not changed. DDRD=DDRD (~(1<<PD2)); // PortD2 as input PORTD=PORTD (~(1<<PD2)); // Pull-up PortD2 GICR=GICR 1<<INT0 ; // enable INT0 MCUCR = MCUCR 1<<ISC01; // INT0 input falling edge MCUCR = MCUCR&((1<<ISC00)^0xff); /*The following statements will only set DDRD3, PD3, INT1, ISC01 and ISC00. Other bits in respective registers are untouched so setting of other interrupts are not changed.*/ DDRD=DDRD ((1<<PD3)^0xff); //Using Ex-or to NOT (1<<PD3) PORTD=PORTD ((1<<PD3)^0xff); GICR=GICR 1<<INT1; MCUCR = MCUCR 1<<ISC11 1<<ISC10; 27

28 Timer Interrupt Programming

29 Programming Timer Interrupt o There are at two timer interrupts: o Overflow / Rollover timer flag o Compare match timer flag o Basically, in ATmega32 there are three timers: Timer0, Timer1, Timer2. o Timer0 and Timer2 are 8-bit, while Timer1 is 16-bit. (will cover more details on how to program timers on the next module)

30 Programming Timer Interrupt: Rollover Timer Flag o If the timer interrupt in the interrupt register is enabled, the timer over flow flag (TOVx) is raised whenever the timer rolls over and the micro-p jumps to the interrupt vector to service the ISR. o To enable the interrupt for a given timer, we must set the TOIEx bit that held by TIMSK register. o To enable (unmask) the Timer interrupt let says Timer0, we should write as follows: TIMSK = 1 << TOV0 S() ; // enable Timer 0 overflow interrupt ; // enable interrupt globally

31 Programming Timer Interrupt: Rollover Timer Flag o Example: Write a program to (a) enable (unmask) the Timer0 overflow interrupt, (b) disable (mask) the Timer0 overflow interrupt, and show how to disable (mask) all the interrupts with a single instruction. a) TIMSK = (1<<TOIE0) ; //set TOE0=1 SEI() ;//allow interrupt to come in b) TMASK = TIMSK ; // Read TIMSK TIMSK=(1<<TOIE0) ;//clear TOIE0=0 ->mask (disable) Timer0 //interrupt c) CLI () ;//mask all interrupt globally

32 Programming Timer Interrupt: Compare Match Timer Flag o Sometimes a task should be done periodically. o The program can be written using the CTC mode and compare match (OCF) flag. o To do so, load the OCR register with the proper value and initialize the number to the CTC mode. o When the content of TNCT matches with OCR, the OCF flag is set. Which cause the compare interrupt to occur. (See next module for detail)

33 Programming Timer Interrupt: Compare Match Timer Flag o Example: Using Timer0, write a program that toggles pin PORTB.5 every 40μs, while at the same time transferring data from PORTC to PORTD. Assume XTAL = 1MHz.

34 Interrupt Priority & Interrupt inside Interrupt

35 Interrupt Priority o What will happen when two interrupts are activated at same time? Which one will responds first? o Answer: Interrupt Priority! o If two interrupts are activated at the same time, the interrupt with the higher priority is served first. o The priority of interrupt is related to the address of that interrupt in the interrupt vector. o Example: Address of INT0 = $2 and INT2 = $6. thus INT0 has higher priority.

36 Interrupt inside Interrupt o What happen if AVR is executing an ISR belonging to an interrupt and another interrupt is activated? o Answer: When AVR begins to execute an ISR, it disables the I bit in SREG causing all the interrupts to be disabled, thus no other interrupt occurs while serving the interrupt. When RETI is executed, AVR enables I bit in SREG, causing the other interrupts to be served.

37 Context Saving in Task Switching o In multitasking system, the CPU serve one task at a time and then moves to the next one. For example: (1) Copying the contents of PORTC to PORTD (2) Toggling PORTC.2 every 5μs o To write a program of multitasking system, we should manage resource carefully so that its not conflict with each other.

38 o Example: thy system performs (1) increasing contents of PORTC continuously and (2) increasing content of PORTD once every 5μs. Context Saving in Task Switching o DOES THE PROGRAM WORKS? o Not working: they have resource conflict and they interfere with each other!!!

39 Context Saving in Task Switching o How to overcome such situation? 1) Using different registers for different tasks. 2) Context saving we can save the contents of registers on the stack before execution of each task, and reload the registers at the end of the task.

40 Saving Flag of SREG Register o The flags of SREG are important especially when there are conditional jumps in our program. o Thus, we should save the SREG register if the flags are changed in a task, especially those who involves with ISR.

41 Interrupt Programming In C : Refers AVR ebook for details. (Section 10.5, pg:385)

42 Atmel Studio C/C++ Interrupt Service Routine Keywords for the ATmega32/ATmega32A Vector Address Source ATmel Studio C/C++ No. Name Event Keywords 1 $000 Reset No needed since it is Changes from High by default assigned to Low at On Chip s by C/C++ compiler RESET Pin referencing to main() function 2 $002 INT0 Status at On Chip s INT0_vect INT0 Pin as defined by ISC01:ISC00 bits of the MCUCR register 3 $004 INT1 Status at On Chip s INT1_vect INT1 Pin as defined by ISC11:ISC10 bits of the MCUCR register Interrupt Definition External Pin, Power - on Reset, Brown -out Reset, Watchdog Reset, and JTAG AVR Reset External Interrupt Request 0 External Interrupt Request 1 45

43 Atmel Studio C/C++ Interrupt Service Routine Keywords for the ATmega32/ATmega32A Vector Address Source ATmel Studio No. Name Event C/C++ Keywords 4 $006 INT2 Status at on INT2_vect Chip s INT1 Pin as defined by ISC2 bit of the MCUCSR register 5 $008 TIMER1 OCF1A bit of TIMER1_COMPA_ve COMPA TIFR register is ct set 6 $00A TIMER2 OVF OCF2 bit of TIFR register is set 7 $00C TIMER1 CAPT ICF1 bit of TIFR register is set 8 $00E TIMER2 COMP OCF2 bit of TIFR register is set Interrupt Definition External Interrupt Request 2 Timer/Counter 1 Compare Match A TIMER2_OVF_vect Timer/Counter 2 Overflow TIMER1_CAPT_vect Timer/Counter 1 Capture Event TIMER2_COMP_vect Timer/Counter 2 Compare Match 46

44 Atmel Studio C/C++ Interrupt Service Routine Keywords for the ATmega32/ATmega32A Vector Address Source ATmel Studio C/C++ No. Name Event Keywords 9 $010 TIMER1 OCF1B bit of TIMER1_COMPB_vect COMPB TIFR register is set 10 $012 TIMER1 OVF T0V1 bit of TIMER1_OVF_vect TIFR register is set 11 $014 TIMER0 COMP OCF0 bit of TIMER0_COMP_vect TIFR register is set 12 $016 TIMER0 OVF T0V0 bit of TIMER0_OVF_vect TIFR register is set 13 $018 SPI, STC SPIF bit of SPSR SPI_STC_vect Register is set 14 $01A USART, RXC RXCIE of UCSRB bit is set USART_RXC_vect Interrupt Definition Timer/Counter 1 Compare Match B TIMER1 OVF Timer/Counter 1 Overflow Timer/Counter 0 Compare Match Timer/Counter 0 Overflow Serial Transfer Complete USART Rx Complete 47

45 Atmel Studio C/C++ Interrupt Service Routine Keywords for the ATmega32/ATmega32A Vector Address Source ATmel Studio Interrupt No. Name Event C/C++ Keywords Definition 15 $01C USART, UDRE UDRIE bit of UCSRB register is set USART_UDRE_vect USART Data Register Empty 16 $01E USART, TXC TXC bit of UCSRB register is set USART_TXC_vect USART, Tx Complete 17 $020 ADC ADC_vect ADC ACIE bit is ACSR Conversion register is set Complete 18 $022 EE_ RDY EEWE bit EECR register is cleared EE_RDY_vect EEPROM Ready 19 $024 ANA_COMP ACI bit is ACSR register is set 20 $026 TWI activated for as long as the TWINT Flag of TWCR is high 21 $028 SPM_ RDY executed as long as the SPMEN bit in the SPMCR Register is cleared. ANA_COMP_vect TWI_vect SPM_RDY_vect Analog Comparator Two -wire Serial Interface Store Program Memory Ready 48

46 Interrupt Vector Table Location of information to tell CPU where to find the service routine of the respective interrupt. When source of Interrupt is generated (after it has been enabled and Global Interrupt Enabled bit is set), PC (program Counter) will be initialised with value Vector Address defined under the Program Address column of the interrupt generated. The event of interrupt is given under the Interrupt Definition column. If RESET occur, PC will be initialised with $0000 (though the number is 3 hex digit under Program Address, a 4 hex digit number will be stored to PC because PC is a 16 bit register). If INT2 interrupt occurs, PC will be initialised with $0006. Except RESET that does not have a current instruction that it is executing, when an interrupt occur, the CPU will complete the current instruction that it is executing and save the address of PC (next instruction to be executed) to the STACK before PC is initialised with interrupt vector Address. 49

47 C Language Example in Setting Up INT0, INT1 and INT2 ISR //Interrupt Service Routine for trigger on Pin INT0 ISR(INT0_vect) { // Codes here; } //Interrupt Service Routine for trigger on Pin INT1 ISR(INT1_vect) { // Codes here; } //Interrupt Service Routine for trigger on Pin INT2 ISR(INT2_vect) { // Codes here; } In C language programming, when the Interrupt Service Routine Keywords is used as the name of the function, the RETI instruction will be inserted by default by the Atmel Studio C/C++ (GCC) compiler. 50

48 Interrupt Flags and Interrupt Enabled bits The interrupt flag bit is set whenever the interrupt event occurs, whether or not the interrupt is enabled. The interrupt enabled bit is used to enable or disable a specific interrupt. Basically is tells the microcontroller whether or not it should respond to the interrupt if it is triggered. 51

49 Global Interrupt Enabled Bit Tell CPU to service all interrupts are enabled Apart from the enabled bits for the specific interrupts the global interrupt enabled bit MUST be enabled for interrupts to be activated in the microcontroller. For the AVR 8-bits microcontroller this bit is located in the Status I/O Register (SREG). The Global Interrupt Enabled is bit 7, the I bit, in the SREG. In assembly language the SEI instruction set the I bit and the CLI instruction clear the bit. In C/C++ language the sei() function set the I bit and the cli() function clears the bit. The functions are declared in AVR/interrupt.h which must be included in the C program. 52

50 Interrupt Request sources provided with the AVR microcontroller The AVR 8-bits microcontroller provides both internal and external interrupt sources. The internal interrupts are associated with the microcontroller's peripherals which are the Timer/Counter, Analog Comparator, etc. The external interrupts are triggered via external pins. When an Interrupt is triggered, the CPU will execute its service routine whose starting address is defined in the Interrupt vector table. On ATmega32/ATmega32A microcontroller there are four (4) external interrupts: The RESET interrupt - Triggered from pin 9 (executed like an interrupt but does not operate as an interrupt because RETI instruction cannot be used in RESET Interrupt service routine. External Interrupt 0 (INT0) - Triggered from pin 16. External Interrupt 1 (INT1) - Triggered from pin 17. External Interrupt 2 (INT2) - Triggered from pin 3. 53

51 Location of External Interrupt pins in ATmega32/ATmega32A 54

52 Writing Assembly Codes Utilizing the Interrupt Feature The Global Interrupt bit in the General Interrupt Control Register (GICR), the I bit, in the microcontroller's status register (SREG) MUST also be enabled by using the SEI instruction. The stack MUST be initialized (Normally at the beginning of the Main Program). When an interrupt is being service the microcontroller needs to store critical information on the stack. The Triggering Condition (in MCUCR for INT0 and INT1 and in MCUSCR for INT2) must be specifically set to suit hardware wiring configuration of the interrupt pin. Enable internal pull-up resistor if external pull-up resistor is not wired for active low interrupt input. The Interrupt Service Routine (ISR) MUST end with the RETI instruction, which indicates the end of the ISR. The microcontroller needs to know when it reaches the end of the ISR so it can return to its previous task. RETI will also set I bit is so that Global interrupt is enabled because I bit is cleared when CPU service any interrupt. 55

53 Writing C Codes Utilizing the Interrupt Feature The Global Interrupt bit, the I bit, in the microcontroller's status register (SREG) MUST also be enabled by using the sei() function. The stack NEED NOT be initialized (C compiler initialised stack by default). NEED NOT store critical information on the stack when an interrupt is being service the microcontroller needs to (C compiler does this by default). The Triggering Condition (in MCUCR for INT0 and INT1 and in MCUSCR for INT2) must be specifically set to suit hardware wiring configuration of the interrupt pin. Switch ON internal pull-up resistor if external pull-up resistor is not wired for active low interrupt input. NEED NOT end The Interrupt Service Routine (ISR) the RETI instruction (C compiler does this by default). 56

54 The ATMEga32/ATMEga32A External Interrupts Pins The INT2, INT1 and INT3 can be programmed to generate external interrupt for the ATmega32 The interrupts can detect four different types of pin changes: 1. pin goes low 2. any logical change in pin 3. falling edge (pin goes from high to low) 4. rising edge (pin goes from low to high) these interrupts are controlled by the following registers. 1. GICR 2. MCUCR (INT1 and INT2) 3. MCUCSR (INT2 only) 57

55 GICR To enable INTn we need to set the INTn bit of the GICR register. 58

56 MCUCR and MCUCSR To set detection (interrupt sense control) of pin changes we need to set the MCUCR (for INT1 and INT0) or MCUCSR (for INT1) ICS2 Description 0 A falling edge on INT2 activates the interrupt 1 A rising edge on INT2 activates the interrupt 59

57 General Interrupt Flag Register (GIFR) INTF1: When 1 on this bit trigger INT1 Interrupt when INT1 bit of GICR and I bit of SREG is one. INTF0: When 1 on this bit trigger INT0 Interrupt when INT0 bit of GICR and I bit of SREG is one. INTF2: When 1 on this bit trigger INT2 Interrupt when INT2 bit of GICR and I bit of SREG is one. 60

58 Example C/C++ codes that initialised External Interrupt INT0 and INT1 only /*The codes to Initialise Stack by default will be generated by the C/C++ compiler. The following statements will only set DDRD2, PD2, INT0 and ISC01, and Clear ISC00. Other bits in respective registers are untouched so setting of other interrupts are not changed. DDRD=DDRD (~(1<<PD2)); PORTD=PORTD (~(1<<PD2)); GICR=GICR 1<<INT0; MCUCR = MCUCR 1<<ISC01; MCUCR = MCUCR&((1<<ISC00)^0xff); /*The following statements will only set DDRD3, PD3, INT1, ISC01 and ISC00. Other bits in respective registers are untouched so setting of other interrupts are not changed.*/ DDRD=DDRD ((1<<PD3)^0xff); //Using Ex-or to NOT (1<<PD3) PORTD=PORTD ((1<<PD3)^0xff); GICR=GICR 1<<INT1; MCUCR = MCUCR 1<<ISC11 1<<ISC10; 61

59 #include <avr/io.h> #include <avr/interrupt.h> ISR(INT0_vect) { PORTB =~PORTB; } void initinterrupt(void) { cli(); GICR=0x40; MCUCR=0x03; sei(); } C Interrupt Sample int main(void) { initinterrupt(); DDRB=0xff; PORTB=0x55; while(1) { /*If interrupt INT0 is triggered, here PORTB will be complemented in background when INT0 is serviced*/ } } ISMAIL FKE UTM 2017 ISMAIL FKE UTM

School of Electrical, Computer and Telecommunications Engineering University of Wollongong Australia

School of Electrical, Computer and Telecommunications Engineering University of Wollongong Australia ECTE333 s schedule ECTE333 Lecture 9 -Timers School of Electrical, Computer and Telecommunications Engineering University of Wollongong Australia Week Lecture (2h) Tutorial (h) Lab (2h) L7: C programming

More information

ATmega Interrupts. Reading. The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi

ATmega Interrupts. Reading. The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi 1 P a g e ATmega Interrupts Reading The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 10: AVR Interrupt Programming in Assembly

More information

Atmel AVR Timers and Interrupts

Atmel AVR Timers and Interrupts 1 P a g e Atmel AVR Timers and Interrupts Reading The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 10: AVR Interrupt Programming

More information

INTERRUPT, TIMER/COUNTER. KONKUK UNIV. VLSI Design Lab. LSI Design Lab

INTERRUPT, TIMER/COUNTER. KONKUK UNIV. VLSI Design Lab. LSI Design Lab INTERRUPT, TIMER/COUNTER KONKUK UNIV. V. 1 INTERRUPT 의개요 외부의요구에의해서현재실행중인프로그램을일시중지하고보다시급한작업을먼저수행한후다시원래의프로그램으로복귀하는것. EX) 스타를하다가택배가오면스타를일시중지하고택배를받은후다시스타를진행함. Interrupt 방식 : 택배아저씨가초인종을눌러줌. Polling 방식 : 택배아저씨가오는지일정시간간격으로살펴봄.

More information

Programming Microcontroller Assembly and C

Programming Microcontroller Assembly and C Programming Microcontroller Assembly and C Course Number CLO : 2 Week : 5-7 : TTH2D3 CLO#2 Student have the knowledge to create basic programming for microcontroller [C3] Understand how to program in Assembly

More information

8-bit Microcontroller with 4K Bytes of In-System Programmable Flash AT90S4433 AT90LS4433. Features. Not Recommend for New Designs. Use ATmega8.

8-bit Microcontroller with 4K Bytes of In-System Programmable Flash AT90S4433 AT90LS4433. Features. Not Recommend for New Designs. Use ATmega8. Features High-performance and Low-power AVR 8-bit RISC Architecture 118 Powerful Instructions Most Single Cycle Execution 32 x 8 General Purpose Working Registers Up to 8 MIPS Throughput at 8 MHz Data

More information

AGH University of Science and Technology Cracow Department of Electronics

AGH University of Science and Technology Cracow Department of Electronics AGH University of Science and Technology Cracow Department of Electronics Microprocessors laboratory Tutorial 7 Interrupts Author: Paweł Russek http://www.fpga.agh.edu.pl/upt ver. 01/07/14 1/12 1. Introduction

More information

CHAPTER 11 INTERRUPTS PROGRAMMING

CHAPTER 11 INTERRUPTS PROGRAMMING CHAPTER 11 INTERRUPTS PROGRAMMING Interrupts vs. Polling An interrupt is an external or internal event that interrupts the microcontroller To inform it that a device needs its service A single microcontroller

More information

Topic 11: Timer ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR

Topic 11: Timer ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR Topic 11: Timer ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR Introduction Timer s objective Timer features Timer Registers - Understand function of each bit Initialization Introduction o In micro-p, we use counter

More information

INTERRUPTS in microprocessor systems

INTERRUPTS in microprocessor systems INTERRUPTS in microprocessor systems Microcontroller Power Supply clock fx (Central Proccesor Unit) CPU Reset Hardware Interrupts system IRQ Internal address bus Internal data bus Internal control bus

More information

8-bit Microcontroller with 1K Byte of In-System Programmable Flash AT90S1200

8-bit Microcontroller with 1K Byte of In-System Programmable Flash AT90S1200 Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 89 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General-purpose Working Registers Up to

More information

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2313

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2313 Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 118 Powerful Instructions Most Single Clock Cycle Execution 32x8GeneralPurposeWorkingRegisters Up to 10

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Interrupts Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA March 1, 2018 Aly El-Osery (NMT) EE 308: Microcontrollers

More information

COMP2121: Microprocessors and Interfacing

COMP2121: Microprocessors and Interfacing Lecture 19: Interrupts II http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 1, 2006 Overview AVR Interrupts Interrupt Vector Table System Reset Watchdog Timer Timer/Counter0 Interrupt Service

More information

8-bit Microcontroller with 4K/8K bytes In-System Programmable Flash AT90S4414 AT90S8515. Features. Pin Configurations

8-bit Microcontroller with 4K/8K bytes In-System Programmable Flash AT90S4414 AT90S8515. Features. Pin Configurations Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

AGH University of Science and Technology Cracow Department of Electronics

AGH University of Science and Technology Cracow Department of Electronics AGH University of Science and Technology Cracow Department of Electronics Microprocessors laboratory Tutorial 7 Interrupts Author: Paweł Russek http://www.fpga.agh.edu.pl/upt ver. 25/05/16 1/11 1. Introduction

More information

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text 1. Interrupt An interrupt is the occurrence of a condition--an event --

More information

University of Kashan Faculty of Electrical and Computer Engineering Department of Computer Engineering. Lecture note 2

University of Kashan Faculty of Electrical and Computer Engineering Department of Computer Engineering. Lecture note 2 University of Kashan Faculty of Electrical and Computer Engineering Department of Computer Engineering Lecture note 2 Memory and IO Interfacing to & An Introduction to AVR Microcontrollers Hossein Sabaghian-Bidgoli

More information

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT90S8515

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT90S8515 Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 118 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General-purpose Working Registers Up

More information

8-bit Microcontroller with 1K Byte Flash. ATtiny15L

8-bit Microcontroller with 1K Byte Flash. ATtiny15L Features High-performance, Low-power AVR 8-bit Microcontroller Advanced RISC Architecture 90 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

12.1. Unit 12. Exceptions & Interrupts

12.1. Unit 12. Exceptions & Interrupts 12.1 Unit 12 Exceptions & Interrupts 12.2 Disclaimer 1 This is just an introduction to the topic of interrupts. You are not meant to master these right now but just start to use them We will cover more

More information

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text In this lecture embedded C program for interrupt handling

More information

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash. ATtiny22 ATtiny22L. Preliminary. Features. Description

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash. ATtiny22 ATtiny22L. Preliminary. Features. Description Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

8-bit Microcontroller with 1K Bytes Flash. ATtiny10 ATtiny11 ATtiny12. Preliminary. Features. Pin Configuration

8-bit Microcontroller with 1K Bytes Flash. ATtiny10 ATtiny11 ATtiny12. Preliminary. Features. Pin Configuration Features Utilizes the AVR RISC Architecture High-performance and Low-power 8-bit RISC Architecture 90 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2323 AT90LS2323 AT90S2343 AT90S/LS2323. Features.

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2323 AT90LS2323 AT90S2343 AT90S/LS2323. Features. Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

Microprocessors & Interfacing

Microprocessors & Interfacing Lecture Overview Microprocessors & Interfacing Interrupts (I) Lecturer : Dr. Annie Guo Introduction to Interrupts Interrupt system specifications Multiple sources of interrupts Interrupt priorities Interrupts

More information

Interrupts & Interrupt Service Routines (ISRs)

Interrupts & Interrupt Service Routines (ISRs) ECE3411 Fall 2015 Lecture 2c. Interrupts & Interrupt Service Routines (ISRs) Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: vandijk,

More information

AVR Programming in C. Topic/Week 9 ISMAIL FKE UTM

AVR Programming in C. Topic/Week 9 ISMAIL FKE UTM AVR Programming in C Topic/Week 9 ISMAIL FKE UTM 2017 1 C Development using Atmel AVR Studio 6.0 Why using C? C is a high-level programming language: C code is easier to understand compared to other languages.

More information

8-bit Microcontroller with 8K Bytes Programmable Flash AT90C8534. Preliminary

8-bit Microcontroller with 8K Bytes Programmable Flash AT90C8534. Preliminary Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 118 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General-purpose Working Registers Up

More information

Embedded Systems and Software

Embedded Systems and Software Embedded Systems and Software Lecture 11 Interrupts Interrupts Slide 1 Interrupts One way to think of interrupts is that they are hardwaregenerated functions calls Internal Hardware When timer rolls over,

More information

Interrupts (I) Lecturer: Sri Notes by Annie Guo. Week8 1

Interrupts (I) Lecturer: Sri Notes by Annie Guo. Week8 1 Interrupts (I) Lecturer: Sri Notes by Annie Guo Week8 1 Lecture overview Introduction to Interrupts Interrupt system specifications Multiple Sources of Interrupts Interrupt Priorities Interrupts in AVR

More information

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming ICT 6641: Advanced Embedded System Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming Prof. S. M. Lutful Kabir Session: April, 2011 Review on Lecture-1 Three parts of a computer : CPU, Memory

More information

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega163 ATmega163L. Advance Information

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega163 ATmega163L. Advance Information Features High-performance, Low-power AVR 8-bit Microcontroller 3 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation Up to 8 MIPS Throughput

More information

8-bit Microcontroller with 8K Bytes In-System Programmable Flash. ATmega8515 ATmega8515L. Features

8-bit Microcontroller with 8K Bytes In-System Programmable Flash. ATmega8515 ATmega8515L. Features Features High-performance, Low-power AVR 8-bit Microcontroller RISC Architecture 130 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation

More information

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega163 ATmega163L

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega163 ATmega163L Features High-performance, Low-power AVR 8-bit Microcontroller 3 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation Up to 8 MIPS Throughput

More information

Fundamental concept in computation Interrupt execution of a program to handle an event

Fundamental concept in computation Interrupt execution of a program to handle an event Interrupts Fundamental concept in computation Interrupt execution of a program to handle an event Don t have to rely on program relinquishing control Can code program without worrying about others Issues

More information

Newbie s Guide to AVR Interrupts

Newbie s Guide to AVR Interrupts Newbie s Guide to AVR Interrupts Dean Camera March 15, 2015 ********** Text Dean Camera, 2013. All rights reserved. This document may be freely distributed without payment to the author, provided that

More information

8-bit Microcontroller with 2K Bytes of Flash. ATtiny28L ATtiny28V

8-bit Microcontroller with 2K Bytes of Flash. ATtiny28L ATtiny28V Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 90 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General-purpose Working Registers Up to

More information

AVR Timers TIMER0. Based on:

AVR Timers TIMER0. Based on: AVR Timers TIMER0 Based on: http://maxembedded.wordpress.com/2011/06/24/avr-timers-timer0-2/ The basic concepts of AVR Timers. Let me summarize it: We have seen how timers are made up of registers, whose

More information

Microprocessors & Interfacing

Microprocessors & Interfacing Lecture Overview Microprocessors & Interfacing Interrupts (II) Interrupts in AVR External interrupts Internal interrupts Timers/Counters Lecturer : Dr. Annie Guo S2, 2008 COMP9032 Week7 1 S2, 2008 COMP9032

More information

3.3V regulator. JA H-bridge. Doc: page 1 of 7

3.3V regulator. JA H-bridge. Doc: page 1 of 7 Digilent Cerebot Board Reference Manual Revision: 11/17/2005 www.digilentinc.com 215 E Main Suite D Pullman, WA 99163 (509) 334 6306 Voice and Fax Overview The Digilent Cerebot Board is a useful tool for

More information

Timers and Interrupts. Mark Neil - Microprocessor Course

Timers and Interrupts. Mark Neil - Microprocessor Course Timers and Interrupts 1 Example Product: Signal Generator A Signal Generator should be programmable. A user can use the the LCD display and the keyboard to change the: Frequency scale Amplitude scale Offset

More information

Lecture 2. Introduction to Microcontrollers

Lecture 2. Introduction to Microcontrollers Lecture 2 Introduction to Microcontrollers 1 Microcontrollers Microcontroller CPU + ++++++++++ Microprocessor CPU (on single chip) 2 What is a Microcontroller Integrated chip that typically contains integrated

More information

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer Features Real-Time Clock with Very Low Power Consumption (4µA @ 3.3V) Very Low Cost Solution Adjustable Prescaler to Adjust Precision Counts Time,

More information

Microcontroller basics

Microcontroller basics FYS3240 PC-based instrumentation and microcontrollers Microcontroller basics Spring 2017 Lecture #4 Bekkeng, 30.01.2017 Lab: AVR Studio Microcontrollers can be programmed using Assembly or C language In

More information

Building Interactive Devices and Objects. Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz MHCI Lab, LMU München

Building Interactive Devices and Objects. Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz MHCI Lab, LMU München Building Interactive Devices and Objects Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz michael.rohs@ifi.lmu.de MHCI Lab, LMU München Schedule # Date Topic Group Ac0vity 1 19.4.2012 Session 1: Introduc5on

More information

8-bit Microcontroller with 128K Bytes In-System Programmable Flash. ATmega103 ATmega103L

8-bit Microcontroller with 128K Bytes In-System Programmable Flash. ATmega103 ATmega103L Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 121 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers + Peripheral

More information

INTERRUPTS PROGRAMMING

INTERRUPTS PROGRAMMING INTERRUPTS PROGRAMMING The 8051 Microcontroller and Embedded Systems: Using Assembly and C Mazidi, Mazidi and McKinlay Chung-Ping Young 楊中平 Home Automation, Networking, and Entertainment Lab Dept. of Computer

More information

Arduino Diecimila Pinouts 697B B8D-A50A-61944C26074F

Arduino Diecimila Pinouts 697B B8D-A50A-61944C26074F mightwerk Resources for creators and innovators outs 697B1380-9797-4B8D-A50A-61944C26074F Introduction... 1 4-pin Expansion Header out... 2 6-pin ICSP Header out... 3 Map from to... 4 Map from ATmega328

More information

Various power connectors. 3.3V regulator. 64K Flash (Internal) 2K EEPROM (Internal) 4K SRAM (Internal) JA Mem Adr/ Data. Doc: page 1 of 9

Various power connectors. 3.3V regulator. 64K Flash (Internal) 2K EEPROM (Internal) 4K SRAM (Internal) JA Mem Adr/ Data. Doc: page 1 of 9 Cerebot II Board Reference Manual Revision: September 14, 2007 Note: This document applies to REV B of the board. www.digilentinc.com 215 E Main Suite D Pullman, WA 99163 (509) 334 6306 Voice and Fax Overview

More information

8-bit Microcontroller with 1K Byte Flash. ATtiny11. ATtiny12

8-bit Microcontroller with 1K Byte Flash. ATtiny11. ATtiny12 Features Utilizes the AVR RISC Architecture High-performance and Low-power 8-bit RISC Architecture 90 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Up

More information

Interrupts and timers

Interrupts and timers Applied mechatronics, Lab project Interrupts and timers Sven Gestegård Robertz Department of Computer Science, Lund University 2018 Outline 1 Interrupts Interrupt types Execution of an interrupt Maskable

More information

ATmega128A. Introduction. Features. 8-bit AVR Microcontroller DATASHEET COMPLETE

ATmega128A. Introduction. Features. 8-bit AVR Microcontroller DATASHEET COMPLETE 8-bit AVR Microcontroller ATmega128A DATASHEET COMPLETE Introduction The Atmel ATmega128A is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions

More information

AVR Microcontroller with Core Independent Peripherals and PicoPower technology

AVR Microcontroller with Core Independent Peripherals and PicoPower technology AVR Microcontroller with Core Independent Peripherals and PicoPower technology Introduction The picopower ATmega324PB is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture.

More information

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100) (Revision-10) FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100) PART-A (Maximum marks : 10) I. Answer all

More information

Introduction to Embedded Systems

Introduction to Embedded Systems Stefan Kowalewski, 4. November 25 Introduction to Embedded Systems Part 2: Microcontrollers. Basics 2. Structure/elements 3. Digital I/O 4. Interrupts 5. Timers/Counters Introduction to Embedded Systems

More information

8-bit Microcontroller with 64K/128K Bytes In-System Programmable Flash. ATmega603 ATmega603L ATmega103 ATmega103L. Preliminary.

8-bit Microcontroller with 64K/128K Bytes In-System Programmable Flash. ATmega603 ATmega603L ATmega103 ATmega103L. Preliminary. Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 120/121 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

Processor and compiler dependent

Processor and compiler dependent Fundamental concept in computation Interrupt execution of a program to handle an event Don t have to rely on program relinquishing control Can code program without worrying about others Issues What can

More information

CHW 469 : Embedded Systems

CHW 469 : Embedded Systems CHW 469 : Embedded Systems Instructor: Dr. Ahmed Shalaby http://bu.edu.eg/staff/ahmedshalaby4# I/O Ports in AVR The AVR microcontroller and embedded systems using assembly and c Topics AVR pin out The

More information

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso Microcontroller It is essentially a small computer on a chip Like any computer, it has memory,

More information

Robosoft Systems in association with JNCE presents. Swarm Robotics

Robosoft Systems in association with JNCE presents. Swarm Robotics Robosoft Systems in association with JNCE presents Swarm Robotics What is a Robot Wall-E Asimo ABB Superior Moti ABB FlexPicker What is Swarm Robotics RoboCup ~ 07 Lets Prepare for the Robotics Age The

More information

Interrupts (II) Lecturer: Sri Parameswaran Notes by: Annie Guo

Interrupts (II) Lecturer: Sri Parameswaran Notes by: Annie Guo Interrupts (II) Lecturer: Sri Parameswaran Notes by: Annie Guo 1 External Interrupts The external interrupts are triggered by the INT7:0 pins. If enabled, the interrupts will trigger even if the INT7:0

More information

AVR XMEGA TM. A New Reference for 8/16-bit Microcontrollers. Ingar Fredriksen AVR Product Marketing Director

AVR XMEGA TM. A New Reference for 8/16-bit Microcontrollers. Ingar Fredriksen AVR Product Marketing Director AVR XMEGA TM A New Reference for 8/16-bit Microcontrollers Ingar Fredriksen AVR Product Marketing Director Kristian Saether AVR Product Marketing Manager Atmel AVR Success Through Innovation First Flash

More information

Microprocessors and Microcontrollers (EE-231)

Microprocessors and Microcontrollers (EE-231) Microprocessors and Microcontrollers (EE-231) Objective Interrupts Programming in C In Proteus On 8051 development board Interrupt An interrupt is an external or internal event that interrupts the microcontroller

More information

CN310 Microprocessor Systems Design

CN310 Microprocessor Systems Design CN310 Microprocessor Systems Design Microcontroller Nawin Somyat Department of Electrical and Computer Engineering Thammasat University Outline Course Contents 1 Introduction 2 Simple Computer 3 Microprocessor

More information

Software Design Considerations, Narrative and Documentation

Software Design Considerations, Narrative and Documentation Software Design Considerations, Narrative and Documentation Introduction The project under consideration is an automated shopping cart designed to follow a shopper around a simulated supermarket environment.

More information

ATmegaS128. Introduction. Features

ATmegaS128. Introduction. Features Rad-Tol 8-bit AVR Microcontroller, 3.3V, 8 MHz with 128 KB Flash, 4 KB EEPROM, 4 KB SRAM, 10-bit ADC, TWI, RTC, 16-bit PWM, USART, SPI and 16-bit Timer/Counter Introduction The ATmegaS128 is a low-power

More information

EMB128. ere co., ltd.

EMB128. ere co., ltd. ATMEGA128 Embedded Board Main Features Atmega128 8-bit RISC CPU (AVR family) Serial EEPROM (I2C), 24LC256 Real Time Clock, DS1307 3V lithium battery keeping time and date 2 channels RS485 2 channels RS232

More information

These three counters can be programmed for either binary or BCD count.

These three counters can be programmed for either binary or BCD count. S5 KTU 1 PROGRAMMABLE TIMER 8254/8253 The Intel 8253 and 8254 are Programmable Interval Timers (PTIs) designed for microprocessors to perform timing and counting functions using three 16-bit registers.

More information

ATmega8A. Introduction. Features. 8-bit AVR Microcontroller DATASHEET COMPLETE

ATmega8A. Introduction. Features. 8-bit AVR Microcontroller DATASHEET COMPLETE 8-bit AVR Microcontroller ATmega8A DATASHEET COMPLETE Introduction The Atmel ATmega8A is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions

More information

Software debouncing of buttons

Software debouncing of buttons Software debouncing of buttons snigelen February 5, 2015 1 Introduction Connecting a button as an input to a micro-controller is a relatively easy task, but there are some problems. The main problem is

More information

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega169V ATmega169. Features. Notice: Not recommended in new designs.

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega169V ATmega169. Features. Notice: Not recommended in new designs. Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 130 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

AT90S Bit Microcontroller with 1K bytes Downloadable Flash AT90S1200. Features. Description. Pin Configuration

AT90S Bit Microcontroller with 1K bytes Downloadable Flash AT90S1200. Features. Description. Pin Configuration Features Utilizes the AVR Enhanced RISC Architecture 89 Powerful Instructions - Most Single Clock Cycle Execution 1K bytes of In-System Reprogrammable Downloadable Flash - SPI Serial Interface for Program

More information

AVR094: Replacing ATmega8 by ATmega88. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR094: Replacing ATmega8 by ATmega88. 8-bit Microcontrollers. Application Note. Features. Introduction AVR094: Replacing by 8 Features Interrupt Vectors Bit and Register s and locations Oscillators and Start up Delay Brown Out Detection USART Control Register access Internal Voltage Reference Programming

More information

The Atmel ATmega168A Microcontroller

The Atmel ATmega168A Microcontroller Ming Hsieh Department of Electrical Engineering EE 459Lx - Embedded Systems Design Laboratory The Atmel ATmega168A Microcontroller by Allan G. Weber 1 Introduction The Atmel ATmega168A is one member of

More information

8-bit Atmel Microcontroller with 8/16K Bytes In-System Programmable Flash AT90PWM81 AT90PWM161

8-bit Atmel Microcontroller with 8/16K Bytes In-System Programmable Flash AT90PWM81 AT90PWM161 Features High performance, low power Atmel AVR 8-bit Microcontroller Advanced RISC architecture 131 powerful instructions - most single clock cycle execution 32 8 general purpose working registers Fully

More information

TIMSK=0b ; /* enables the T/C0 overflow interrupt in the T/C interrupt mask register for */

TIMSK=0b ; /* enables the T/C0 overflow interrupt in the T/C interrupt mask register for */ The codes below which help in better understanding of timers and counters. I have tested this code for atmega32. I have taken reference from www.avrfreaks.net. Hope you all will find this useful. Darsh

More information

Embedded programming, AVR intro

Embedded programming, AVR intro Applied mechatronics, Lab project Embedded programming, AVR intro Sven Gestegård Robertz Department of Computer Science, Lund University 2017 Outline 1 Low-level programming Bitwise operators Masking and

More information

Lecture 14. Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Lecture 14. Ali Karimpour Associate Professor Ferdowsi University of Mashhad Lecture 14 AUTOMATIC CONTROL SYSTEMS Ali Karimpour Associate Professor Ferdowsi University of Mashhad Lecture 4 The AVR Microcontroller Introduction to AVR CISC (Complex Instruction Set Computer) Put as

More information

MICROPROCESSOR BASED SYSTEM DESIGN

MICROPROCESSOR BASED SYSTEM DESIGN MICROPROCESSOR BASED SYSTEM DESIGN Lecture 5 Xmega 128 B1: Architecture MUHAMMAD AMIR YOUSAF VON NEUMAN ARCHITECTURE CPU Memory Execution unit ALU Registers Both data and instructions at the same system

More information

The Atmel ATmega328P Microcontroller

The Atmel ATmega328P Microcontroller Ming Hsieh Department of Electrical Engineering EE 459Lx - Embedded Systems Design Laboratory 1 Introduction The Atmel ATmega328P Microcontroller by Allan G. Weber This document is a short introduction

More information

8-Bit Microcontroller with 1K bytes In-System Programmable Flash AT90S1200. Features. Description. Pin Configuration

8-Bit Microcontroller with 1K bytes In-System Programmable Flash AT90S1200. Features. Description. Pin Configuration Features AVR - High Performance and Low Power RISC Architecture 89 Powerful Instructions - Most Single Clock Cycle Execution 1K bytes of In-System Reprogrammable Flash SPI Serial Interface for Program

More information

Charon 2M. Ethernut embedded ethernet module with 128 kb SRAM. Main Features

Charon 2M. Ethernut embedded ethernet module with 128 kb SRAM. Main Features Charon 2M Ethernut embedded ethernet module with 128 kb SRAM Main Features Full duplex IEEE 802.3 10 Mb/s Ethernet ATmega 128 RISC AVR microcontroller - up to 16 MIPS throughput 128 kbyte In-System Programmable

More information

Microcontroller basics

Microcontroller basics FYS3240 PC-based instrumentation and microcontrollers Microcontroller basics Spring 2012 Lecture #4 Bekkeng, 5.2.2012 Lab: AVR Studio Microcontrollers can be programmed using Assembly or C language AVR

More information

ET-BASE AVR ATmega64/128

ET-BASE AVR ATmega64/128 ET-BASE AVR ATmega64/128 ET-BASE AVR ATmega64/128 which is a Board Microcontroller AVR family from ATMEL uses MCU No.ATmega64 and ATmega128 64PIN. Board ET-BASE AVR ATmega64/128 uses MCU s resources on

More information

Revision: 05/05/ E Main Suite D Pullman, WA (509) Voice and Fax. Various power connectors. 3.3V regulator

Revision: 05/05/ E Main Suite D Pullman, WA (509) Voice and Fax. Various power connectors. 3.3V regulator Digilent Cerebot Plus Board Reference Manual Revision: 05/05/2008 www.digilentinc.com 215 E Main Suite D Pullman, WA 99163 (509) 334 6306 Voice and Fax Overview The Digilent Cerebot Plus Board is a useful

More information

Arduino Uno R3 INTRODUCTION

Arduino Uno R3 INTRODUCTION Arduino Uno R3 INTRODUCTION Arduino is used for building different types of electronic circuits easily using of both a physical programmable circuit board usually microcontroller and piece of code running

More information

U6DIL. AVR USB Module. Rev. 1.1 Documentation Rev. 18. Reusch Elektronik Reusch Elektronik, Dipl.-Ing. (FH) Rainer Reusch

U6DIL. AVR USB Module. Rev. 1.1 Documentation Rev. 18. Reusch Elektronik Reusch Elektronik, Dipl.-Ing. (FH) Rainer Reusch AVR USB Module Documentation Rev. 18 2011, Dipl.-Ing. (FH) Rainer Reusch www.reusch-elektronik.de http://products.reworld.eu/u6dil.htm File: _Manual Created: 2011-02-22 Changed: 2011-03-31 Table of Contents

More information

U4DIL. AVR USB Module. Rev. 1.1 Documentation Rev. 19. Reusch Elektronik Reusch Elektronik, Dipl.-Ing. (FH) Rainer Reusch

U4DIL. AVR USB Module. Rev. 1.1 Documentation Rev. 19. Reusch Elektronik Reusch Elektronik, Dipl.-Ing. (FH) Rainer Reusch AVR USB Module Documentation Rev. 19 2010, Dipl.-Ing. (FH) Rainer Reusch www.reusch-elektronik.de http://products.reworld.eu/u4dil.htm File: _Manual Created: 2010-02-10 Changed: 2010-09-07 Contents 1.

More information

Laboratory 3 Working with the LCD shield and the interrupt system

Laboratory 3 Working with the LCD shield and the interrupt system Laboratory 3 Working with the LCD shield and the interrupt system 1. Working with the LCD shield The shields are PCBs (Printed Circuit Boards) that can be placed over the Arduino boards, extending their

More information

Microprocessors B (17.384) Spring Lecture Outline

Microprocessors B (17.384) Spring Lecture Outline Microprocessors B (17.384) Spring 2013 Lecture Outline Class # 04 February 12, 2013 Dohn Bowden 1 Today s Lecture Administrative Microcontroller Hardware and/or Interface Programming/Software Lab Homework

More information

Interrupt Programming: Interrupts vs. Polling Method:

Interrupt Programming: Interrupts vs. Polling Method: UNIT 4: INTERRUPT PROGRAMMING & SERIAL COMMUNICATION WITH 8051: Definition of an interrupt, types of interrupts, Timers and Counter programming with interrupts in assembly. 8051 Serial Communication: Data

More information

ADC: Analog to Digital Conversion

ADC: Analog to Digital Conversion ECE3411 Fall 2015 Lecture 5b. ADC: Analog to Digital Conversion Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: {vandijk, syed.haider}@engr.uconn.edu

More information

Marten van Dijk, Syed Kamran Haider

Marten van Dijk, Syed Kamran Haider ECE3411 Fall 2015 Wrap Up Review Session Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: vandijk, syed.haider@engr.uconn.edu Pulse Width

More information

ATmega1284P. Introduction. Feature. 8-bit AVR Microcontrollers DATASHEET COMPLETE

ATmega1284P. Introduction. Feature. 8-bit AVR Microcontrollers DATASHEET COMPLETE 8-bit AVR Microcontrollers ATmega1284P DATASHEET COMPLETE Introduction The Atmel picopower ATmega1284P is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing

More information

19.1. Unit 19. Serial Communications

19.1. Unit 19. Serial Communications 9. Unit 9 Serial Communications 9.2 Serial Interfaces Embedded systems often use a serial interface to communicate with other devices. Serial implies that it sends or receives one bit at a time. µc Device

More information

AVR Microcontrollers Architecture

AVR Microcontrollers Architecture ก ก There are two fundamental architectures to access memory 1. Von Neumann Architecture 2. Harvard Architecture 2 1 Harvard Architecture The term originated from the Harvard Mark 1 relay-based computer,

More information

Objectives. I/O Ports in AVR. Topics. ATmega16/mega32 pinout. AVR pin out The structure of I/O pins I/O programming Bit manipulating 22/09/2017

Objectives. I/O Ports in AVR. Topics. ATmega16/mega32 pinout. AVR pin out The structure of I/O pins I/O programming Bit manipulating 22/09/2017 Objectives The AVR microcontroller and embedded systems using assembly and c I/O Ports in AVR List all the ports of the AVR microcontroller Describe the dual role of the AVR pins Code assembly language

More information

Marten van Dijk, Syed Kamran Haider

Marten van Dijk, Syed Kamran Haider ECE3411 Fall 2015 Lecture 3b. Timers 0, 1 & 2 Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: vandijk, syed.haider@engr.uconn.edu Based

More information

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation. : Real-Time Clock (RTC) using the Asynchronous Timer Features Real-Time Clock with Very Low Power Consumption (4µA @ 3.3V) Very Low Cost Solution Adjustable Prescaler to Adjust Precision Counts Time, Date,

More information