Download: 8-bit RISC Microcontoller Application Note AVR130: Setup and Use the AVR® Timers Features

8-bit RISC Microcontoller Application Note Rev. 2505A–AVR–02/02 AVR130: Setup and Use the AVR® Timers Features • Description of Timer/Counter Events • Timer/Counter Event Notification • Clock Options • Example Code for Timer0 – Overflow Interrupt • Example Code for Timer1 – Input Capture Interrupt • Example Code for Timer2 – Asynchronous Operation – Compare Match Interrupt • PWM Basics • Example Code for PWM Operation of Timer2 Introduction This application note describes how to use the different timers of the AVR. The AT90S8535 is used as an example. The intention of this document is to give ...
Author: Walway Shared: 8/19/19
Downloads: 676 Views: 2885

Content

8-bit

RISC Microcontoller Application Note

Rev. 2505A–AVR–02/02

AVR130: Setup and Use the AVR® Timers Features

• Description of Timer/Counter Events • Timer/Counter Event Notification • Clock Options • Example Code for Timer0 – Overflow Interrupt • Example Code for Timer1 – Input Capture Interrupt • Example Code for Timer2 – Asynchronous Operation – Compare Match Interrupt • PWM Basics • Example Code for PWM Operation of Timer2

Introduction

This application note describes how to use the different timers of the AVR. The AT90S8535 is used as an example. The intention of this document is to give a general overview of the timers, show their possibilities and explain how to configure them. The code examples will make this clearer and can be used as guidance for other applications. Starting from a general overview of the timers, several examples will show how the timers work and how they are configured. Experienced users can start directly with the section “Setting Up the Timers” on page 7. The last section is a short description of the PWM mode. Additional information can be found in the data sheets and in application notes where the timers are used.

General Description

In principle, a timer is a simple counter. Its advantage is that the input clock and oper- ation of the timer is independent of the program execution. The deterministic clock makes it possible to measure time by counting the elapsed cycles and take the input frequency of the timer into account.

Why Different Timers

The answer is quite simple: To have the right timer for the right application and to have enough resources to do this. Generally, the 90S- and megaAVRs have two 8-bit and one 16-bit timer. A timer with 16-bit resolution is certainly more flexible to use than one with 8-bit resolution. How- ever, the saying “bigger is better” does not necessarily apply to the microcontroller world. For many applications, it is sufficient to have 8-bit resolution. Using a higher resolution means a larger program overhead, which costs processing time and should be avoided in speed optimized code. It also means higher device cost., Because of the flexibility of the AVR timers, they can be used for different purposes. The number of timers determines the amount of independent configurations. In the following, the different configuration options will be described more closely.

Timer Events The timer of the AVR can be specified to monitor several events. Status flags in the

TIMSK register show if an event has occurred. The AT90S8535 can be configured to monitor up to three events per timer. Timer Overflow A timer overflow means that the counter has counted up to its maximum value and is reset to zero in the next timer clock cycle. The resolution of the timer determines the maximum value of that timer. There are two timers with 8-bit resolution and one timer with 16-bit resolution on the AT90S8535. The maximum value a timer can count to can be calculated by Equation 1. Res is here the resolution in bits. MaxVal = 2Res – 1 (1) The timer overflow event causes the Timer Overflow Flag (TOVx) to be set in the Timer Interrupt Flag Register (TIFR). Compare Match In cases where it is not sufficient to monitor a timer overflow, the compare match inter- rupt can be used. The Output Compare Register (OCRx) can be loaded with a value [0 .. MaxVal] which the timer will be checked against every timer cycle. When the timer reaches the compare value, the corresponding Output Compare Flag (OCFx) in the TIFR register is set. The Timer can be configured to clear the count register to “0” on a compare match. Related output pins can be configured to be set, cleared or toggled automatically on a compare match. This feature is very useful to generate square wave signals of different frequencies. It offers a wide range of possibilities which makes it possible to implement a DAC. The PWM mode is a special mode which is even better suited for wave genera- tion. See the “PWM Basics” on page 14, the data book or [3] for details. Input Capture The AVR has an input pin to trigger the input capture event. A signal change at this pin causes the timer value to be read and saved in the Input Capture Register (ICRx). At the same time the Input Capture Flag (ICFx) in the TIFR will be set. This is useful to mea- sure the width of external pulses.

Timer Event Notification The timer operates independently of the program execution. For each timer event there

