ECTE333: Digital Hardware 2 7 L10: Pulse Width Modulator .

2y ago
8 Views
2 Downloads
304.89 KB
14 Pages
Last View : 13d ago
Last Download : 3m ago
Upload by : Cade Thielen
Transcription

ECTE333 Spring 2010 ScheduleWeek1Lecture (2h)711Lab 8Tutorial 9Lab 9Tutorial 10Lab 10Tutorial 11Lab 11L11: Analogue-to-digital converter10School of Electrical, Computer and Telecommunications EngineeringUniversity of WollongongAustraliaTutorial 8L10: Pulse width modulator89Lab 7L9: Timers6ECTE333: Digital Hardware 2Lecture 9 - TimersTutorial 7L8: Serial communications45Lab (2h) (5%)L7: C programming for the ATMEL AVR23Tutorial (1h)Class Test 2 (1h, worth 5%)1213Lab 12L13: Revision lectureLab report (5%)Final exam (25%) & Practical exam (10%)Lam PhungLecture 9 references University of Wollongong, 2010.2Lecture 9 referencesM. Mazidi, J. Mazidi, R. McKinlay, “The 8051 microcontroller andembedded systems using assembly and C,” 2nd ed., PearsonPrentice Hall, 2006, [Chapters 9].J. Pardue, C Programming for Microcontrollers, 2005, SmileyMicros,[Chapter 7: Interrupts ].Atmel Corp., 8-bit AVR microcontroller with 16K Bytes In-SystemProgrammable Flash ATmega16/ATmega16L, 2007,M. Mazidi and J. Mazidi, “The 8086 IBM PC and compatiblecomputers,” 4th ed., Pearson Prentice Hall, 2003, [Chapters 13].[Interrupts], [External Interrupts] and [Timers].P. Spasov, “Microcontroller technology the 68HC11,” 3rd ed.,Prentice Hall, 1999, [Chapters 11].S. F. Barrett and D. J. Pack, Atmel AVR Microcontroller Primer:Programming and Interfacing, 2008, Morgan & Claypool Publishers,[Chapter 5: Timing Subsystem].Lam Phung University of Wollongong, 2010.H. Huang, “MC68HC12 an introduction: software and hardwareinterfacing,” Thomson Delmar Learning, 2003, [Chapter 8].3Lam Phung University of Wollongong, 2010.4

