Atmel AVR053 Application Note
Atmel AVR053 Application Note

Atmel AVR053 Application Note

Internal rc oscillator calibration for tinyavr and megaavr devices

Advertisement

Quick Links

AVR053: Internal RC Oscillator Calibration for

Introduction

This application note describes a fast and accurate method to calibrate the
internal RC oscillator of the Atmel
have ISP or JTAG interfaces. It offers firmware source code that allows
calibration using the
AVRISP
programming tools. It could also be adapted to production programmers.
These are covered in the
Microcontrollers" application note.
Many tinyAVR and megaAVR devices offer the possibility to run from an
internal RC oscillator. Typically, this oscillator can be user calibrated to within
±1% of the frequency specified in the datasheet. This feature offers
significant cost savings compared to using an external oscillator.
Factory calibration is performed at a fixed operating voltage and
temperature. The calibration technique in this application note can be
performed by the user to achieve higher accuracy than the standard
calibration offers, to match a specific operating voltage or temperature, or
even to tune the oscillator to a different frequency.
In some systems it may be necessary to perform run-time calibration of the
oscillator using an external crystal. This is covered in the
32kHz XTAL for run-time calibration of the internal

Features

Calibration using the following programming tools: AVRISP mkII,
JTAGICE mkII, JTAGICE3, and Atmel-ICE
Support for tinyAVR and megaAVR devices with tunable RC oscillator
and ISP, or JTAG interface
Adjustable internal RC oscillator frequency with ±1% accuracy typical
Tune RC oscillator to any frequency at any operating voltage and
temperature within specification
No external components required for calibration
Atmel-2555H-Internal-RC-Oscillator-Calibration-for-tinyAVR-and-megaAVR-Devices_AVR053_Application Note-09/2016
AVR 8-bit Microcontrollers
tinyAVR and megaAVR Devices
®
®
tinyAVR
and megaAVR
mkII,
JTAGICE
mkII, JTAGICE3, or
"AT06015: Production Programming of Atmel
RC" application note.
APPLICATION NOTE
®
devices that
Atmel-ICE
"AVR055: Using a

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the AVR053 and is the answer not in the manual?

Questions and answers

