APPLICATION NOTE. Atmel AVR1638: XMEGA RTC Calibration. 8-bit Atmel Microcontrollers. Features. Introduction

Similar documents
APPLICATION NOTE. Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices. Atmel AVR XMEGA. Features.

APPLICATION NOTE. AT03324: Atmel REB212BSMA-EK Quick Start Guide. Atmel MCU Wireless. Introduction

AVR1518: XMEGA-A1 Xplained Training - XMEGA Clock System. 8-bit Atmel Microcontrollers. Application Note. Prerequisites.

APPLICATION NOTE. Atmel AT03304: SAM D20 I 2 C Slave Bootloader SAM D20. Description. Features

Hardware Prerequisites Atmel Xplained Pro Evaluation Kit Atmel WINC1500 extension USB Micro Cable (TypeA / MicroB)

Atmel AVR1619: XMEGA-B1 Xplained Demonstration. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

OLED display with pixels resolution Ambient light sensor CPU load Analog filter Quadrature Encoder with push button Digital I/O

APPLICATION NOTE. Atmel AT01080: XMEGA E Schematic Checklist. Atmel AVR XMEGA E. Features. Introduction

APPLICATION NOTE. Atmel AVR057: Internal RC Oscillator Calibration for ATtiny4/5/9/10/20/40. 8-bit Atmel Microcontrollers. Features.

Atmel QT600 Quick Start Guide Touch Solutions

Atmel AVR32847: Migration from/to the UC3L0 64/32/16 from/to the UC3L0 256/ bit Atmel Microcontrollers. Application Note.

Atmel AVR ATxmega384C3 microcontroller OLED display with 128x32 pixels resolution Analog sensors. Ambient light sensor Temperature sensor

STK521. User Guide B AVR 01/12

APPLICATION NOTE. Atmel AT02260: Driving AT42QT1085. Atmel QTouch. Features. Description

APPLICATION NOTE. Atmel AVR536: Migration from ATmega644 to ATmega644A. 8-bit Atmel Microcontrollers. Introduction

AVR1503: Xplain training - XMEGA Programmable Multi Interrupt Controller 8-bit Microcontrollers Application Note Prerequisites

APPLICATION NOTE. Atmel AVR3009: Driving QTouch Device with I 2 C Interface. Atmel QTouch. Introduction

Atmel LF-RFID Kit Comparison Chart. Application Note. Atmel LF-RFID Kit Comparison Chart. 1. Description

APPLICATION NOTE. Atmel AT03782: Using Low Power Modes in SAM4N Microcontroller. Atmel 32-bit Microcontroller. Features.

AVR1501: Xplain training XMEGA Timer/Counter 8-bit Microcontrollers Application Note Prerequisites 1 Introduction

USER GUIDE. Wireless Production Test Reference Protocol Specification Document. Atmel MCU Wireless. Description

Atmel AT697F. Rad-Hard 32-bit SPARC v8 Processor ERRATA SHEET. Active Errata List

APPLICATION NOTE. Atmel AVR116: Wear Leveling on DataFlash. 32-bit Atmel Microcontrollers. Features. Description. Wear leveling

APPLICATION NOTE. Atmel AVR2131: Lightweight Mesh Getting Started Guide. Atmel MCU Wireless. Features. Description

OLED display Sensors readout. Light sensor Temperature sensor

Atmel ATMXT143E touchscreen controller Capacitive touch ITO 320 x 240 pixel LCD display with SPI interface LED backlight

Atmel AVR1926: XMEGA-B1 Xplained Getting Started Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

Section 5 SERCOM. Tasks SPI. In this section you will learn:

AVR32917: picopower Board getting started. 32-bit Microcontrollers. Application Note. Preliminary. Features. 1 Introduction

AVR1922: Xplain Board Controller Firmware 8-bit Microcontrollers Application Note Features 1 Introduction

AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Features. Introduction. AVR 8-bit Microcontrollers APPLICATION NOTE

AVR1303: Use and configuration of IR communication module. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