is a corresponding status flag in the Timer Interrupt Flag Register (TIFR). The occur- rence of timer events require a notification of the processor to trigger the execution of corresponding actions. This is done by setting the status flag of the event which occurred. There are three different ways to monitor timer events and react on them: 1. Constantly polling of status flags – interrupt flags and execution of corresponding code. 2. Break of program flow and execution of Interrupt Service Routines (ISR). 3. Changing the level of output pins automatically. Polling of Interrupt Flags This method makes use of the fact that the processor marks the timer events by setting the corresponding interrupt flags. The main program can frequently check the status of these flags to see if one of these events occurred. This requires some program over- 2 AVR130,

AVR130

head, which will cost additional processing time. The advantage of this solution is the very short response time when tight loops are used. The assembler implementation for the Timer0 can look like the following code example. This three code lines have to be located in the main loop so that they are executed frequently. loop: ; label in r16,TIFR ; load TIFR in register 16 sbrs r16,TOV0 ; skip next instruction if bit (zero) in register ; (r16) is set rjmp loop ; jump to loop if no Timer0 overflow occurred ; Event Service Code starts here Interrupt Controlled The AVR can be configured to execute interrupts if a timer event has occurred (the cor- Notification responding interrupt flag in the TIFR is set). Normal program execution will be interrupted (almost) immediately and the processor will execute the code of the Interrupt Service Routine. The advantage compared to polling of interrupt flags is zero overhead in the main loop. This saves processing time. The section “Setting Up the Timers” on page 7 shows a few examples of how this can be implemented. Timer interrupts are enabled by setting the corresponding bit in the Timer Interrupt Mask Register (TIMSK). The following example shows how to enable the Output Compare Interrupt of Timer2: ldi r16,1<Clock Options The clock unit of the AVR timers consists of a prescaler connected to a multiplexer. A prescaler can be described as a clock divider. Generally, it is implemented as a counter with several output signals at different counting stages. In the case of the AT90S8535, a 10-bit counter is used to divide the input clock in four (six in case of the Timer2) different prescaled clocks. The multiplexer is used to select which prescaled clock signal to use as input signal for the Timer. Alternatively, the multiplexer can be used to bypass the prescaler and configure an external pin to be used as input for the Timer. The fact that there are two prescalers available, but three different Timers, has to be seen in context with which clock source the prescaled value is based on. Both Timer0 and Timer1 are synchronous timers and use the system clock (CPU clock) as input, source. In this case there is no limitation if both use the same prescaler (as long as each timer can be configured separately). However, the asynchronous clocked Timer2 needs its own prescaler to be independent of the system clock. Figure 1 shows the prescaling and the configuration unit. The data sheets contain more detailed drawings showing all prescalers and multiplexers. An overview of the possible clock settings is given in Table 1. In the following sections these settings will be described more clearly. Notes: 1. The prescaler is constantly running during operation. In cases where the timer has to count very accurately it has to be ensured that the prescaler starts counting from zero. On parts without prescaler reset this has to be done by detecting the prescaler overflow by software and the initialization of the timer counter TCNTx register afterwards. 2. On newer devices with shared prescaler, executing a prescaler reset will affect all connected timers. Figure 1. Prescaler PCKx 10-bit T/C Prescaler T (0-1)x CSx0 CSx1 CSx2 (0-1) only available on Timer 0 and 1 TCKx (2) only available on Timer2x[0..2] Clocking by System Clock In this case, the system clock is used as input signal for the prescaler. Even if a pres- caled value is chosen instead of the system clock, this clock is based on the system clock. The timer clock is therefore synchronous to the system clock. All three timers of the AT90S8535 and most timers on other AVR parts support this option. The advantage of this is that no additional external circuits are needed. Small time frames can be implemented or monitored because of the high frequency of the sys- tem clock. The timer overflow frequency is a good indication of the size of the time frame a timer covers. Equation 1 shows the correlation between the timer overflow frequency TOVCK, the maximum value (MaxVal) of the timer, the system clock (CK) and the division factor of the prescaler (PVal). PCKx /8 PCKx /32 (2) PCKx /64 PCKx /128 (2) PCKx /256 PCKx /1024 4 AVR130,

AVR130