Lecture 9’s sequence9.1 Interrupt programming in C for ATmega16In Semester I, we learnt9.1 the interrupt-driven approach and the ATmega8515,Interrupt programming in C for ATmega16 writing an interrupt-driven program in the assembly language.In this lecture, we will learn9.2 the interrupt subsystem in the ATmega16,Timers in ATmega169.3 writing an interrupt-driven program in C.Compared to polling, interrupt is a more efficient approach for the CPUto handle peripheral devices, e.g.Timer applications serial port, external switches, timers, PWM and ADC.5 University of Wollongong, 2010.Lam PhungPolling versus Interruptget device status;if (service required){}normal execution;}normal executionInterruptwhile (1){ University of Wollongong, 2010.6Interrupt execution sequencePollingservice routine;Lam Phung1. A device issues an interruptinterruptsignal2. CPU finishes the current instructioninstruction krunsinterruptserviceroutine3. CPU acknowledges the interruptinstruction k 14. CPU saves its states and PC onto stack5. CPU loads the address of ISR onto PCUsing polling, the CPU must continually check the device’s status.6. CPU executes the ISRUsing interrupt: A device will send an interrupt signal when needed.7. CPU retrieves its states and PC from stack In response, the CPU will perform an interrupt service routine,and then resume its normal execution.Lam Phung University of Wollongong, 2010.8. Normal execution resumes7Lam Phung University of Wollongong, 2010.8

ATmega16 interrupt subsystemATmega16 interrupt subsystem: Complete listTable 9.1: Interrupts in ATmega16.The ATmega16 has 21 interrupts: 1 reset interrupt 3 external interrupts 8 timer interrupts 3 serial port interrupts 1 ADC interrupt 1 analogue comparator interrupt 1 SPI interrupt 1 TWI interrupt 2 memory interruptsLam Phung University of Wollongong, 2010.9ATmega16 interrupt subsystem: Complete listVector No.Program Address1 000Interrupt vector nameRESET vectDescriptionReset2 002INT0 vectExternal Interrupt Request 03 004INT1 vectExternal Interrupt Request 14 006TIMER2 COMP vectTimer/Counter2 Compare Match5 008TIMER2 OVF vectTimer/Counter2 Overflow6 00ATIMER1 CAPT vectTimer/Counter1 Capture Event7 00CTIMER1 COMPA vectTimer/Counter1 Compare Match A8 00ETIMER1 COMPB vectTimer/Counter1 Compare Match B9 010TIMER1 OVF vectTimer/Counter1 Overflow10 012TIMER0 OVF vectTimer/Counter0 Overflow11 014SPI STC vectSerial Transfer Complete12 016USART RXC vectUSART, Rx Complete13 018USART UDRE vectUSART Data Register Empty14 01AUSART TXC vectUSART, Tx Complete15 01CADC vectADC Conversion Complete16 01EEE RDY vectEEPROM Ready17 020ANA COMP vectAnalog Comparator18 022TWI vect2-wire Serial Interface19 024INT2 vectExternal Interrupt Request 220 026TIMER0 COMP vectTimer/Counter0 Compare Match21 028SPM RDY vectStore Program Memory ReadyLam Phung University of Wollongong, 2010.10Steps to program an interrupt in CFor Table 9.1,To program an interrupt in C, five steps are required.1. Include header file avr\interrupt.h .Vector No An interrupt with a lower ‘Vector No’ will have a higher priority.2. Use C macro ISR() to declare the interrupt handler and update IVT. E.g., INT0 has a higher priority then INT1 and INT2.3. Enable the specific interrupt.4. Configure details about the interrupt by setting relevant registers.Program Address5. Enable the interrupt subsystem globally using sei(). The fixed memory location for a given interrupt handler. E.g., in response to interrupt INT0, CPU runs instruction at 002.Later, we’ll study steps for interrupt programming in C, via 2 examples.9.1.1 USART RXD Complete interruptInterrupt Vector Name9.1.2 External interrupts This is the interrupt name, to be used with C macro ISR().Lam Phung University of Wollongong, 2010.11Lam Phung University of Wollongong, 2010.12

Using C macro ISR()Learning ATmega16 interruptsVector No.The C macro ISR() is used to declare the handler for a given interrupt.It basic syntax is given asISR(interrupt vector name){// code for interrupt handler here}where interrupt vector name is given in Table 9.1.Example: To process interrupt 'RXD Complete’ and put the receivedcharacter in Port B, we writeISR(USART RXC vect){PORTB UDR;// put received character in port B}Lam Phung University of Wollongong, 2010.139.1.1 Serial RXD interruptInterrupt vector nameDescription1RESET vectReset2INT0 vectExternal Interrupt Request 03INT1 vectExternal Interrupt Request 14TIMER2 COMP vectTimer/Counter2 Compare Match5TIMER2 OVF vectTimer/Counter2 Overflow6TIMER1 CAPT vectTimer/Counter1 Capture Event7TIMER1 COMPA vectTimer/Counter1 Compare Match A8TIMER1 COMPB vectTimer/Counter1 Compare Match B9TIMER1 OVF vectTimer/Counter1 Overflow10TIMER0 OVF vectTimer/Counter0 Overflow11SPI STC vectSerial Transfer Complete12USART RXC vectUSART, Rx Complete13USART UDRE vectUSART Data Register Empty14USART TXC vectUSART, Tx Complete15ADC vectADC Conversion Complete16EE RDY vectEEPROM Ready17ANA COMP vectAnalog Comparator18TWI vect2-wire Serial Interface19INT2 vectExternal Interrupt Request 220TIMER0 COMP vectTimer/Counter0 Compare Match21SPM RDY vectStore Program Memory Ready14 University of Wollongong, 2010.Lam PhungSerial RXD interrupt: EnablingRXCIEWrite a C interrupt-driven program to use the serial port of ATmega16TXCIEUDRIERXENTXENUCSZ2RXB8TXB8Register UCSRB 0b10011000Tx extra data bit for 9-bit character sizeat baud rate 1200, no parity, 1 stop bit, 8 data bits, clock speed 1MHz.Rx extra data bit for 9-bit character sizeWhenever a character is received, it should be sent to Port B.bit 2 to decide character size1 to enable USART transmitter: Pin D.1 TXD pinThe serial port on ATmega16 can trigger an RXD interrupt whenever a1 to enable USART receiver:character is received [Lecture 8].Pin D.0 RXD pin1 to enable USART Data Register Empty Interrupt1 to enable TX Complete Interrupt, valid only if Global Interrupt Flag 1 and TXC 1We enable this interrupt by setting a flag in a serial port register.1 to enable RX Complete Interrupt, valid only if Global Interrupt Flag 1 and RXC 1We then need to write the interrupt handler, to be run whenever theFor any interrupt, the ATmega16 manual can be searched to learn howinterrupt is triggered.to enable the interrupt.E.g., for serial RXD interrupt, we look at ‘USART’ section.Lam Phung University of Wollongong, 2010.15Lam Phung University of Wollongong, 2010.16

Serial RXD interrupt: serial int.cSerial RXD interrupt: Testing#include avr/io.h #include avr/interrupt.h Writea C theinterrupt-drivenprogramto toggle port B whenever a switchTo testserial RXD interruptexample:on the STK500 board is pressed. The program should use an external Connect RXD pin (pin D.0) to RXD pin of RS232 Spare.interrupt. Connect TXD pin (pin D.1) to TXD pin of RS232 Spare.void USART init(void){// Normal speed, disable multi-procUCSRA 0b00000000;// Enable Tx and Rx pins, enable RX interruptUCSRB 0b10011000; Connect Port B to LED connector.// Asynchronous mode, no parity, 1 stop bit, 8 data bitsUCSRC 0b10000110; Compile, download program.// Baud rate 1200bps, assuming 1MHz clockUBRRL 0x33; UBRRH 0x00; Connect RS232 Spare Connector to Serial Port of PC.} Configure and run HyperTerminal and use it to send characters.ISR(USART RXC vect){ // Handler for RXD interruptPORTB UDR;// Received character is displayed on port B}int main(void) {USART init();sei();DDRB 0xFF;while (1) {;}return 0;}////////Lam Phunginitialise USARTenable interrupt subsystem globallyset port B for outputinfinite loop University of Wollongong, 2010.Video demo link: [avr]/ecte333/serial int.mp4avr http://www.elec.uow.edu.au/avr17Serial RXD Polling approach18Externalinterrupts on ATmega16andATmega8515are similar.Writea C interrupt-drivenprogram totoggleport B whenevera switch#include avr/io.h on the STK500 board is pressed. The program should use an externalKey references on ATmega16 external interrupts: ATmega16 userinterrupt.manual, ‘External Interrupts’ section.void USART init(void){// Normal speed, disable multi-procUCSRA 0b00000000;// Enable Tx and Rx, disable interruptsUCSRB 0b00011000;Three external interrupts can be triggered.// Asynchronous mode, no parity, 1 stop bit, 8 data bitsUCSRC 0b10000110; INT0 on pin D.2,// Baud rate 1200bps, assuming 1MHz clockUBRRL 0x33; UBRRH 0x00; INT1 on pin D.3,} INT2 on pin B.2.int main(void) {USART init(); // initialise USARTDDRB 0xFF; // set port B for outputwhile (1) {// infinite loop// Poll until RXC flag 1while ((UCSRA & (1 RXC)) 0x00){;}PORTB UDR; // received character is displayed on port B}return 0;} University of Wollongong, 2010. University of Wollongong, 2010.9.1.2 External interruptsFor comparison, the program below uses polling for the same effect.Lam PhungLam PhungKey steps in using external interrupts. enable the interrupt, specify what types of event will trigger the interrupt.19Lam Phung University of Wollongong, 2010.20

External Interrupts Relevant pinsExternal interrupts: EnablingTo enable an external interrupt, set a flag in General Interrupt ControlRegister (GICR).Read/WriteInitial W0R/W0Example: to enable INT1 on pin D.3, we can writeGICR (1 INT1);Note that INT1 and GICR names are already defined in avr/io.h .21 University of Wollongong, 2010.Lam PhungExternal interrupts: Specifying eventsR/W0R/W0SM2SER/W0SM1R/ W0SM0 University of Wollongong, 2010.22External interrupts: ExampleTo specify the type of events that triggers an external interrupt, setMCU Control Register or MCU Control and Status Register.Read/WriteInitial valueLam PhungR/W0R/W0R/W0R/W0ISC11ISC10ISC01ISC00Write a C interrupt-driven program to toggle port B whenever a switchon the STK500 board is pressed. The program should use an externalinterrupt.MCUCRLet us use interrupt INT1. This interrupt is triggered on pin D.3.To enable interrupt INT1GICR (1 INT1);To specify that INT1 is triggered on any change in pin D.3Read/WriteInitial valueR/W0JTDR/W0ISC2R/W0-R/ W0JTRFR/W0R/W0R/W0R/W0WDRFBORFEXTRFPORFMCUCR (1 ISC10);MCUCSRWe then write interrupt handler and enable interrupt subsystem globallyas usual.0: falling edge generates an interrupt INT21: rising edge generates an interrupt INT2Lam Phung University of Wollongong, 2010.23Lam Phung University of Wollongong, 2010.24

External interrupts: ext int.cExternal interrupts: Testing ext int.c#include avr/io.h Writea C theinterrupt-drivenprogramto toggle port B whenever a switchTo testexternal interruptexample:on the STK500 board is pressed. The program should use an external Connect INT1 pin (pin D.3) to switch SW7 on STK500 board.interrupt. Connect GRD pin of Port D to GRD pin of SW connector.#include avr/interrupt.h ISR(INT1 vect){PORTB ( PORTB);// handler for INT1 interrupt// toggle port B Connect Port B to LED connector.} Compile, download program.int main(void) { Press switch SW7.GICR (1 INT1); // enable interrupt INT1MCUCR (1 ISC10); // triggered on any change to INT1 pin (D.3)sei();// enable interrupt subsystem globallyDDRB 0xFF;// set port B for outputVideo demo link: [avr]/ecte333/ext int.mp4PORTB 0b10101010; // initial valuewhile (1) {;}// infinite loopreturn 0;}Lam Phung University of Wollongong, 2010.259.2 Timers in ATmega16Lam Phung University of Wollongong, 2010.26Timer terminologyMany computer applications require accurate timing.Input Capture: An input signal is connected to a pin, designated as input capturepin, of the timer.Examples include When a preset event (rising edge, falling edge, change) occurs onthe input capture pin, the current value of the timer is stored in aregister. recording the time when an event occurs, calculating the time difference between events, performing tasks at specific or periodic time instants, creating accurate time delays,Output Compare: generating waveforms of certain shape, period or duty cycle. A timer usually has a pin designated as output compare pin. When the timer reaches a preset value, the output compare pin canbe automatically changed to logic 0 or logic 1.Lecture 9 and Lecture 10 focus on the use of timers to perform theabove time-related processing.Lam Phung University of Wollongong, 2010.27Lam Phung University of Wollongong, 2010.28

Overview of Timers in ATmega16Overview of Timers in ATmega16When the internal system clock is used, a prescaler can be used makeATmega16 has three timers: Timer 0, Timer 1 and Timer 2.the timer count at a slower rate.Each timer is associated with a counter and a clock signal.Example:The counter is incremented by 1 in every period of the timer’s clocksignal. Suppose the system clock rate 1Mhz (1μs per cycle). Suppose a timer prescaler of 64 is used.The clock signal of a timer can come from Then, timer will increment every 64μs. the internal system clock or an external clock source.29 University of Wollongong, 2010.Lam PhungOverview of Timers in ATmega16Timer 0OverallLam Phung University of Wollongong, 2010.30Study planTimer 1Timer 2In Lecture 9, we focus on- 8-bit counter- 16-bit counter- 8-bit counter- 10-bit prescaler- 10-bit prescaler- 10-bit prescaler- PWM- PWM- PWM- Frequency generation- Frequency generation- Frequency generation- Event counter- Event counter- Event counter measuring time, creating time delay,- Output compare- Output compare: 2- Output compare measuring period/duty cycle of a signal, operations of Timer 1, using Timer 1 overflow interrupt,Functions using Timer 1 input capture interrupt,channels information required for Lab 9.- Input captureOperationmodes- Normal mode- Normal mode- Normal mode- Clear timer on- Clear timer on- Clear timer oncompare matchcompare matchIn Lecture 10, we will learn using Timer 1 output compare interrupt,compare match- Fast PWM- Fast PWM- Fast PWM- Phase correct PWM- Phase correct PWM- Phase correct PWM generating PWM signals, information required for Lab 10.Timer 1 has the most capability among the three timers.Lam Phung University of Wollongong, 2010.31Lam Phung University of Wollongong, 2010.32

Timer 1: An overviewTimer 1: Block diagram16-bit counter.External clockpinCurrent timer/counter value10-bit prescaler: 8, 64, 256, 1024Output Comparepinscan trigger a timer overflow interrupt when counter reaches MAX.Output CompareRegisterscan trigger an input capture interrupt when an event occurs on theinput capture pin. timer value is stored automatically in a register. input capture pin for Timer 1 is ICP1 (D.6).Input Capture registercan trigger an output compare match interrupt when timer reaches apreset value.Input Capture pinTimer/CounterControl Registers There are two independent output compare channels A and B.Not shown here: TIMSK and TIFR registersLam Phung University of Wollongong, 2010.33Timer 1 Relevant pinsLam Phung University of Wollongong, 2010.34Timer 1 Five groups of registers1) Timer/Counter 1 TCNT1 16-bit register that stores the current value of the timer.2) Timer/Counter 1 Control Registers TCCR1A and TCCR1B To configure the operations of Timer 1.3) Input Capture Register ICR1 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.5) Output Compare Registers OCR1A, OCR1B To store the preset values for output compare.used in thislectureLam Phung University of Wollongong, 2010.35Lam Phung University of Wollongong, 2010.36