32Kbytes on-chip SRAM. Viterbi decoding and CRC PRIME compliant 128-bit AES encryption Channel sensing and collision pre-detection

AVR4018: Inertial Two (ATAVRSBIN2) Hardware User's Guide. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Atmel AT697F. Rad-Hard 32-bit SPARC v8 Processor ERRATA SHEET. Active Errata List

Atmel AVR1924: XMEGA-A1 Xplained Hardware User's Guide. 8-bit Atmel Microcontrollers. Application Note. Preliminary. Features.

Atmel CryptoAuthentication Starter Kit

AVR1508: Xplain training - XMEGA DAC 8-bit Microcontrollers Application Note Features 1 Introduction

AVR42789: Writing to Flash on the New tinyavr Platform Using Assembly

AVR532: Migration from ATmega48/88/168 to ATmega48A/88A/168A. 8-bit Microcontrollers. Application Note. 1 Introduction

a clock signal and a bi-directional data signal (SCL, SDA)

AVR1315: Accessing the XMEGA EEPROM. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Getting Started with the SAM4L-EK Demo

AVR32752: Using the AVR32 UC3 Static Memory Controller. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR473: ATAVRSB202 Hardware User Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

Atmel AT32UC3A3256 microcontroller 64MBit SDRAM Analog input (to ADC) Temperature sensor RC filter

AVR1512: XMEGA-A1 Xplained training - XMEGA Basics. 8-bit Atmel Microcontrollers. Application Note. Prerequisites. 1 Introduction

AVR42772: Data Logger Demo Application on XMEGA A1U Xplained Pro. Introduction. Features. AVR XMEGA Microcontrollers APPLICATION NOTE

AVR32901: EVKLCD100/EVKLCD101 Hardware User's Guide. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AT03975: Getting Started with SAM L21. Descripton. Features. SMART ARM-Based Microcontroller APPLICATION NOTE

One-channel Toggle-mode Touch Sensor IC with Power Management Functions AT42QT1012. Summary

AVR097: Migration between ATmega128 and ATmega1281/ATmega bit Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR ATxmega384C3 microcontroller OLED display with pixels resolution Analog sensors. Ambient light sensor Temperature sensor

AVR based 125kHz RFID Evaluation Kit (Re)Programming Guide ATA2270-EK1. Overview. Fuse Settings: ISP Programming

APPLICATION NOTE. AT11008: Migration from ATxmega16D4/32D4 Revision E to Revision I. Atmel AVR XMEGA. Introduction. Features

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATtiny87 ATtiny167 Automotive

Native route discovery algorithm

AVR32 UC3 Software Framework... User Manual

SAM4 Reset Controller (RSTC)

AT60142H/HT. Rad-Hard 512Kx8 Very Low Power CMOS SRAM ERRATA-SHEET. Active Errata List. Errata History. Abbreviations. 1.

APPLICATION NOTE. Atmel AT03261: SAM D20 System Interrupt Driver (SYSTEM INTERRUPT) SAM D20 System Interrupt Driver (SYSTEM INTERRUPT)

ATAES132A Firmware Development Library. Introduction. Features. Atmel CryptoAuthentication USER GUIDE

ATECC108/ATSHA204 USER GUIDE. Atmel Firmware Library. Features. Introduction

APPLICATION NOTE. AT05567: TC Capture on External Interrupt with the Event System on SAM D20. Preface ASF PROJECT DOCUMENTATION

AT697E. Application Note. Checking AT697E Code for Occurrence of LDF/FPOPd Instructions Sequence with a dependency on an Odd-Numbered Register

AT06467: Getting started with SAM D09/D10/D11. Features. Description. SMART ARM-based Microcontrollers APPLICATION NOTE

USER GUIDE. ZigBit USB Stick User Guide. Introduction

AVR32401: AVR32 AP7 Linux Interfacing DataFlash. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-megabyte, 4-megabyte, and 2-megabyte 2.7-volt Only DataFlash Cards AT45DCB008D AT45DCB004D AT45DCB002D. Not Recommended for New Design

