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

Size: px
Start display at page:

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

Transcription

1 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 for the ATMEL AVR 2 Tutorial 7 Lab 7 3 L8: Serial communication 4 Tutorial 8 Lab 8 5 L9: Timers 6 Tutorial 9 Lab 9 7 L: Pulse width modulator 8 Tutorial Lab 9 L:Analogue-to-digital converter Tutorial Lab L2: Revision lecture 2 Lab 2 3 L3: Self-study guide (no lecture) Final exam (25%), Practical exam (2%), Labs (5%) 2/57 Lecture 9 s sequence 9. Interrupt programming in C for ATmega6 9. Interrupt programming in C for ATmega6 In Semester, we learnt the interrupt-driven approach and the ATmega855, writing an interrupt-driven program in the assembly language Timers in ATmega6 In this lecture, we will learn the interrupt subsystem in the ATmega6, writing an interrupt-driven program in C. 9.3 Timer applications Compared to polling, interrupt is a more efficient approach for the CPU to handle peripheral devices, e.g. serial port, external switches, timers, PWM, and ADC. 3/57 4/57

2 Polling versus Interrupt Polling while (){ get_device_status; if (service_required){ instruction k service_routine; routine; normal_execution; instruction k+ rmal_ex xecutio on no Interrupt interrupt signal runs interrupt_ service_ routine Interrupt execution sequence. A device issues an interrupt 2. CPU finishes the current instruction 3. CPU acknowledges the interrupt 4. CPU saves its states and PC onto stack 5. CPU loads the address of ISR onto PC Using polling, the CPU must continually check the device s status. Using interrupt: 6. CPU executes the ISR A device will send an interrupt signal when needed. In response, the CPU will perform an interrupt service routine, and then resume its normal execution. 7. CPU retrieves its states and PC from stack 8. Normal execution resumes 5/57 6/57 ATmega6 interrupt subsystem Table 9.: Interrupts in ATmega6 Vector No. Program Address Interrupt t vector name Description The ATmega6 has 2 interrupts: reset interrupt 3 external interrupts 8 timer interrupts 3 serial port interrupts ADC interrupt $ RESET_vect Reset 2 $2 INT_vect External Interrupt Request 3 $4 INT_vect External Interrupt Request 4 $6 TIMER2_COMP_vect Timer/Counter2 Compare Match 5 $8 TIMER2_OVF_vect Timer/Counter2 Overflow 6 $A TIMER_CAPT_vect Timer/Counter Capture Event 7 $C TIMER_COMPA_vect Timer/Counter Compare Match A 8 $E TIMER_COMPB_vect Timer/Counter Compare Match B 9 $ TIMER_OVF_vect Timer/Counter Overflow $2 TIMER_OVF_vect Timer/Counter Overflow $4 SPI_STC_vect Serial Transfer Complete analogue comparator interrupt SPI interrupt TWI interrupt 2 memory interrupts 2 $6 USART_RXC_vect USART, Rx Complete 3 $8 USART_UDRE_vectUDRE USART Data Register Empty 4 $A USART_TXC_vect USART, Tx Complete 5 $C ADC_vect ADC Conversion Complete 6 $E EE_RDY_vect EEPROM Ready 7 $2 ANA_COMP_vect Analog Comparator 8 $22 TWI_vect 2-wire Serial Interface 9 $24 INT2_vect External Interrupt Request 2 2 $26 TIMER_COMP_vect Timer/Counter Compare Match 2 $28 SPM_RDY_vect Store Program Memory Ready 7/57 8/57

3 Table 9.: Interrupts in ATmega6 Steps to program an interrupt in C Vector No An interrupt with a lower Vector No has a higher priority. E.g., INT has a higher priority than INT and INT2. Program Address The fixed memory location for a given interrupt handler. E.g., in response to interrupt INT, CPU runs instruction at $2. To program an interrupt, 5 steps are required.. Include header file <avr\interrupt.h>. 2. Use C macro ISR() to define the interrupt handler and update IVT. 3. Enable the specific interrupt. t 4. Configure details of the interrupt by setting relevant registers. 5. Enable the interrupt subsystem globally using sei(). Interrupt Vector Name This is the interrupt name, to be used with C macro ISR(). Later, we ll study steps for interrupt programming in C, via 2 examples. 9.. USART RXD Complete interrupt 9..2 External interrupts 9/57 /57 Using C macro ISR() Learning ATmega6 interrupts Vector No. Interrupt vector name Description The C macro ISR() is used to define the handler for a given interrupt. RESET_vect Reset 2 INT_vect External Interrupt Request Its syntax is given as 3 INT_ vect External Interrupt Request 4 TIMER2_COMP_vect Timer/Counter2 Compare Match ISR(interrupt_vector_name){ // code for interrupt handler here where interrupt_vector_name is given in Table TIMER2_OVF_vect Timer/Counter2 Overflow 6 TIMER_CAPT_vect Timer/Counter Capture Event 7 TIMER_COMPA_vect Timer/Counter Compare Match A 8 TIMER_COMPB_vect Timer/Counter Compare Match B 9 TIMER_OVF_vect Timer/Counter Overflow TIMER_OVF_vect Timer/Counter Overflow SPI_STC_vect Serial Transfer Complete 2 USART_RXC_vect USART, Rx Complete Example: To process interrupt t RXD Complete and put the received character in Port B, we write 3 USART_UDRE_vectUDRE USART Data Register Empty 4 USART_TXC_vect USART, Tx Complete 5 ADC_vect ADC Conversion Complete ISR(USART_RXC_vect){ RXC PORTB = UDR; // put the received character in Port B 6 EE_RDY_vect EEPROM Ready 7 ANA_COMP_vect Analog Comparator 8 TWI_vect 2-wire Serial Interface 9 INT2_vect External Interrupt Request 2 2 TIMER_COMP_vect Timer/Counter Compare Match 2 SPM_RDY_vect Store Program Memory Ready /57 2/57

4 9.. Serial RXD interrupt Write a C interrupt-driven program to use the serial port of ATmega6 at baud rate 2, no parity, stop bit, 8 data bits, clock speed MHz. Whenever a character is received, it should be sent to Port B. The serial port on ATmega6 can trigger an RXD interrupt whenever a character is received [Lecture 8]. We enable this interrupt by setting a flag in a serial port register. We then write the interrupt handler, to be run whenever the interrupt is triggered. Serial RXD interrupt: Enabling RXCIE TXCIE UDRIE RXEN TXEN UCSZ2 RXB8 TXB8 Register UCSRB = b Tx extra data bit for 9-bit character size Rx extra data bit for 9-bit character size bit 2 to decide character size to enable USART transmitter: Pin D. = TXD pin to enable USART receiver: Pin D. = RXD pin to enable USART Data Register Empty Interrupt to enable TX Complete Interrupt, valid only if Global Interrupt Flag = and TXC = to enable RX Complete Interrupt, valid only if Global Interrupt Flag = and RXC = For any interrupt, the ATmega6 manual explains how to enable the interrupt. E.g., for serial RXD interrupt, we look at USART section. 3/57 4/57 Serial RXD interrupt: serial_int.c #include <avr/io.h> #include <avr/interrupt.h> void USART_init(void){ // Normal speed, disable multi-proc UCSRA = b; // Enable Tx and Rx pins, enable RX interrupt UCSRB = b; // Asynchronous mode, no parity, stop bit, 8 data bits UCSRC = b; // Baud rate 2bps, assuming MHz clock UBRRL = x33; UBRRH = x; ISR(USART_RXC_vect){ RXC // Handler for RXD interrupt PORTB = UDR; // Received character is displayed on port B int main(void) { USART_init(); // initialise USART sei(); // enable interrupt subsystem globally DDRB = xff; // set port B for output while () {; // infinite loop return ; Serial RXD interrupt: Testing Write To test a C the interrupt-driven serial RXD interrupt program example: to toggle port B whenever a switch on the STK5 board is pressed. The program should use an external Connect RXD pin (pin D.) to RXD pin of RS232 Spare. interrupt. Connect TXD pin (pin D.) to TXD pin of RS232 Spare. Connect Port B to LED connector. Compile, download program. Connect RS232 Spare Connector to Serial Port of PC. Configure and run HyperTerminal and use it to send characters. Video demo: [avr]/ecte333/serial_int.mp4 avr = 5/57 6/57

5 Serial RXD: Polling approach For comparison, the program below uses polling for the same effect. #include <avr/io.h> void USART_init(void){ // Normal speed, disable multi-proc UCSRA = b; // Enable Tx and Rx, disable interrupts UCSRB = b; // Asynchronous mode, no parity, stop bit, 8 data bits UCSRC = b; // Baud rate 2bps, assuming MHz clock UBRRL = x33; UBRRH = x; int main(void) { USART_init(); // initialise USART DDRB = xff; // set port B for output while () { // infinite loop // Poll until RXC flag = while ((UCSRA & (<<RXC)) == x){; PORTB = UDR; // received character is displayed on port B return ; 7/ External interrupts Write External a C interrupt-driven interrupts on ATmega6 program and to toggle ATmega855 port B whenever are similar. a switch on the STK5 board is pressed. The program should use an external Key references on ATmega6 external interrupts: t ATmega6 user interrupt. manual, External Interrupts section. Three external interrupts can be triggered. INT on pin D.2, INT on pin D.3, INT2 on pin B.2. Key steps in using external interrupts: enable the interrupt, specify what types of event will trigger the interrupt. rising-edge interrupt falling-edge interrupt 8/57 External Interrupts: Relevant pins External interrupts: Enabling To enable an external interrupt, set a flag in General Interrupt Control Register (GICR). INT INT INT IVSEL IVSEL Read/Write R/W R/W R/W R R R R/W R/W Initial value Example: To enable INT on pin D.3, we can write GICR = ( << INT); Note that INT and GICR names are already defined in <avr/io.h>. #define INT 7 9/57 2/57

6 External interrupts: Specifying events External interrupts: Specifying events Specify the events that trigger an external interrupt by using MCU Control Register (INT and INT), or MCU Control and Status Register (INT2). For INT and INT: MCUCR SM2 SE SM SM ISC ISC ISC ISC For INT2: MCUCSR JTD ISC2 - JTRF WDRF BORF EXTRF PORF : falling edge triggers an interrupt INT2 : rising edge triggers an interrupt INT2 ISC ISC An interrupt is triggered when low level of INT any change of INT falling edge of INT rising edge of INT ISC ISC An interrupt is triggered when low level of INT any change of INT falling edge of INT rising edge of INT 2/57 22/57 External interrupts: Example External interrupts: ext_int.c Write a C program to toggle port B whenever a switch on the STK5 board is pressed. The program should use an external interrupt. #include <avr/io.h> #include <avr/interrupt.h> ISR(INT_vect){ // handler for INT interrupt PORTB = (~PORTB); // toggle port B Let s use interrupt INT. This interrupt is triggered on pin D.3. To enable interrupt INT: GICR = ( << INT); int main(void) { GICR = ( << INT); // enable interrupt INT MCUCR = (<<ISC); // triggered on any change to INT pin (D.3) To specify that INT is triggered on any change in pin D.3: sei(); DDRB = xff; // enable interrupt subsystem globally // set port B for output MCUCR = ( << ISC); Then, we write interrupt handler and enable interrupt subsystem. PORTB = b; // initial value while () {; return ; // infinite main loop 23/57 24/57

7 External interrupts: Testing ext_int.c Lecture 9 s sequence Write To test a C the interrupt-driven external interrupt program example: to toggle port B whenever a switch on the STK5 board is pressed. The program should use an external Connect INT pin (pin D.3) to switch SW7 on STK5 board. interrupt. Connect GRD pin of Port D to GRD pin of SW connector. Connect Port B to LED connector. 9. Interrupt programming in C for ATmega6 Compile, download program. Press switch SW Timers in ATmega6 Video demo: [avr]/ecte333/ext_int.mp4 9.3 Timer applications 25/57 26/ Timers in ATmega6 Timer terminology Many computer applications require accurate timing. Examples include: recording the time when an event occurs, calculating the time difference between events, performing tasks at specific or periodic times, creating accurate time delays, generating waveforms of certain shape, period, or duty cycle. Lectures 9 and focus on using timers to perform time-related tasks. Input Capture: Input signal is connected to a pin, called input capture, of the timer. When a preset event (rising edge, falling edge, change) occurs on this pin, the current timer value is automatically stored in a register. Output Compare: A timer typically has a pin, called output compare. When the timer reaches a preset value, the output compare pin can be automatically changed to logic or logic. 27/57 28/57

8 Overview of Timers in ATmega6 Overview of Timers in ATmega6 ATmega6 has three timers: Timer, Timer and Timer 2. When the internal system clock is used, a prescaler can be applied to make the timer count at a slower rate. Each timer is associated with a counter and a clock signal. Example: The counter is incremented by in every clock cycle of the timer. Consider a system clock of Mhz (i.e. μs per cycle). Suppose that a timer prescaler of 64 is used. The clock signal of a timer can come from the internal system clock or Then, timer will increment every 64μs. an external clock source. 29/57 3/57 Overview of Timers in ATmega6 Study plan Timer Timer Timer 2 In Lecture 9, we focus on - 8-bit counter - 6-bit counter - 8-bit counter Overall - -bit prescaler - -bit prescaler - -bit prescaler operations of Timer, using Timer overflow interrupt, Functions - PWM - PWM - PWM - Frequency generation - Frequency generation - Frequency generation - Event counter - Event counter - Event counter - Output compare - Output compare channels: 2 - Output compare - Input capture using Timer input capture interrupt, measuring time, creating time delay, measuring gperiod/duty cycle of a signal, information required for Lab 9. Operation modes - Normal mode - Normal mode - Normal mode - Clear timer on - Clear timer on - Clear timer on compare match compare match compare match - Fast PWM - Fast PWM - Fast PWM - Phase correct PWM - Phase correct PWM - Phase correct PWM In Lecture, we will learn using Timer output compare interrupt, generating PWM signals, information required for Lab. Timer has the most capability among the three timers. 3/57 32/57

9 Timer : An overview 6-bit counter. -bit prescaler: 8, 64, 256, and 24 can trigger a timer overflow interrupt when counter reaches MAX. can trigger an input capture interrupt when an event occurs on the input capture pin. timer value is stored automatically in a register. input capture pin for Timer is ICP (D.6). can trigger an output compare match interrupt when timer reaches a preset value. There are two independent output compare channels A and B. Timer : Block diagram Current timer/counter value Output Compare Registers Input Capture register Timer/Counter Control Registers External clock pin Output Compare pins Input Capture pin Not shown here: TIMSK and TIFR registers 33/57 34/57 Timer Relevant pins Timer Five groups of registers ) Timer/Counter TCNT 6-bit register that stores the current value of the timer. 2) Timer/Counter Control Registers TCCRA and TCCRB To configure the operations of Timer. 3) Input Capture Register ICR to store timer value when an event occurs on input capture pin. 4) Interrupt registers TIMSK to enable timer interrupts TIFR to monitor status of timer interrupts. used in this lecture 5) Output Compare Registers OCRA, OCRB To store the preset values for output compare. 35/57 36/57