Timer 1 Five groups of registers9.2.1 Timer/Counter 1 Control Register A (TCCR1A)76543210COM1A1 COM1A0 COM1B1 COM1B0 FOC1A FOC1B WGM11 WGM10Specify Waveform Generation Modeused with WGM13, WGM12WGM13.WGM10 0000 for normal mode.1 to force output compare on channel B1 to force output compare on channel AOutput compare mode for channel BOutput compare mode for channel A University of Wollongong, 2010.Lam Phung379.2.2 Timer/Counter 1 Control Register B (TCCR1B)765ICNC1ICES1-43WGM13 WGM12210CS12CS11CS10Lam Phung University of Wollongong, 2010.38Clock selectclock select (next slide)select Waveform Generation Mode, used with WGM11, WGM10WGM13.WGM10 0000 for normal mode.input capture edge select: 1 will select rising edge, 0 will select falling edgeFor ATmega16, the internal clock is set by default at clkI/O 1MHz.Timer 1 can run using the internal or external clock.1 to activate input capture noise cancellerIf using the internal clock, we can set Timer 1 to run at a speed that is8, 64, 256 or 1024 times slower than the internal clock.Lam Phung University of Wollongong, 2010.39Lam Phung University of Wollongong, 2010.40

9.2.3 Timer/Counter Interrupt Mask Register (TIMSK)76OCIE2TOIE25432TICIE1 OCIE1A OCIE1B TOIE110OCIE0TOIE09.2.4 Timer/Counter Interrupt Flag Register (TIFR)765OCF2TOV2ICF143OCF1A OCF1B210TOV1OCF0TOV0For Timer 0For Timer 0Timer 1 Overflow Interrupt EnableTimer 1 Overflow Interrupt Flag: set to 1 when overflowTimer 1 Output Compare B Match Interrupt Enable: 1 to enableTimer 1 Output Compare B Match Flag: set to 1 when matchTimer 1 Output Compare A Match Flag: set to 1 when matchTimer 1 Output Compare A Match Interrupt Enable: 1 to enableTimer 1 Input Capture Flag: set to 1 when capture event occursTimer 1 Input Capture Interrupt Enable: 1 to enableFor Timer 2For Timer 2This register has flags that indicate when a timer interrupt occurs. University of Wollongong, 2010.Lam Phung419.3 Timer applicationsLam Phung University of Wollongong, 2010.429.3.1 Creating an accurate delayWrite a C program for ATmega16 to toggle PORTB every 2 seconds.In this section, we consider three applications of Timer 1.It should use timer 1 overflow interrupt to create delays of 2s each.9.3.1 Creating an accurate delay using timer overflow interrupt.Analysis Internal system clock: 1MHz. With no prescaler, Timer 1 will increment every 1 μs.9.3.2 Measuring elapsed time between two events. Because Timer 1 is 16-bit counter, it will overflow every 216 μs. To have a 2s delay, we need Timer 1 to overflow for 2s/216 μs 31times.9.3.3 Measuring the period of a square signal using input captureinterrupt.Coding Write code to enable & intercept Timer 1 overflow interrupt. Use interrupt handler to count the number of overflows. When number of overflows 31, toggle port B.Lam Phung University of Wollongong, 2010.43Lam Phung University of Wollongong, 2010.44