Non Volatile Rad Hard Reprogrammable FPGA. ATF280 SRAM-based FPGA AT69170 Serial EEPROM. 2x SRAM-based FPGA designed for Space use - ATF280

Embedded AVR Microcontroller Including RF Transmitter and Immobilizer LF Functionality for Remote Keyless Entry ATA5795. Summary.

ATDH2200E Programming Kit... User Guide

QTouch 8-key Touch Sensor IC AT42QT1085. Summary

Asynchronous SRAM Operating Voltage: 5V Read Access Time: 40 ns Write Cycle Time: 30 ns Very Low Power Consumption (Pre-RAD)

AT09381: SAM D - Debugging Watchdog Timer Reset. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

8-bit Microcontroller. Application Note. AVR320: Software SPI Master

APPLICATION NOTE. AT6486: Using DIVAS on SAMC Microcontroller. SMART ARM-Based Microcontroller. Introduction. Features

USER GUIDE EDBG. Description

CAN Microcontrollers. Application Note. Migrating from T89C51CC01 to AT89C51CC03. Feature Comparison

USER GUIDE. Atmel QT1 Xplained Pro. Preface

Ethernet1 Xplained Pro

32Kbytes on-chip SRAM Up to 256Kbytes external SRAM

APPLICATION NOTE. AT04470: Differences between SAM D21 Variants A, B, and L. 32-bit Microcontroller. Introduction

USER GUIDE. Atmel OLED1 Xplained Pro. Preface

CAN, 80C51, AVR, Microcontroller. Application Note

EDBG. Description. Programmers and Debuggers USER GUIDE

AT91 ARM Thumb Microcontrollers. Application Note. AT91 Host Flash Loader. 1. Package Contents. 2. Definition of Terms. 3.

AT17F Series. Application Note. Programming Circuits for AT17F Series Configurators with Xilinx FPGAs. 1. Introduction

USER GUIDE. Atmel Segment LCD1 Xplained Pro. Preface

WINC1500 Software. Release Notes VERSION : DATE : JULY Abstract

AT11512: SAM L Brown Out Detector (BOD) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

High-performance Electrically Erasable Programmable Logic Device

USER GUIDE. Atmel QT6 Xplained Pro. Preface

AT21CS Series Reset and Discovery. Introduction. Serial EEPROM APPLICATION NOTE

Application Note. Microcontrollers. Using Keil FlashMon Emulator with AT89C51CC01/03 AT89C51CC01/ Summary. 2. Background overview

AT91 ARM Thumb Microcontrollers. Application Note. Using the ECC Controller on AT91SAM9260/9263 and AT91SAM7SE Microcontrollers. 1.

APPLICATION NOTE. AT03498: Low Power Modes in SAM3 Family. Atmel AT91 ARM Cortex Microcontrollers. Introduction

QT3 Xplained Pro. Preface. Atmel QTouch USER GUIDE

Atmel AVR944: Atmel LED Driver Library for 8- bit AVR. 8-bit Atmel. Microcontroller. Application Note. Features. 1 Introduction

Smart RF Device Family - Getting Started Guide. Features. Description. References ATAN0115 APPLICATION NOTE

Transcription:

APPLICATION NOTE Atmel AVR1638: XMEGA RTC Calibration 8-bit Atmel Microcontrollers Features Example software project which performs RTC calibration with help of an external precise clock source Software has been implemented as Atmel Studio ASF example project Support for Atmel XMEGA E devices Introduction XMEGA E devices support correction on the RTC clock by taking ppm error value from CALIB register. The CALIB register has to be written by user software after external calibration or temperature correction. This application note provide example software project which performs RTC calibration with help of an external accurate clock source. The software will calculate the RTC calibration value for connected RTC clock source for current environmental condition. This value will be stored in the device EEPROM location. Later, user application code, which uses RTC peripheral and intents to perform automatic RTC clock correction, has to read this calibration value from stored EEPROM location and load in CALIB register.