Summary of Contents for Atmel AVR053

  • Page 1: Introduction

    AVR 8-bit Microcontrollers AVR053: Internal RC Oscillator Calibration for tinyAVR and megaAVR Devices APPLICATION NOTE Introduction This application note describes a fast and accurate method to calibrate the ® ® ® internal RC oscillator of the Atmel tinyAVR and megaAVR devices that have ISP or JTAG interfaces.
  • Page 2: Table Of Contents

    Performance of the Calibration Firmware...................12 3.5. Calibration Clock Accuracy......................13 3.6. Quick Start guide........................13 3.7. Adding Support for New Devices....................15 4. References......................16 5. Revision History.......................17 Atmel AVR053: Internal RC Oscillator Calibration for tinyAVR and megaAVR Devices [APPLICATION NOTE] Atmel-2555H-Internal-RC-Oscillator-Calibration-for-tinyAVR-and-megaAVR-Devices_AVR053_Application Note-09/2016...
  • Page 3: Internal Rc Oscillator

    RC oscillator to remove process variations from the oscillator frequency, as shown in the figure below. The OSCCAL register is one byte wide. Atmel AVR053: Internal RC Oscillator Calibration for tinyAVR and megaAVR Devices [APPLICATION NOTE] Atmel-2555H-Internal-RC-Oscillator-Calibration-for-tinyAVR-and-megaAVR-Devices_AVR053_Application Note-09/2016...
  • Page 4: Oscillator Characteristics

    ATmega8. The frequency increases with increasing voltage, and decreases with increasing operating temperature. These characteristics will vary from device to device. For details on a specific device, refer to its datasheet. Atmel AVR053: Internal RC Oscillator Calibration for tinyAVR and megaAVR Devices [APPLICATION NOTE] Atmel-2555H-Internal-RC-Oscillator-Calibration-for-tinyAVR-and-megaAVR-Devices_AVR053_Application Note-09/2016...
  • Page 5: Rc Oscillator Revision History

    4.8 and 9.6 ATmega169P The prescaler register is in these devices is named XDIV. ATmega169 revision A-E uses oscillator version 4.0, while ATmega169P uses oscillator version 5.0. Atmel AVR053: Internal RC Oscillator Calibration for tinyAVR and megaAVR Devices [APPLICATION NOTE] Atmel-2555H-Internal-RC-Oscillator-Calibration-for-tinyAVR-and-megaAVR-Devices_AVR053_Application Note-09/2016...
  • Page 6: Version 1.X Oscillators

    The ATmega406 has a frequency of 4MHz but is otherwise the same. Atmel AVR053: Internal RC Oscillator Calibration for tinyAVR and megaAVR Devices [APPLICATION NOTE]...
  • Page 7: Calibration

    This chapter is divided into calibration protocol and calibration firmware. The protocol can be adapted into any test or programming tool to support calibration. The AVRISP mkII, JTAGICE mkII, JTAGICE3, and Atmel-ICE programming tools support the implemented calibration protocol. The usage of these tools to calibrate a device is described in later sections.
  • Page 8: Calibration Firmware

    2.3. Calibration Firmware The calibration code is written in AVRASM2 assembly, for Atmel Studio 7.0 (or later). The calibration firmware is structured in a way so that it can easily be updated to support new tinyAVR or megaAVR devices that have an ISP or JTAG interface. Also, the interface for calibration can be configured.
  • Page 9: Binary Search Of Osccal

    The C-frequency is specified in the interface specific include file. The method for determining the oscillator frequency is described in the flowchart below. Atmel AVR053: Internal RC Oscillator Calibration for tinyAVR and megaAVR Devices [APPLICATION NOTE]...
  • Page 10 However, these extremes are very unlikely to be encountered due to the binary search method used. Atmel AVR053: Internal RC Oscillator Calibration for tinyAVR and megaAVR Devices [APPLICATION NOTE]...
  • Page 11: Correcting Timing Inaccuracies

    AVRASM2. All values that cannot be represented (floats) are rounded towards a tighter accuracy and will therefore not endanger the goal of ±1% accuracy for the oscillator. Atmel AVR053: Internal RC Oscillator Calibration for tinyAVR and megaAVR Devices [APPLICATION NOTE]...
  • Page 12: Steps To Calibrate Device Using Avr Tools

    The root assembly file for the calibration firmware is RC_Calibration.asm. This file is pointed to by the Atmel Studio solution file rc_calib.atsln. In the RC_Calibration.asm file it is possible to specify the desired calibration interface: Atmel-ICE, AVRISP mkII, JTAGICE3, or JTAGICE mkII. In addition, it is possible to specify the desired calibration accuracy.
  • Page 13: Calibration Clock Accuracy

    To quickly get started performing calibration on a supported device, follow these steps: Download and install Atmel Studio 7.0 (or later) from http://www.atmel.com. Download and unzip the code for this application note, AVR053 (any location can be used, here called \AVR053).
  • Page 14 Refer to the device data sheet for achievable accuracy. 10. Save all modified files in Atmel Studio by clicking on "File" then "Save All". 11. Click on "Build" then "Build rc_calib" to assemble the project and generate the hex file that should be programmed into the device.
  • Page 15: Adding Support For New Devices

    Figure 3-4. Fuse Settings 17. If the install path for Atmel Studio differs from the one used in the batch file, change the path to the relevant atprogram.exe file as shown in the figure below. Figure 3-5. Tool Path 18. For production calibration the @PAUSE command at successful calibration can be removed.
  • Page 16: References

    References AVR054: Run-time Calibration of the Internal RC Oscillator http://www.atmel.com/Images/doc2563.pdf AVR055: Using a 32kHz XTAL for Run-time Calibration of the Internal RC http://www.atmel.com/Images/doc8002.pdf Atmel AVR053: Internal RC Oscillator Calibration for tinyAVR and megaAVR Devices [APPLICATION NOTE] Atmel-2555H-Internal-RC-Oscillator-Calibration-for-tinyAVR-and-megaAVR-Devices_AVR053_Application Note-09/2016...
  • Page 17: Revision History

    Revision History Doc Rev. Date Comments 09/2016 Complete modernization and refurbishing of document. 05/2006 03/2006 01/2006 Updated details on handshaking and removed duplicate info in 2.7.1 Atmel AVR053: Internal RC Oscillator Calibration for tinyAVR and megaAVR Devices [APPLICATION NOTE] Atmel-2555H-Internal-RC-Oscillator-Calibration-for-tinyAVR-and-megaAVR-Devices_AVR053_Application Note-09/2016...
  • Page 18 DISCLAIMER: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND...

Table of Contents