Creating an accurate delay: timer delay.c9.3.2 Measuring elapsed time#include avr/io.h #include avr/interrupt.h To measure a time interval using Timer 1, we must keep track of bothvolatile int overflow count; the number of times that Timer 1 has overflowed: nISR(TIMER1 OVF vect){// handler for Timer1 overflow interruptoverflow count ;// increment overflow countif (overflow count 31){ // when 2s has passedoverflow count 0;// start new countPORTB PORTB;// toggle port B}} the current counter value:If we reset n and TCNT1 at the beginning of the interval, then thetime elapse is (assuming no prescaler, 1MHz clock)t n x 65536 TCNT1 (μs)int main(void) {DDRB 0xFF;// set port B for outputPORTB 0x00;// initial value of PORTBoverflow count 0; // initialise overflow countTCCR1A 0b00000000; // normal modeTCCR1B 0b00000001; // no prescaler, internal clockTimer OverflowsTCNT1n 0TCNT1 0TIMSK 0b00000100; // enable Timer 1 overflow interruptsei();// enable interrupt subsystem globallywhile (1){;}return 0;TCNT112ntime interval t// infinite loopstart at time t1stop at time t2}Lam Phung University of Wollongong, 2010.45Measuring elapsed timeLam Phung University of Wollongong, 2010.46Measuring elapsed time: measure time.c#include avr/io.h #include avr/interrupt.h #include inttypes.h Use Timer 1 to measure the execution time of some custom C code.volatile uint32 t n;ISR(TIMER1 OVF vect){// handler for Timer1 overflow interruptn ;// increment overflow count}int main(void) {int i, j;uint32 t elapse time;Approach: Clear Timer 1 when the code starts. Record Timer 1 when the code finishes.TCCR1A 0b00000000; // normal modeTCCR1B 0b00000001; // no prescaler, internal clockTIMSK 0b00000100; // enable Timer 1 overflow interrupt Also, use Timer 1 Overflow Interrupt to keep track of how manytimes it has overflowed.n 0;// reset nTCNT1 0;// reset Timer 1sei();// enable interrupt subsystem globally// ----- start code -------------for (i 0; i 100; i )for (j 0; j 1000; j ){;}// ----- end code ----------------elapse time n * 65536 (uint32 t) TCNT1;cli();// disable interrupt subsystem globallyreturn 0;}Lam Phung University of Wollongong, 2010.47Lam Phung University of Wollongong, 2010.48