10 Timer Five groups of registers 9.2. Timer/Counter Control Register A (TCCRA) COMACOMA COMBCOMB FOCA FOCB WGM WGM Specify Waveform Generation Mode used with WGM3, WGM2 WGM3..WGM = for normal mode. to force output compare on channel B to force output compare on channel A Output compare mode for channel B Output compare mode for channel A 37/57 38/ Timer/Counter Control Register B (TCCRB) ICNC ICES - WGM3 WGM2 CS2 CS CS 3 2 Clock select CS2 CS CS Description No clock source (timer stopped) CLK I/O / (no prescaling) CLK I/O /8 (from prescaler) clock select (next slide) CLK I/O /64 (from prescaler) CLK I/O /256 (from prescaler) CLK I/O /24 (from prescaler) select Waveform Generation Mode, used with WGM, WGM WGM3..WGM = for normal mode. input capture edge select: will select rising edge, will select falling edge to activate input capture noise canceller External clock source on T pin. Clock on falling edge. External clock source on T pin. Clock on rising edge. For ATmega6, the default internal clock is clk I/O = MHz. Timer can use the internal or external clock. If using the internal clock, we can set Timer to run 8, 64, 256, or 24 times slower than the internal clock. 39/57 4/57

11 9.2.3 Timer/Counter Interrupt Mask Register (TIMSK) Timer/Counter Interrupt Flag Register (TIFR) OCIE2 TOIE2 TICIE OCIEA OCIEB TOIE OCIE TOIE OCF2 TOV2 ICF OCFA OCFB TOV OCF TOV For Timer For Timer Timer Overflow Interrupt Enable Timer Overflow Interrupt Flag: set to when overflow Timer Output Compare B Match Interrupt Enable: to enable Timer Output Compare B Match Flag: set to when match Timer Output Compare A Match Interrupt Enable: to enable Timer Output Compare A Match Flag: set to when match Timer Input Capture Flag: set to when capture event occurs Timer Input Capture Interrupt Enable: to enable For Timer 2 For Timer 2 This register has flags that indicate when a timer interrupt occurs. 4/57 42/57 Lecture 9 s sequence 9.3 Timer applications In this section, we consider three applications of Timer. 9. Interrupt programming in C for ATmega Creating an accurate delay using timer overflow interrupt Timers in ATmega Measuring elapsed time between two events. 9.3 Timer applications Measuring the period of a square signal using input capture interrupt. 43/57 44/57