Table of Contents 1. RTC clock correction... 3 2. RTC calibration... 3 2.1 Overview of calibration software... 3 2.2 How calibration works Calibration Algorithm... 4 2.2.1 Resources and configuration used in software... 4 2.2.2 Algorithm... 4 2.3 RTC calibration configuration in software... 6 2.4 Quick start guide... 6 3. Revision History... 7 2

1. RTC clock correction Atmel XMEGA E devices support a feature by which RTC can do internal correction on the RTC crystal clock by taking the ppm error value from the CALIB register. The CALIB register has to be written by user software after external calibration or temperature correction. Correction is done within an interval of approximately 1 million RTC clock cycles. The correction operation is performed as a single cycle operation adding or removing one cycle, depending on the nature of error. These single cycle operations will be performed repeatedly the error number of times (ERROR [6:0] - CALIB Register) spread throughout the 1 million cycle correction interval. The final correction of the clock will be reflected in the RTC count value available through the CNTL and CNTH registers. This feature allows user to choose relatively cheaper and not very highly accurate RTC crystal/clock for RTC application. To achieve higher timing accuracy from such RTC, prior to download of user application, the error from such crystal clock has to be calibrated by separate software which will find the calibration value. Later, in user application code, which uses RTC, need to load this calibration value in CALIB register as part of RTC init routine. In short, XMEGA E devices support only RTC clock correction, but not calibration. Hence, finding the calibration value is the responsibility of the user. 2. RTC calibration As explained in Chapter 1, finding calibration value is responsibly of user. This application note will help exactly to meet this task with ready to use source code. The software has been implemented as an example project in Atmel Studio ASF. The ASF project is RTC Calibration Demo application. 2.1 Overview of calibration software Calibration set-up uses very precise external clock connected at PC4 (more and more precise clock means lesser error in RTC calibration value calculation) as system clock source. With a minimum clock of 2MHz, the RTC can be calibrated to an accuracy of ±0.5ppm RTC can use either external clock from TOSC1 or crystal oscillator on TOSC By comparing number of RTC clocks with at least 1 million system clock (assumed no error in system clock), RTC calibration value will be calculated The calibration value, which can be directly used to load in to RTC-CALIB register, will be stored in configurable EEPROM address Calibration status will also be loaded in another configurable EEPROM address XMEGA E support maximum correction of 127ppm If RTC clock error is more than 127ppm, correction is not possible and calibration status will be failure. Failure is indicated with status value 0x02 If RTC clock error is less than or equal to 127ppm, correction is possible and calibration status will be success. Success is indicated with status value 0x01 3

2.2 How calibration works Calibration Algorithm This section explains device configuration and algorithm used to find calibration value. 2.2.1 Resources and configuration used in software Precise external clock connected at PC4 used as system clock RTC with clock source as either external clock from TOSC1 or crystal oscillator on TOSC Load RTC Period Register with a value so that the duration of the period is equal to at least 1 million periods of the system clock. As an example, with system clock of 2MHz, RTC clock of 32.768kHz and RTC PER register with 0x8000 will generate 2 million system clock periods at RTC overflow. This configuration will lead to ±0.5ppm calibration accuracy Timer counter 4 and 5 together works in 32-bit input capture mode by cascading both Timer counter 4 used with below configuration In pulse width and frequency capture mode, with event selection as event channel-1 Clock source is system clock Capture channel A is enabled Timer counter 5 used with below configuration In pulse width and frequency capture mode, with event selection as event channel-1 Clock source is event channel-2 Event delay is enabled to operate in 32-bit input capture mode Capture channel A is enabled Port C, Pin7 (PC7) configuration PC7 direction is output Configure PC7 for input sense in rising edge Configure to out event channel-0 on PC7 Event system configuration Event Channel-0 is configured for RTC overflow Event Channel-1 is configured Port C, Pin7 (PC7) change Event Channel-2 is configured TC4 overflow 2.2.2 Algorithm After configurations made as given above, start both RTC and TC4/5 Synchronize between RTC start TC4/5 start before getting 32-bit capture value to ensure correct capture value. For this, wait for the TC4 capture flag is set and clear it Wait for new capture flag of TC4 and read out both TC4 and TC5 capture value Compare this 32-bit capture value with expected value. Any deviation indicates the error in RTC clock Convert the error into ppm. That is error per million If capture value is more than expected value, it means RTC clock is slower. Hence need to make the RTC clock faster for correction. That is, sign bit of CALIB is 1 If capture value is less than expected value, it means RTC clock is faster. Hence need to make the RTC clock slower for correction. That is, sign bit of CALIB is 0 Note that when the required correction is speeding up the clock by skipping cycles (that is, if sign bit of CALIB is 1), it is required to run the RTC prescaler at a minimum setting of DIV2(RTC clock/2) A flow chart of the RTC calibration algrothm is shown in Figure 2-1. 4