9.3.3 Measuring period of a square signalMeasuring period of a square signalAssumption: the input signal has a high frequency, hence timeroverflow can be ignored.Use Timer 1 input capture interrupt to measure the period of a squaresignal.Analysis:Implementation: The period of a square wave the time difference betweentwo consecutive rising edges. Select timer operations: normal, no prescaler, internal clock 1MHz,noise canceller enabled, input capture for rising edges. Connect the square wave to input capture pin of Timer 1.TCCR1A 0b00000000; Configure input capture module to trigger on a rising edge.TCCR1B 0b00000001;Input capture interrupt is triggered.Read ICR1 register.Input capture interrupt is triggered.Read ICR1 register again.periodLam Phung Enable input capture interrupt:TIMSK 0b00100000;square waveform University of Wollongong, 2010.49measure period.c University of Wollongong, 2010.50Testing measure period.c#include avr/io.h #include avr/interrupt.h #include inttypes.h Writea C theinterrupt-drivenprogramto toggle port B whenever a switchTo testcode for measuringperiod:on the STK500 board is pressed. The program should use an external Connect Input Capture pin (D.6) to square wave generator oninterrupt.WishMaker.uint16 t period;ISR(TIMER1 CAPT vect){period ICR1;TCNT1 0;PORTB (period }Lam Phung// handler for Timer1 input capture interrupt// period value of Timer 1 stored in ICR1// reset Timer 18); // display top 8-bit of period on PORT B Connect GRD pin of Port D to GRD pin of WishMaker. Connect Port B to LED connector. Compile, download program.int main(void) {DDRB 0xFF; Change frequency of square ware and observe output on LEDs.// set port B for outputTCCR1A 0b00000000;TCCR1B 0b11000001;TIMSK 0b00100000;sei();while (1){;}return 0;//////////normal modeno prescaler, rising edge, noise cancellerenable Timer 1 input capture interruptenable interrupt subsystem globallyinfinite loopVideo demo link: [avr]/ecte333/measure period.mp4}Lam Phung University of Wollongong, 2010.51Lam Phung University of Wollongong, 2010.52