12 9.3. Creating an accurate delay Write a C program for ATmega6 to toggle PORTB every 2 seconds. It should use Timer overflow interrupt to create delays of 2s each. Analysis (video) Internal system clock: MHz. With no prescaler, Timer increments every μs. Timer is 6-bit counter, so it will overflow every 2 6 μs. For a 2s delay, we need Timer to overflow for 2s/2 6 μs = 3 times. Coding Write code to enable & intercept t Timer overflow interrupt. t Use interrupt handler to count the number of overflows. When the number of overflows is 3, toggle port B. Creating an accurate delay: timer_delay.c #include <avr/io.h> #include <avr/interrupt.h> volatile int overflow_count; ISR(TIMER_OVF_vect){ // handler for Timer overflow interrupt overflow_count++; // increment overflow count if (overflow_count >= 3){ // when 2s has passed overflow_count = ; // start new count PORTB = ~PORTB; // toggle port B int main(void) { DDRB = xff; // set port B for output PORTB = x; // initial value of PORTB overflow_count = ; // initialise overflow count TCCRA = b; // normal mode TCCRB = b; // no prescaler, internal clock TIMSK = b; // enable Timer overflow interrupt sei(); // enable interrupt subsystem globally while (){; return ; // infinite loop 45/57 46/ Measuring elapsed time Measuring elapsed time To measure time using Timer, we must keep track of both Use Timer to measure the execution time of some custom C code. the number of times that Timer has overflowed: n the current counter value: TCNT Approach: If we reset n and TCNT at the beginning of the interval, then the time elapse is (assuming no prescaler, MHz clock) t = n x TCNT (μs) Clear Timer when the code starts. Record Timer when the code finishes. Also, use Timer Overflow Interrupt to keep track of how many n = TCNT = Timer Overflows TCNT times it has overflowed. 2 n time interval t start t at time t stop at time t 2 47/57 48/57