Table 1. Overview of the Clock Settings TCCRx Synchronous Timer0 & Synchronous/Asynchronous Bit 2 Bit 1 Bit 0 Timer1 PCK = CK Timer2 PCK2 = f (AS2) CSx2 CSx1 CSx0 TCK0,1 TCK20000(Timer Stopped) 0 (Timer Stopped) 001PCK (System Clock) PCK2 (System Clock/Asynchronous Clock) 010PCK/8 PCK2/8011PCK/64 PCK2/32100PC/256 PCK2/64101PCK/1024 PCK2/128110External Pin Tx falling edge PCK2/256111External Pin Tx rising edge PCK2/1024 f (P TOV = -C-K- = -C-K ⁄ PVal) P CK - x- = -C-K-x- (2) MaxVal MaxVal (PVal • MaxVal) Assume that the CPU is running with fCPU = 3.69 MHz and the resolution of the timer is 8 bit (MaxVal = 256). A prescale value of 64 will then cause the timer to be clocked with TCK = 3.69 MHz/64 so that there will be about 225 timer overflows per second. See Equation 2 for the correct mathematical description: f TOV = -C-K- = (-3-.-6-9-M-H-zCK - ⁄-6-4-) = ~225 MaxVal 256 To get 225 timer overflow events per second means that every 4.4 ms an overflow occurs. The maximum prescaler value will generate a timer overflow every 71 ms while the minimum prescaler value generates a timer overflow every 69 µs. In most cases a different approach will be used to determine the settings. The require- ments of the application will specify the frequency of the timer overflows. Based on this and the given clock frequency of the CPU together with the timer resolution the pres- caler settings will be calculated according to Equation 3.

P