Extending measure period.cSummaryWhat we learnt in this lecture:The code given here assumes that there is no timer overflow betweentwo rising edges of the square signal. How to write an interrupt-driven program in C for ATmega16. Programming serial and external interrupts in C. Overview of timers in ATmega16.In Lab 9, you are required to extend the code so that a correct period ismeasured for low-frequency signals. Using Timer1 overflow and input capture interrupts in 3 applications.What are next activities? Tutorial 9: ‘Timers’.It is necessary to intercept timer overflow (as in Examples 9.3.1 and9.3.2). Lab 9: ‘Timers’ Complete the online Pre-lab Quiz for Lab 9.The measure period should also be sent through the serial port to PCfor testing.Lam Phung University of Wollongong, 2010.53 Write programs for Tasks 1 and 2 of Lab 9. See video demos of Lab 9: [avr]/ecte333/lab09 task1.mp4[avr]/ecte333/lab09 task2.mp4Lam Phung University of Wollongong, 2010.54

Later, we’ll study steps for interrupt programming in C, via 2 examples. 9.1.1 USART RXD Complete interrupt 9.1.2 External interrupts 1. Include header file avr\interrupt.h . 2. Use C macro ISR() to declare the interrupt handler and update IVT. 3. Enable the specific interrupt. 4. Configure details abo