13 Measuring elapsed time: measure_time.c #include <avr/io.h> #include <avr/interrupt.h> #include <inttypes.h> volatile uint32_t t n; ISR(TIMER_OVF_vect){ // handler for Timer overflow interrupt n++; // increment overflow count int main(void) { int i, j; uint32_t elapse_time; // uint32_t is unsigned 32-bit integer data type TCCRA = b; // normal mode TCCRB = b; // no prescaler, internal clock TIMSK = b; // enable Timer overflow interrupt Measuring period of a square signal Use Timer input capture interrupt to measure the period of a square wave. Analysis: The period of a square wave = the time difference between two consecutive rising edges. Connect the square wave to input capture pin of Timer. Configure input capture module to trigger on a rising edge. n = ; // reset n TCNT = ; // reset Timer sei(); // enable interrupt subsystem globally // start code for (i = ; i < ; i++) for (j = ; j < ; j++){; // end code elapse_time = n * (uint32_t) TCNT; cli(); // disable interrupt subsystem globally return ; Input capture interrupt is triggered. Read ICR register. period Input capture interrupt is triggered. Read ICR register again. square waveform 49/57 5/57 Measuring period of a square signal measure_period.c Assumption: the input signal has a high frequency, hence timer overflow can be ignored. #include <avr/io.h> #include <avr/interrupt.h> #include <inttypes.h> uint6_t period; // data type: unsigned 6-bit integer Implementation: Select timer operations: normal, no prescaler, internal clock MHz, noise canceller enabled, input capture for rising edges. TCCRA = b; TCCRB = b; ISR(TIMER_CAPT_vect){ // handler for Timer input capture interrupt period = ICR; // period = value of Timer stored in ICR TCNT = ; // reset Timer PORTB = ~(period >> 8); // display top 8-bit of period on PORT B int main(void) { DDRB = xff; // set port B for output Enable input capture interrupt: TIMSK = b; TCCRA = b; // normal mode TCCRB = b; // no prescaler, rising edge, noise canceller TIMSK = b; // enable Timer input capture interrupt sei(); // enable interrupt subsystem globally while (){; // infinite loop return ; 5/57 52/57