PVal = -C-K-x- (3) (TOV • MaxVal), The assembler implementation for Timer0 can look like the following code example. These lines set the prescaler values in the TCCR0 to a clock division factor of 1024 (see Table 1). ldi r16,(1<AVR130 The assembler implementation for the Timer0 can look like the following code example. These lines set pin T0 as input pin for the timer clock with the rising edge as the active clock edge (see Table 1). ldi r16,(1<Setting Up the Timers This section shows concrete examples for how to set up the three different timers. The data sheet and the application notes listed in the “Litterature” section should be read in addition. Especially when transforming the settings to other parts than the AT90S8535. Using interrupts is the most common way to react on timer events. The examples which are described in the following use interrupts. Independent of the different features of the three timers, they all have two things in com- mon. The timer has to be started by selecting the clock source, and if interrupts are used they have to be enabled.

Shared Registers If the same registers are used in the interrupt service routines as in the main code, these

registers have to be saved at the beginning of the ISR and restored at the end of the ISR. If not all 32 registers are needed in the application, the save and restore operations can be avoided by using separate registers in the main code and the ISR. It is also very important to remember to store the Status Register (SREG), as this is not automatically done by the interrupt handler. Note: The C compiler handles this automatically, while it has to be done manually by using for instance push and pop instructions if assembly language is used. 8-bit Timer0 The 8-bit Timer0 is a synchronous Timer. This means that it is clocked by the system clock, a prescaled system clock or an external clock which is synchronized with the sys- tem clock (see section “Clock Options” on page 3 for details about this). This timer is the least complex of the three. Only a few settings have to be made to get it running., Example – Timer0 Overflow The following example will show how the Timer0 can be used to generate Timer Over- Interrupt flow Interrupts. With every interrupt the output pins on Port B will be toggled. To observe this, the STK500 Development Board can be used. Port B has to be con- nected to the LEDs using the 10-pin ribbon cable. The LEDs will blink with a frequency (fLED) that is determined by the following formula: f fLED = - C-K- = -(-C-K-⁄-P-V-a-l-)- = -C-K- MaxVal 2 • MaxVal 2(PVal • MaxVal) A system consisting of an 8-bit t imer (MaxVal = 256) and a system clock of CK = 3.69 MHz which is divided by a prescaler value of PVal = 1024, will cause the LEDs to blink with a frequency (fLED) of approximately 7 Hz. The following initialization routine shows how to set up such a system: init_Ex1: ldi r16,(1<AVR130 In the next step, the interrupt service routine has to be implemented. This routine will be executed with every timer overflow. Its purpose in this example is to toggle the bits of the Port B (the LEDs). ISR_TOV0: push r16 in r16,SREG push r16 in r16,PORTB ; Read Port B com r16 ; Invert bits of r16 register out PORTB,r16 ; Write Port B pop r16 out SREG,r16 pop r16 reti The corresponding C code for the IAR Compiler looks like this: void interrupt [TIMER0_OVF0_vect] ISR_TOV0 (void) { PORTB = ~PORTB; // Toggle pins on Port B } 16-bit Timer1 The 16-bit timer1 is a synchronous timer. This means that it is clocked by the system clock, a prescaled system clock or an external clock which is synchronized with the sys- tem clock. To ensure that the 16-bit registers of the Timer1 are written and read simultaneously, a temporary register (Temp) is used. This makes it necessary to access these registers in a specific order. Please see the application note “AVR072: Accessing 16-bit I/O Registers” and the data book for details. The correct way to access the regis- ters is shown in Table 2. Table 2. Accessing 16-bit Registers Operation 1st Access 2nd Access Read Low Byte High Byte Write High Byte Low Byte According to this, a read operation of a 16-bit register can look like this: in r16,TCNT1L in r17,TCNT1H A write operation to this register has to access the registers in the opposite order: out TCNT1H,r17 out TCNT1L,r16 The C Compiler automatically handles 16-bit I/O read and write operations in the correct order., Example – Timer Input This example will show the implementation of a very simple use of the input capture Capture Interrupt event and interrupt. The port pin PD6 is the input capture pin (ICP). If the value of this pin changes, the time between successive positive or negative edges on this pin will be measured by Timer1. The eight most significant bits of the timer value will be written to Port B. Again Port B has to be connected to the LEDs of the STK500, while Port D has to be connected to the switches (using two 10-bit ribbon cables). This makes it possible to see the timer value on the LEDs and to use the switch as the input pin for the input capture event. In this example, the maximum time the system should be able to detect is specified to approximately one second (TOVCK = 1). Using Equation 3 the required clock division factor of the prescaler can be determined. For a system clock of 3.69 MHz the prescaler value is determined through: 3-.-6-9-M-H-z- = 56 PVal = 64 (Closest Selectable Value) The following initialization routine shows how to set up such a system: init_Ex2: ldi r16,(1<AVR130 In the next step, the interrupt service routine has to be implemented. This routine will be executed with every input capture event. Its purpose in this example is to output the high byte of Timer1 on Port B (the LEDs). Secondly the timer is reset for the next measurement. TIM1_CAPT: push r16 in r16,SREG push r16 in r16,ICR1L ; Read ICR low byte and high ; byte/ save high byte in Temp in r16,ICR1H ; Read ICR high byte com r16 ; Invert bits - 1 complement (see Note 1) out PORTB,r16 ; Write ICR1H to PORTB clr r16 out TCNT1H,r16 ; Write Temp register out TCNT1L,r16 ; Clear the 16 bit register pop r16 out SREG,r16 pop r16 reti

The corresponding C code for the IAR Compiler looks like this:

void interrupt [TIMER1_CAPT1_vect] ISR_ICP1(void) { // read high byte from Input Capture Register (read // 16 bit value and shift it eight bits to the // right) PORTB = ~( ICR1>>8); // Invert Byte (see Note // 1)and output high byte // on Port B TCNT1 = 0; // Reset Timer1 Count // Register } Notes: 1. The inversion of the bits is necessary because of the way the LEDs are connected on the STK500 (Low Level = LED on / High Level = LED off) 2. This implementation has one disadvantage: A timer overflow is not detected. A global variable which is set in a timer overflow ISR can be used to avoid this. If this variable is set, a value like 0xFF should be written to Port B instead of the timer value.,

Asynchronous 8-bit Timer2 can be used in synchronous mode like Timer0 and Timer1. In addition, an asyn- Timer2 chronous mode can be used. Please see the description of the asynchronous clocking

in “Clocking by Asynchronous Clock” on page 6 or the data sheet for details. Example – Timer Output This example shows how to use the timer output compare interrupt of Timer2. The timer Compare Interrupt will be configured so that the compare match event occurs every second. This feature could be used to implement a RTC. In this example, however, the port pins will be inverted with every compare match event so that the connected LEDs will be blinking with a frequency of 0.5 Hz. Like in the previous example, Port B has to be connected to the LEDs and Port D to the switches of the STK500. In addition, a 32.768 kHz crystal has to be mounted on the pins TOSC1/PC6 and TOSC2/PC7 of Port C. The timer settings can be calculated according to Equation 2. As Timer maximum value (MaxVal) the value of the OCR2 has to be used instead. The prescaler clock (PCKx) is in this case the clock signal of the watch crystal (fOSCCK), while TOVCK as the clock signal for the pin change events is specified by the application to 1 second. The mathematical description of this relation is shown by the following equation: f 1 = TOVCK = - O-S-C-C-K- = -3-2-.-7-6-8-k-H-z- PVal • OCR2 PVal • OCR2 A prescaler value of 1024 is selected plus a corresponding OCR2 value of 32 to get the delay time of one second between two Timer compare match events. The following initialization routine shows how to set up such a system: init_Ex3: ldi r16,1<AVR130 The corresponding C code for the IAR Compiler looks like this: void init_Ex3(void) { ASSR= 1<In the next step the interrupt service routine has to be implemented. This routine will be executed with every output compare event. The purpose in this example is to toggle the bits of Port B (the LEDs). ISR_OCIE2: push r16 in r16,SREG push r16 in r16,PORTB ; Read Port B com r16 ; Invert bits of r16 register out PORTB,r16 ; Write Port B pop r16 out SREG,r16 pop r16 reti

The corresponding C code for the IAR Compiler looks like this:

void interrupt [TIMER2_COMP_vect] ISR_OCIE2 (void) { PORTB = ~PORTB; // invert bits on Port B },

PWM Basics PWM is an abbreviation for Pulse Width Modulation. It is a special mode, which the

Timer1 and Timer2 can be configured to use. In this mode, the timer acts as an up/down counter. That means that the counter counts up to its maximum value and then counts down back to zero. This is contrary to the usual counting mode where the timer has an overflow the cycle after reaching the maximum value. The advantage of the PWM is that the duty cycle relation can be changed in a phase consistent way. If the PWM is configured to toggle the Output Compare pin (OCx), the signal at this pin can look like shown in Figure 2. Figure 2. Output Signal of PWM

V VH VAV

VLtxyVH: Output Voltage high level VL: Output Voltage low level VAV: Average Output Voltage level x: Duty cycle high level y: Duty cycle low level A low pass filter at the output pin combined with the relative high speed of the PWM will cause a constant voltage level instead of a square wave signal as output signal. Equa- tion 4 shows how this voltage level can be calculated: (VH • x + VL • y)VAV = - (4)(x + y) with x = OCRx • 2 y = (MaxVal – OCRx) • 2 (VH • OCRx + VL • (MaxVal – OCRx))VAV = - (5)MaxVal The fact that this method allows the timer to generate voltage levels between VCC and GND means that a DAC can be implemented using the PWM. Details about this are 14 AVR130,

AVR130

described in the application notes “AVR314: DTMF Transmitter” and “AVR335: Digital Sound Recorder with AVR and Serial DataFlash”. Example – Timer2 as 8-bit This example shows how to generate voltages between VCC and GND at the output pin PWM of the PWM (PD7/OC2). To observe this, Port D should be connected to the LEDs using one of the 10-pin ribbon cables. Port D is configured the way that the LEDs connected to the low nibble will be switched on while the LEDs connected to the high nibble will be switched off. Only the LED on PD7 / OC2 will not be switched off nor will it be switched on but shine with a low bright- ness. This LED is connected to the output pin of the PWM whichs output signal has a duty relation of 1/8 to 7/8 (OCR2 = 0xE0). Note: The duty cycle ratio for this configuration is inverted because of the way the LEDs are connected on the STK500. The following initialization routine shows how to set up such a system: init_Ex4: ; 8 bit PWM non-inverted (Fck/510) ldi r16,(1<Literature 1. AVR072: Accessing 16-bit I/O Registers 2. AVR134: Real Time Clock (RTC) using the Asynchronous Timer 3. AVR314: DTMF Transmitter 4. AVR335: Digital Sound Recorder with AVR and Serial DataFlash,

Atmel Headquarters Atmel Operations Corporate Headquarters Memory RF/Automotive

2325 Orchard Parkway Atmel Corporate Atmel Heilbronn San Jose, CA 95131 2325 Orchard Parkway Theresienstrasse 2 TEL 1(408) 441-0311 San Jose, CA 95131 Postfach 3535 FAX 1(408) 487-2600 TEL 1(408) 436-4270 74025 Heilbronn, Germany FAX 1(408) 436-4314 TEL (49) 71-31-67-0

Europe FAX (49) 71-31-67-2340

Atmel SarL Microcontrollers Route des Arsenaux 41 Atmel Corporate Atmel Colorado Springs Casa Postale 80 2325 Orchard Parkway 1150 East Cheyenne Mtn. Blvd. CH-1705 Fribourg San Jose, CA 95131 Colorado Springs, CO 80906 Switzerland TEL 1(408) 436-4270 TEL 1(719) 576-3300 TEL (41) 26-426-5555 FAX 1(408) 436-4314 FAX 1(719) 540-1759 FAX (41) 26-426-5500 Atmel Nantes Biometrics/Imaging/Hi-Rel MPU/

Asia La Chantrerie High Speed Converters/RF Datacom

Atmel Asia, Ltd. BP 70602 Atmel Grenoble Room 1219 44306 Nantes Cedex 3, France Avenue de Rochepleine Chinachem Golden Plaza TEL (33) 2-40-18-18-18 BP 123 77 Mody Road Tsimhatsui FAX (33) 2-40-18-19-60 38521 Saint-Egreve Cedex, France East Kowloon TEL (33) 4-76-58-30-00 Hong Kong ASIC/ASSP/Smart Cards FAX (33) 4-76-58-34-80 TEL (852) 2721-9778 Atmel Rousset FAX (852) 2722-1369 Zone Industrielle 13106 Rousset Cedex, France

Japan TEL (33) 4-42-53-60-00

Atmel Japan K.K. FAX (33) 4-42-53-60-01 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Atmel Colorado Springs Chuo-ku, Tokyo 104-0033 1150 East Cheyenne Mtn. Blvd. Japan Colorado Springs, CO 80906 TEL (81) 3-3523-3551 TEL 1(719) 576-3300 FAX (81) 3-3523-7581 FAX 1(719) 540-1759 Atmel Smart Card ICs Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland TEL (44) 1355-803-000 FAX (44) 1355-242-743 e-mail email is hidden

Web Site

http://www.atmel.com © Atmel Corporation 2002. Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company’s standard warranty which is detailed in Atmel’s Terms and Conditions located on the Company’s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel’s products are not authorized for use as critical components in life support devices or systems. ATMEL® and AVR® are the registered trademarks of Atmel. Other terms and product names may be the trademarks of others. Printed on recycled paper. 2505A–AVR–02/02 0M]
15

Similar documents

8-bit RISC Microcontroller Application Note AVR151: Setup And Use of The SPI Features Introduction
8-bit RISC Microcontroller Application Note Rev. 2585A–AVR–11/04 AVR151: Setup And Use of The SPI Features • SPI Pin Functionality • Multi Slave Systems • SPI Timing • SPI Transmission Conflicts • Emulating the SPI • Code examples for Polled operation • Code examples for Interrupt Controlled operati
AVR241: Direct driving of LCD display using general IO
AVR241: Direct driving of LCD display using general IO Features • Software driver for displays with one common line • Suitable for parts without on-chip hardware for LCD driving • Control up to 15 segments using 16 IO lines • Fully interrupt driven operation Introduction As a low power alternative t
8-bit Microcontroller Application Note
8-bit Microcontroller Application Note Rev. 0938B–AVR–01/03 AVR204: BCD Arithmetics Features • Conversion 16 Bits ↔ 5 Digits, 8 Bits ↔ 2 Digits • 2-digit Addition and Subtraction • Superb Speed and Code Density • Runable Example Program Introduction This application note lists routines for BCD arith
8-bit Microcontroller Application Note
8-bit Microcontroller Application Note Rev. 2530B–AVR–01/04 AVR065: LCD Driver for the STK502 and AVR Butterfly Features • Software Driver for Alphanumeric Characters • Liquid Crystal Display (LCD) Contrast Control • Interrupt Controlled Updating • Conversion of ASCII to LCD Segment Control Codes (S
8-bit Instruction Set Instruction Set Nomenclature
8-bit Instruction Set Rev. 0856D–AVR–08/02 Instruction Set Nomenclature Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two’s complement overflow indicator S: N ⊕ V, For signed tests H: Half Carry Flag T: Transfer bit used by BLD and BST instructions I: Gl
8-bit Microcontroller Application Note
8-bit Microcontroller Application Note Rev. 0933B–AVR–05/02 AVR102: Block Copy Routines Features • Program Memory (Flash) to SRAM Copy Routine • SRAM to SRAM Copy Routine • Extremely Code Efficient Routines Flash → SRAM: 6 Words, SRAM → SRAM: 5 Words • Runable Test/Example Program Introduction This
Novice’s Guide to AVR Development intended for
Novice’s Guide to AVR Development Preparing your PC for AVR Development Basic AVR Knowledge An Introduction Let's make an easy start, and download the files that we will need later on. The AVR Microcontroller family is a modern architecture, with all the bells andFirst you should download the files
AVR079: STK600 Communication Protocol
AVR079: STK600 Communication Protocol Features 8-bit • Supported Commands and Command options • Command and Answer package formats Microcontrollers 1 Introduction Application Note This document describes the STK®600 protocol. The firmware is distributed with AVR Studio® 4.14 or later. The definition
8-bit Instruction Set Instruction Set Nomenclature
8-bit Instruction Set Rev. 0856G–AVR–07/08 Instruction Set Nomenclature Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two’s complement overflow indicator S: N ⊕ V, For signed tests H: Half Carry Flag T: Transfer bit used by BLD and BST instructions I: Gl
Designer’s Designing for Efficient Production Corner with In-System Re-programmable Flash µCs
Designer’s Designing for Efficient Production Corner with In-System Re-programmable Flash µCs By: OJ Svendlsi always the component where the majority of the engi- neering hours are spent. Thus, making sure the micro- For products where time-to-market and efficient pro- controller has what it takes t
AVR069: AVRISP mkII Communication Protocol
AVR069: AVRISP mkII Communication Protocol Features • General commands • ISP commands • Return values • Parameters 1 Introduction This document describes the AVRISP mkII protocol. The firmware is distributed with AVR Studio 4.12 or later. Download the latest AVR Studio from the Atmel web site, http:
Studio® Integrated Development A COMPLETE SOFTWARE ENVIRONMENT TO Environment DEVELOP AVR® APPLICATIONS. IT’S FREE!
MICROCONTROLLERSStudio® Integrated Development A COMPLETE SOFTWARE ENVIRONMENT TO Environment DEVELOP AVR® APPLICATIONS. IT’S FREE! AVR Studio® is an Integrated Development Environment for writing and debugging AVR applications in Windows® 98/XP/ME/2000 and Windows NT® environments. AVR Studio provi
Hexadecimal Object File Format Specification
Hexadecimal Object File Format Specification Revision A January 6, 1988 This specification is provided "as is" with no warranties whatsoever, including any warranty of merchantability, noninfringement, fitness for any particular purpose, or any warranty otherwise arising out of any proposal, specifi
AVR914: CAN & UART based Bootloader for AT90CAN32, AT90CAN64, & AT90CAN128 1. Features
AVR914: CAN & UART based Bootloader for AT90CAN32, AT90CAN64, & AT90CAN128 1. Features • UART Protocol 8-bit – UART used as Physical Layer – Based on the Intel Hex-type records Microcontrollers – Auto-baud • CAN Protocol – CAN used as Physical Layer Application Note – 7 re-programmable ISP CAN ident
AVR Microcontrollers Application Note
AVR Microcontrollers Application Note AVR495: AC Induction Motor Control Using the Constant V/f Principle and a Space-vector PWM Algorithm 1. Features • Cost-effective and energy efficient 3-phase induction motor drive • Interrupt driven • Low memory and computing requirements 2. Introduction In a p
AVR Microcontrollers Application Note AVR494: AC Induction Motor Control Using the constant V/f Principle and a Natural PWM Algorithm
AVR Microcontrollers Application Note AVR494: AC Induction Motor Control Using the constant V/f Principle and a Natural PWM Algorithm 1. Features • Cost-effective and flexible 3-phase induction motor drive • Interrupt driven • Low memory and computing requirements 2. Introduction Electrical power ha
AVR465: Single-Phase Power/Energy Meter with Tamper Detection
AVR465: Single-Phase Power/Energy Meter with Tamper Detection Features • Cost-Effective and Flexible Single-Phase Energy Meter • Fulfills IEC 61036 Accuracy Requirements for Class 1 Meters • Detects, Signals and Continues to Measure Accurately Under At Least 20 Different Tamper Conditions • Design E
AVR453: Smart Battery Reference Design
AVR453: Smart Battery Reference Design Features • Support for up to 4 Li-Ion series-connected battery cells • Battery protection by dedicated Hardware - Deep under voltage protection - Over-current protection during charging - Over-current protection during discharging - Short circuit protection • C
8-bit Microcontroller Application Note AVR450: Battery Charger for SLA, NiCd, NiMH and Li-Ion Batteries Features
8-bit Microcontroller Application Note Rev. 1659B–AVR–11/02 AVR450: Battery Charger for SLA, NiCd, NiMH and Li-Ion Batteries Features • Complete Battery Charger Design • Modular “C” Source Code and Extremely Compact Assembly Code • Low Cost • Supports Most Common Battery Types • Fast Charging Algori
Getting started with the AVR battery charger reference design.
Getting started with the AVR battery charger reference design. The AVR battery charger reference design is designed for use with several types of batteries and various number of battery cells. The AVR battery charger reference design is supplied with resistor values for scaling down the charge volta
8-bit Microcontroller Application Note
8-bit Microcontroller Application Note Rev. 2534A–AVR–05/03 AVR415: RC5 IR Remote Control Transmitter Features • Utilizes ATtiny28 Special HW Modulator and High Current Drive Pin • Size Efficient Code, Leaves Room for Large User Code • Low Power Consumption through Intensive Use of Sleep Modes • Cos
AVR336: ADPCM Decoder
AVR336: ADPCM Decoder Features • AVR Application Decodes ADPCM Signal in Real-Time • Supports Bit Rates of 16, 24, 32 and 40 kbit/s • More Than One Minute Playback Time on ATmega128 (at 16 kbit/s) • Decoded Signal Played Using Timer/Counter in PWM Mode 1 Introduction Adaptive Differential Pulse Code
8-bit Microcontroller Application Note
8-bit Microcontroller Application Note Rev. 1181B–AVR–04/03 AVR360: Step Motor Controller Features • High-speed Step Motor Controller • Interrupt Driven • Compact Code (Only 10 Bytes Interrupt Routine) • Very High Speed • Low Computing Requirement • Supports all AVR Devices Introduction This applica
8-bit RISC Microcontroller Application Note AVR335: Digital Sound Recorder with AVR and Serial DataFlash Features
8-bit RISC Microcontroller Application Note Rev. 1456B–01/04 AVR335: Digital Sound Recorder with AVR and Serial DataFlash Features • Digital Voice Recorder • 8-bit Sound Recording • 8 KHz Sampling Rate • Sound Frequency up to 4000 Hz • Maximum Recording Time 2 1/4 Minutes • Very Small Board Size • O
USB in a Nutshell. Making Sense of the USB Standard.
USB in a Nutshell. Making Sense of the USB Standard. Starting out new with USB can be quite daunting. With the USB 2.0 specification at 650 pages one could easily be put off just by the sheer size of the standard. This is only the beginning of a long list of associated standards for USB. There are U
What is USB Enumeration? What does enumeration look like?
What is USB Enumeration? Enumeration is the process by which a USB device is attached to a system and is assigned a specific numerical address that will be used to access that particular device. It is also the time at which the USB host controller queries the device in order to decide what type of d
Draft
CYCLIC REDUNDANCY CHECKS IN USB Introduction The USB specification calls for the use of Cyclic Redundancy Checksums (CRC) to protect all non-PID fields in token and data packets from errors during transmission. This paper describes the mathematical basis behind CRC in an intuitive fashion and then e
File: X:\USERS\IGOR\DOC\WORD\Atmel\USB to RS232 Application Note\Firmware\USBtoRS232_ATmega8\AVR Studio 4 project\USBtoRS232.asm 1.2.2004
1 ;*************************************************************************** 2 ;* USBSTACKFORTHEAVRFAMILY3;* 4 ;* File Name :"USBtoRS232.asm" 5 ;* Title :AVR309:USB to UART protocol converter 6 ;* Date :01.02.2004 7 ;* Version :2.8 8 ;* Target MCU :ATmega8 9 ;* AUTHOR :Ing. Igor Cesko 10 ;* Slovak
File: X:\USERS\IGOR\DOC\WORD\Atmel\USB to RS232 Application Note\Firmware\USBtoRS232_AT90S2313\AVR Studio 4 project\USB90S2313.asm 26.1.2004
1 ;*************************************************************************** 2 ;* USBSTACKFORTHEAVRFAMILY3;* 4 ;* File Name :"USB90S2313.asm" 5 ;* Title :AVR309:USB to UART protocol converter (simple - small FIFO) 6 ;* Date :26.01.2004 7 ;* Version :2.2 8 ;* Target MCU :AT90S2313-10 9 ;* AUTHOR :I
AVR309: Software Universal Serial Bus (USB)
AVR309: Software Universal Serial Bus (USB) Features • USB (Universal Serial Bus) protocol implemented in firmware • Supports Low Speed USB (1.5Mbit/s) in accordance with USB2.0 • Implementation runs on very small AVR devices, from 2kBytes and up • Few external components required - One resistor for