Figure 2-1. Flow chart of the RTC calibration algorithm. 5

2.3 RTC calibration configuration in software Refer the header file conf_rtc_calibration.h, under src/config folder from RTC calibration demo ASF project. From conf_rtc_calibration.h, make below configurations as per user requirement/setup RTCCALIB_SYSTEM_CLOCK_IN_MHZ System clock value in MHz RTCCALIB_EEPROM_ADDR_TO_STORE EEPROM address where calculated calibration value to be stored RTCCALIB_STAT_EEPROM_ADDR EEPROM address where calibration status to be stored RTCCALIB_RTC_CLK_SRC RTC clock source Refer the header file conf_clock.h, under src/config folder from RTC calibration demo ASF project. From conf_clock.h, make below configuration as per user requirement/setup BOARD_XOSC_HZ External system clock frequency value 2.4 Quick start guide Here it is assumed that, working user board based on an Atmel ATxmega E device will be used to run this application note software. If default settings are made, then it is not necessary to change any configuration values. 1. Connect external clock of value 2MHz (default system clock value) at port pin PC4. 2. Connect RTC clock 32.768 khz at TOSC1 pin (Default RTC clock source). This is the clock to be calibrated. 3. Open Atmel Studio ASF project RTC calibration demo project and select proper XMEGA E device. Default device selected is ATxmega32E5. 4. To enable proper debugging, from Atmel studio, Project -> Properties -> AVR /GNU C Compiler -> Optimization, select use rjmp/rcall(limited range) on >8K devices. 5. Build and download the.hex file to user board. 6. After running this.hex file in user board, calibration value will be stored in EEPROM address 0 (0 is default address configuration) and calibration status will be stored in EEPROM address 1 (1 is default address configuration). 7. Here calibration routine is finished and now user application can be downloaded. 8. Ensure that EEPROM content is preserved before downloading user application code. 9. User application code should first read calibration status from stored EEPROM location. 10. If calibration status is success (if status is 0x01), read the calibration value from stored EEPROM location and load in to CALIB register to enable RTC correction. 11. If calibration status is failure (if status is 0x02), it means RTC clock error is more than 127ppm and hence correction is not possible. 6

3. Revision History Doc. Rev. Date Comments 42042A 11/2012 Initial document release 7

Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: (+1)(408) 441-0311 Fax: (+1)(408) 487-2600 www.atmel.com Atmel Asia Limited Unit 01-5 & 16, 19F BEA Tower, Millennium City 5 418 Kwun Tong Road Kwun Tong, Kowloon HONG KONG Tel: (+852) 2245-6100 Fax: (+852) 2722-1369 Atmel Munich GmbH Business Campus Parkring 4 D-85748 Garching b. Munich GERMANY Tel: (+49) 89-31970-0 Fax: (+49) 89-3194621 Atmel Japan G.K. 16F Shin-Osaki Kangyo Building 1-6-4 Osaki Shinagawa-ku, Tokyo 141-0032 JAPAN Tel: (+81)(3) 6417-0300 Fax: (+81)(3) 6417-0370 2012 Atmel Corporation. All rights reserved. / Rev.: Atmel, Atmel logo and combinations thereof, AVR, Enabling Unlimited Possibilities, XMEGA, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others. 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 CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.