14 Testing measure_period.c Write To test a C the interrupt-driven code for measuring program period: to toggle port B whenever a switch on the STK5 board is pressed. The program should use an external Connect Input Capture pin (D.6) to square wave generator on interrupt. WishMaker. Connect GRD pin of Port D to GRD pin of WishMaker. Connect Port B to LED connector. Compile, download program. Change frequency of square ware and observe output on LEDs. Extending measure_period.c This example assumes no timer overflow between two rising edges of the square signal. In Lab 9, you are required to extend the code to measure the period for low-frequency signals. It is necessary to intercept timer overflow (see Examples 9.3. & 9.3.2). Video demo: [avr]/ecte333/measure_period.mp4 For testing, the measured period should be sent to PC via serial port. 53/57 54/57 Lecture 9 s summary Lecture 9 s references What we learnt in this lecture: How to write an interrupt-driven program in C for ATmega6. Programming serial and external interrupts in C. Overview of timers in ATmega6. Using Timer overflow and input capture interrupts in 3 applications. What are the next activities? Tutorial 9: Timers. Lab 9: Timers Complete the online Pre-lab Quiz for Lab 9. Write programs for Tasks and 2 of Lab 9. See video demos of Lab 9: [avr]/ecte333/lab9_task.mp4 [avr]/ecte333/lab9_task2.mp4 J. Pardue, C Programming for Microcontrollers, 25, SmileyMicros, [Chapter 7: Interrupts ]. Atmel Corp., 8-bit AVR microcontroller with 6K Bytes In-System Programmable Flash ATmega6/ATmega6L, 27, [Interrupts], t [External Interrupts] t and [Timers]. S. F. Barrett and D. J. Pack, Atmel AVR Microcontroller Primer: Programming and Interfacing, 28, Morgan & Claypool Publishers, [Chapter 5: Timing Subsystem]. 55/57 56/57

15 Lecture 9 s references M. Mazidi, J. Mazidi, R. McKinlay, The 85 microcontroller and embedded systems using assembly and C, 2 nd ed., Pearson Prentice Hall, 26, [Chapters 9]. M. Mazidi and J. Mazidi, The 886 IBM PC and compatible computers, 4 th ed., Pearson Prentice Hall, 23, [Chapters 3]. P. Spasov, Microcontroller technology the 68HC, 3 rd ed., Prentice Hall, 999, [Chapters ]. H. Huang, MC68HC2 an introduction: software and hardware interfacing, Thomson Delmar Learning, 23, [Chapter 8]. 57/57

Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR

Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR Objectives To become familiar with interrupts on the AVR Maskable and non-maskable Initialization Triggers To develop interrupt service routines

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

Unit 14 Timers and Counters 14.1

Unit 14 Timers and Counters 14.1 Unit 14 Timers and Counters 14.1 14.2 Counter/Timers Overview ATmega328P has two and one counters. Can configure to count at some frequency up to some value (a.k.a. ), generate an and counkng again, if

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

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

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

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

Physics 120B: Lecture 11. Timers and Scheduled Interrupts

Physics 120B: Lecture 11. Timers and Scheduled Interrupts Physics 120B: Lecture 11 Timers and Scheduled Interrupts Timer Basics The ATMega 328 has three @mers available to it (Arduino Mega has 6) max frequency of each is 16 MHz, on Arduino TIMER0 is an 8- bit

More information

Physics 124: Lecture 12. Timer Basics. Timers and Scheduled Interrupts

Physics 124: Lecture 12. Timer Basics. Timers and Scheduled Interrupts Physics 124: Lecture 12 Timers and Scheduled Interrupts Timer Basics The Arduino Uno/Nano (ATMega 328) has three Hmers available to it (Arduino Mega has 6) max frequency of each is 16 MHz, (as assembled)