Related Documents:

- HARDWARE USER MANUAL - MANUEL DE L'UTILISATEUR HARDWARE . - HARDWAREHANDLEIDING - MANUALE D'USO HARDWARE - MANUAL DEL USUARIO DEL HARDWARE - MANUAL DO UTILIZADOR DO HARDWARE . - 取扱説明書 - 硬件用户手册. 1/18 Compatible: PC Hardware User Manual . 2/18 U.S. Air Force A -10C attack aircraft HOTAS (**) (Hands On Throttle And .

Class- VI-CBSE-Mathematics Knowing Our Numbers Practice more on Knowing Our Numbers Page - 4 www.embibe.com Total tickets sold ̅ ̅ ̅̅̅7̅̅,707̅̅̅̅̅ ̅ Therefore, 7,707 tickets were sold on all the four days. 2. Shekhar is a famous cricket player. He has so far scored 6980 runs in test matches.

Digital inclusion is defined in various ways and is often used interchangeably with terms such as digital skills, digital participation, digital competence, digital capability, digital engagement and digital literacy (Gann, 2019a). In their guide to digital inclusion for health and social care, NHS Digital (2019) describe digital

Digital Media Middle East & Middle Eastern Digital Media Awards 29-30 Nov 2022 Riyadh Digital Media Africa & African Digital Media Awards 12-13 July 2022 Virtual Digital Media LATAM & LATAM Digital Media Awards 16-18 Nov 2022 Mexico City Digital Media India & Indian Digital Media Awards 08-10 Mar 2022 Virtual Digital Media Asia &

3. Mounting Hardware: a. Use mounting hardware that came with the TV, or b. If the TV did not come with mounting hardware, select from included Bolts and Washers (see Parts List on page 7). WARNING! To prevent serious injury, do not use hardware that does not match the TV's hardware, that is too long or too short, or overtighten the hardware.

IT hardware, and only 17 percent actually inventory all IT hardware. On average, about 76 percent of an organiza-tion's IT hardware is inventoried. Any IT hardware that's not inventoried is either intentional (by design) or the result of poorly enforced policies. The scope of IT hardware encompasses a wide range

by software. Commodity hardware devices, such as Mel-lanox NICs and P4 Switches, support both putting a hardware counter to every flow and sampling the hardware traffic to software. The cost of using hardware counters for flow rate measurement is very high (more discussion in Section2). If sampling a portion of the hardware traffic to .

Hacker/Sommers, A Writer’s Reference, 7th ed. (Boston: Bedford, 2011) Slide 2 of 11 Sample MLA Research Paper Summary and long quotation are each introduced with a signal phrase naming the author. Long quotation is set off from the text; quotation marks are omitted. Page number is given in parentheses after the final period. Marginal annotations indicate MLA-style formatting and effective .