More information

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz IV

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz IV Department of Electrical and Computing Engineering UNIVERSITY OF CONNECTICUT ECE 3411 Microprocessor Application Lab: Fall 2015 Quiz IV There is 1 questions in this quiz. There are 15 pages in this quiz

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

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

USART Register Description

USART Register Description USART Register Description USART I/O Data Register UDR RXB[7:0] TXB[7:0] Read/Write R/W R/W R/W R/W R/W R/W R/W R/W Initial Value 0 0 0 0 0 0 0 0 UDR (Read) UDR (Write) The USART Transmit Data Buer Register

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

Features 2.4 GHz Carrier Frequency RS232 UART interface with variable baud rate Input supply voltage: 5V to 12V 255 possible Channels frequencies (0 to 255) Programmable Device Address (255 per channel)

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 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

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

COMP2121: Microprocessors and Interfacing

COMP2121: Microprocessors and Interfacing COMP2121: Microprocessors and Interfacing Lecture 25: Serial Input/Output (II) Overview USART (Universal Synchronous and Asynchronous serial Receiver and Transmitter) in AVR http://www.cse.unsw.edu.au/~cs2121

More information

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz V

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz V Department of Electrical and Computing Engineering UNIVERSITY OF CONNECTICUT ECE 3411 Microprocessor Application Lab: Fall 2015 Quiz V There are 3 questions in this quiz. There are 10 pages in this quiz

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

How to use RFpro in Packet Mode

How to use RFpro in Packet Mode How to use RFpro in Packet Mode Jumper Setting Priority Jumper J1 à Configuration Mode Jumper à Higher Priority Jumper J2 à Packet Mode Jumper à Lower Priority When both the jumpers are connected, by default,

More information

Laboratory 4 Usage of timers

Laboratory 4 Usage of timers Laboratory 4 Usage of timers 1. Timer based interrupts Beside external interrupt, the MCU responds to internal ones which are triggered by external events (on the external pins). The source of the internal

More information

Newbie s Guide to AVR Timers

Newbie s Guide to AVR Timers Newbie s Guide to AVR Timers Dean Camera November 5, 204 ********** Text Dean Camera, 203. All rights reserved. This document may be freely distributed without payment to the author, provided that it is

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

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

EE 308: Microcontrollers

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

More information

Embedded Systems Design with the Atmel AVR Microcontroller Part II

Embedded Systems Design with the Atmel AVR Microcontroller Part II Embedded Systems Design with the Atmel AVR Microcontroller Part II Synthesis Lectures on Digital Circuits and Systems Editor Mitchell A.Thornton, Southern Methodist University Embedded Systems Design

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

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

Embedded Systems and Software

Embedded Systems and Software Embedded Systems and Software Timers and Counters F-35 Lightning II Electro-optical Targeting System (EOTS Lecture 1, Slide-1 Timers and Counters Very important peripherals on microcontrollers ATtiny45

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

Overview RFSv4.3 is a RF module providing easy and flexible wireless data transmission between devices. It is based on AVR Atmega8 with serial output which can be interfaced directly to PC. Features 2.4

More information

UART: Universal Asynchronous Receiver & Transmitter

UART: Universal Asynchronous Receiver & Transmitter ECE3411 Fall 2015 Lecture 2a. UART: Universal Asynchronous Receiver & Transmitter Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: {vandijk,

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

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

CSCE 236 Embedded Systems, Spring 2012 Quiz/Test 2

CSCE 236 Embedded Systems, Spring 2012 Quiz/Test 2 CSCE 236 Embedded Systems, Spring 2012 Quiz/Test 2 Thursday, April 12, 2012 Instructions: You will have the full class period to complete this test. Make sure to show your work to ensure you receive partial

More information

ATmega128. Serial Communication (RS-232C)

ATmega128. Serial Communication (RS-232C) ATmega128 Serial Communication (RS-232C) RS-232C EIA (Electronics Industries Association) DTE (Data Terminal Equipment) DCE (Data Communication Equipment) RS-232C Signals 핀번호 (Pin No.) 명칭 (Signal Name)

More information

Newbie's Guide to AVR Timers (C) Dean Camera, 2007

Newbie's Guide to AVR Timers (C) Dean Camera, 2007 Newbie's Guide to AVR Timers (C) Dean Camera, 2007 At last! Yet another tutorial, this one covering a topic which is the main source of frustration to those new with AVRs; timers. What are they, and what

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

Introduction to Embedded Systems

Introduction to Embedded Systems Introduction to Embedded Systems Edward A. Lee UC Berkeley EECS 149/249A Fall 2016 2008-2016: E. A. Lee, A. L. Sangiovanni-Vincentelli, S. A. Seshia. All rights reserved. Chapter 10: Input and Output,

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

Interrupts Arduino, AVR, and deep dark programming secrets. What is an Interrupt?

Interrupts Arduino, AVR, and deep dark programming secrets. What is an Interrupt? Interrupts Arduino, AVR, and deep dark programming secrets What is an Interrupt? A transfer of program control that is not directed by the programmer Like a phone call in the middle of a conversation Stop

More information

Distributed Real-Time Control Systems. Chapter 10 Real-Time Digital Control

Distributed Real-Time Control Systems. Chapter 10 Real-Time Digital Control Distributed Real-Time Control Systems Chapter 10 Real-Time Digital Control 1 Real-Time Digital Control Hardware Digital Controllers are usually designed as periodic tasks with fixed period and synchronized

More information

Interrupts & Interrupt Service Routines (ISRs)

Interrupts & Interrupt Service Routines (ISRs) ECE3411 Fall 2017 Lecture 2a. Interrupts & Interrupt Service Routines (ISRs) Marten van Dijk Department of Electrical & Computer Engineering University of Connecticut Email: marten.van_dijk@uconn.edu Copied

More information

Serial Communications

Serial Communications 1 Serial Interfaces 2 Embedded systems often use a serial interface to communicate with other devices. Serial Communications Serial implies that it sends or receives one bit at a time. Serial Interfaces

More information

ATmega128 USART. Overview

ATmega128 USART. Overview USART Dual USART Overview The Universal Synchronous and Asynchronous serial Receiver and Transmitter (USART) is a highly flexible serial communication device. The main features are: Full Duplex Operation

More information

ATmega32 Reference Guide

ATmega32 Reference Guide ATmega32 Reference Guide 1 ATmega32 Reference Guide Ver. 1.0 9-20-2005 1 Features High-performance, Low-power RISC Architecture 8-bit Microcontroller 32 x 8 General Purpose Working Registers Fully Static

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

Unit 13 Timers and Counters

Unit 13 Timers and Counters Unit 13 Timers and Counters 1 2 Review of some key concepts from the first half of the semester A BRIEF SUMMARY 3 A Few Big Ideas 1 Setting and clearing bits in a register tells the hardware what do and

More information

Embedded Systems and Software. Serial Communication

Embedded Systems and Software. Serial Communication Embedded Systems and Software Serial Communication Slide 1 Using RESET Pin on AVRs Normally RESET, but can be configured via fuse setting to be general-purpose I/O Slide 2 Disabling RESET Pin on AVRs Normally

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

Embedded Systems and Software

Embedded Systems and Software Embedded Systems and Software Serial Communication Serial Communication, Slide 1 Lab 5 Administrative Students should start working on this LCD issues Caution on using Reset Line on AVR Project Posted

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

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

Supplementary Materials: Fabrication of a Lab on Chip Device Using Material Extrusion (3D Printing) and Demonstration via Malaria Ab ELISA

Supplementary Materials: Fabrication of a Lab on Chip Device Using Material Extrusion (3D Printing) and Demonstration via Malaria Ab ELISA S1 of S10 Supplementary Materials: Fabrication of a Lab on Chip Device Using Material Extrusion (3D Printing) and Demonstration via Malaria Ab ELISA Maria Bauer and Lawrence Kulinsky * 1. Program Code

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

Distributed Real- Time Control Systems. Lecture 7 Real- Time Control

Distributed Real- Time Control Systems. Lecture 7 Real- Time Control Distributed Real- Time Control Systems Lecture 7 Real- Time Control 1 Real- Time Digital Control Hardware Digital Controllers are usually designed as periodic tasks with fixed period and synchronizeda/d-

More information

Using the USART Serial Communications

Using the USART Serial Communications Using the USART Serial Communications Tutorial (c) Dean Camera, 2007. dean_camera@hotmail.com This tutorial will focus on setting up the serial USART on the AVR platform. Although other hardware AVR interfaces

More information

AN HONORS UNIVERSITY IN MARYLAND UMBC. AvrX. Yousef Ebrahimi Professor Ryan Robucci

AN HONORS UNIVERSITY IN MARYLAND UMBC. AvrX.   Yousef Ebrahimi Professor Ryan Robucci AvrX https://github.com/kororos/avrx Yousef Ebrahimi Professor Ryan Robucci Introduction AvrX is a Real Time Multitasking Kernel written for the Atmel AVR series of micro controllers. The Kernel is written

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. 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

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

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

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

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

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

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

Embedded Real-Time Systems

Embedded Real-Time Systems Embedded Real-Time Systems Reinhard von Hanxleden Christian-Albrechts-Universität zu Kiel Copyright 2008-11, Slides kindly provided by Edward A. Lee & Sanjit Seshia, UC Berkeley, All rights reserved Lecture

More information

CSCE374 Robotics Fall 2013 Notes on the irobot Create

CSCE374 Robotics Fall 2013 Notes on the irobot Create CSCE374 Robotics Fall 2013 Notes on the irobot Create This document contains some details on how to use irobot Create robots. 1 Important Documents These notes are intended to help you get started, but

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

WEATHER STATION WITH SERIAL COMMUNICATION

WEATHER STATION WITH SERIAL COMMUNICATION WEATHER STATION WITH SERIAL COMMUNICATION Written by: Wenbo Ye, Xiao Qu, Carl-Wilhelm Igelström FACULTY OF ENGINEERING, LTH Digital and Analogue Projects EITF11 Contents Introduction... 2 Requirements...

More information

Introduction to Embedded Systems

Introduction to Embedded Systems Introduction to Embedded Systems UsingANSICand the Arduino Development Environment David J. Russell University of NebraskaLincoln SYNTHESIS LECTURES ONDIGITAL CIRCUITSAND SYSTEMS #30 xi Preface Introduction

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

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

Use a semaphore to avoid the enqueue and dequeue functions from accessing and modifying count variable at the same time.

Use a semaphore to avoid the enqueue and dequeue functions from accessing and modifying count variable at the same time. Goal: In this project you will create an OS-driven multitasking device than can capture data at precise intervals, buffer the data to EEPROM, and send data over a serial interface to a computer, while

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

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

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

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

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

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

Lampiran. Universitas Sumatera Utara

Lampiran. Universitas Sumatera Utara Lampiran LISTING PROGRAM #include #include // Declare your global variables here char buff[16]; unsigned int frekuensi,x; unsigned int detak; // External Interrupt 0 service routine

More information

UART. Embedded RISC Microcontroller Core Peripheral

UART. Embedded RISC Microcontroller Core Peripheral Features New Enhanced Baud Rate Generator Generates Any Required Baud Rate Maximum 6 Mbps (0.35 µm) High Baud Rates at Low Crystal Clock Frequencies 6-, 7-, 8- or 9-bit Data Noise Filtering and Noise Error

More information

ECE 353 Lab 4. General MIDI Explorer. Professor Daniel Holcomb Fall 2015

ECE 353 Lab 4. General MIDI Explorer. Professor Daniel Holcomb Fall 2015 ECE 353 Lab 4 General MIDI Explorer Professor Daniel Holcomb Fall 2015 Where are we in Course Lab 0 Cache Simulator in C C programming, data structures Cache architecture and analysis Lab 1 Heat Flow Modeling

More information

SquareWear Programming Reference 1.0 Oct 10, 2012

SquareWear Programming Reference 1.0 Oct 10, 2012 Content: 1. Overview 2. Basic Data Types 3. Pin Functions 4. main() and initsquarewear() 5. Digital Input/Output 6. Analog Input/PWM Output 7. Timing, Delay, Reset, and Sleep 8. USB Serial Functions 9.

More information

Introduction. Unit 4. Numbers in Other Bases in C/C++ BIT FIDDLING. Microcontrollers (Arduino) Overview Digital I/O

Introduction. Unit 4. Numbers in Other Bases in C/C++ BIT FIDDLING. Microcontrollers (Arduino) Overview Digital I/O 4.1 4.2 Introduction Unit 4 Microcontrollers () Overview Digital I/O The primary way that software controls hardware is by manipulating individual bits We need to learn how to: Set a bit to a 1 Clear a

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

// Voltage Reference: AREF pin #define ADC_VREF_TYPE ((0<<REFS1) (0<<REFS0) (0<<ADLAR))

// Voltage Reference: AREF pin #define ADC_VREF_TYPE ((0<<REFS1) (0<<REFS0) (0<<ADLAR)) 44 Lampiran 1 Listing program dari seluruh sistem. /****************************************************** * This program was created by the CodeWizardAVR V3.12 Advanced Automatic Program Generator Copyright

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

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

Chapter 2. Overview of Architecture and Microcontroller-Resources

Chapter 2. Overview of Architecture and Microcontroller-Resources Chapter 2 Overview of Architecture and Microcontroller-Resources Lesson 4 Timers, Real Time Clock Interrupts and Watchdog Timer 2 Microcontroller-resources Port P1 Port P0 Port P2 PWM Timers Internal Program

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

C Language Programming, Interrupts and Timer Hardware

C Language Programming, Interrupts and Timer Hardware C Language Programming, Interrupts and Timer Hardware In this sequence of three labs, you will learn how to write simple C language programs for the MC9S12 microcontroller, and how to use interrupts and

More information

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz III

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz III Department of Electrical and Computing Engineering UNIVERSITY OF CONNECTICUT ECE 3411 Microprocessor Application Lab: Fall 2015 Quiz III There are 5 questions in this quiz. There are 11 pages in this quiz

More information

CSCE 236 Embedded Systems, Fall 2017 Homework 5

CSCE 236 Embedded Systems, Fall 2017 Homework 5 CSCE 236 Embedded Systems, Fall 2017 Homework 5 Started: Tuesday, November 7th, 2017 Due: Friday, November 17th, 2017 (5pm) Instructions: This homework is an individual assignment, collaboration is not

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

Infineon C167CR microcontroller, 256 kb external. RAM and 256 kb external (Flash) EEPROM. - Small single-board computer (SBC) with an

Infineon C167CR microcontroller, 256 kb external. RAM and 256 kb external (Flash) EEPROM. - Small single-board computer (SBC) with an Microcontroller Basics MP2-1 week lecture topics 2 Microcontroller basics - Clock generation, PLL - Address space, addressing modes - Central Processing Unit (CPU) - General Purpose Input/Output (GPIO)

More information

L A M P I R A N UNIVERSITAS KRISTEN MARANTHA

L A M P I R A N UNIVERSITAS KRISTEN MARANTHA L A M P I R A N LAMPIRAN B LISTING PROGRAM MIKROKONTROLER //Simplest universal VGA(20x20)/PAL(38x20) terminal //For sync used Timer0 Timer1 //To avoid flickering while receive UART data,recommend

More information