AN974 APPLICATION NOTE



Similar documents
AN3332 Application note

AN1819 APPLICATION NOTE Bad Block Management in Single Level Cell NAND Flash Memories

AN3265 Application note

HANDLING SUSPEND MODE ON A USB MOUSE

AN2146 APPLICATION NOTE

AN2604 Application note

AN1754 APPLICATION NOTE

AN820 APPLICATION NOTE INPUT/OUTPUT PROTECTION FOR AUTOMOTIVE COMPUTER

LM833 LOW NOISE DUAL OPERATIONAL AMPLIFIER

AN3252 Application note

AN2389 Application note

AN3998 Application note

AN438 APPLICATION NOTE SAFETY PRECAUTIONS FOR DEVELOPMENT TOOL TRIAC + MICROCONTROLLER

AN886 APPLICATION NOTE

L4940 series VERY LOW DROP 1.5 A REGULATORS

TDA2822 DUAL POWER AMPLIFIER SUPPLY VOLTAGE DOWN TO 3 V LOW CROSSOVER DISTORSION LOW QUIESCENT CURRENT BRIDGE OR STEREO CONFIGURATION

TDA4605 CONTROL CIRCUIT FOR SWITCH MODE POWER SUPPLIES USING MOS TRANSISTORS

SPC5-FLASHER. Flash management tool for SPC56xx family. Description. Features

UM1676 User manual. Getting started with.net Micro Framework on the STM32F429 Discovery kit. Introduction

Description. Table 1. Device summary. Order code Temperature range Package Packaging Marking

AN3270 Application note

UM0109 USER MANUAL. Public Transport Ticketing Demo

STGW40NC60V N-CHANNEL 50A - 600V - TO-247 Very Fast PowerMESH IGBT

Obsolete Product(s) - Obsolete Product(s)

HCF4010B HEX BUFFER/CONVERTER (NON INVERTING)

Single LNB supply and control IC DiSEqC 1.X compliant with EXTM based on the LNBH29 in a QFN16 (4x4) Description

HCF4081B QUAD 2 INPUT AND GATE

How To Write To An Eeprom Memory On A Flash Memory On An Iphone Or Ipro Memory On Microsoft Flash Memory (Eeprom) On A Microsoft Microsoft Powerbook (Ai) 2.2.2

LF00AB/C SERIES VERY LOW DROP VOLTAGE REGULATORS WITH INHIBIT

DDSL01. Secondary protection for DSL lines. Features. Description

AN2680 Application note

AN3354 Application note

HCF4056B BCD TO 7 SEGMENT DECODER /DRIVER WITH STROBED LATCH FUNCTION

HCF4001B QUAD 2-INPUT NOR GATE

TL074 TL074A - TL074B

L297 STEPPER MOTOR CONTROLLERS

ADJUSTABLE VOLTAGE AND CURRENT REGULATOR

ST19NP18-TPM-I2C. Trusted Platform Module (TPM) with I²C Interface. Features

TDA CHANNEL VOLUME CONTROLLER 1 FEATURES 2 DESCRIPTION. Figure 1. Package

UM1680 User manual. Getting started with STM32F429 Discovery software development tools. Introduction

AN2557 Application note

SPC5-CRYP-LIB. SPC5 Software Cryptography Library. Description. Features. SHA-512 Random engine based on DRBG-AES-128

HCF4028B BCD TO DECIMAL DECODER

CLASS-D VERTICAL DEFLECTION AMPLIFIER FOR TV AND MONITOR APPLICATION OUT CFLY + CFLY - BOOT VREG FEEDCAP FREQ. July /8

AN4108 Application note

AN2760 Application note

TN0023 Technical note

AN3990 Application note

TL084 TL084A - TL084B

AN2824 Application note

EVL185W-LEDTV. 185 W power supply with PFC and standby supply for LED TV based on the L6564, L6599A and Viper27L. Features.

ST202 5V POWERED MULTI-CHANNEL RS-232 DRIVERS AND RECEIVERS

MC34063A MC34063E DC-DC CONVERTER CONTROL CIRCUITS

M24LRxx/CR95HF application software installation guide

MC Low noise quad operational amplifier. Features. Description

Symbol Parameter Value Unit V i-o Input-output Differential Voltage 40 V I O Output Current Intenrally Limited Top

HCF4070B QUAD EXCLUSIVE OR GATE

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

Installation Guide E Dielectric Probe Kit 85071E Materials Measurement Software

UM1790 User manual. Getting started with STM32L053 discovery kit software development tools. Introduction

AN2866 Application note

HCC4541B HCF4541B PROGRAMMABLE TIMER

UA741. General-purpose single operational amplifier. Features. Applications. Description. N DIP8 (plastic package)

LM337. Three-terminal adjustable negative voltage regulators. Features. Description

UM1727 User manual. Getting started with STM32 Nucleo board software development tools. Introduction

STP80NF55-08 STB80NF55-08 STB80NF N-CHANNEL 55V Ω - 80A D2PAK/I2PAK/TO-220 STripFET II POWER MOSFET

Keysight M9485A PXIe Multiport Vector Network Analyzer. Configuration Guide

UM0985 User manual. Developing your STM32VLDISCOVERY application using the IAR Embedded Workbench software. Introduction

BUX48/48A BUV48A/V48AFI

Getting started with DfuSe USB device firmware upgrade STMicroelectronics extension

BD241A BD241C. NPN power transistors. Features. Applications. Description. NPN transistors. Audio, general purpose switching and amplifier transistors

AN1826 APPLICATION NOTE TRANSIENT PROTECTION SOLUTIONS: Transil diode versus Varistor

BD238. Low voltage PNP power transistor. Features. Applications. Description. Low saturation voltage PNP transistor

AN3155 Application note

AN4156 Application note

UM1613 User manual. 16-pin smartcard interface ST8034P demonstration board. Introduction

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

DRIVE CIRCUITS FOR POWER MOSFETs AND IGBTs

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

ETP01-xx21. Protection for Ethernet lines. Features. Description. Applications. Benefits. Complies with the following standards

ULN2801A, ULN2802A, ULN2803A, ULN2804A

AN4128 Application note

AN3110 Application note

Description. IO and RF AGC. ASIC controller and power management. Carrier recovery loop. GPIO switch matrix. Lock indicator and monitoring DVBS2 FEC

Lesson-16: Real time clock DEVICES AND COMMUNICATION BUSES FOR DEVICES NETWORK

BTB04-600SL STANDARD 4A TRIAC MAIN FEATURES

STW34NB20 N-CHANNEL 200V Ω - 34A TO-247 PowerMESH MOSFET

L78M00 SERIES POSITIVE VOLTAGE REGULATORS.

STP62NS04Z N-CHANNEL CLAMPED 12.5mΩ - 62A TO-220 FULLY PROTECTED MESH OVERLAY MOSFET

2STBN15D100. Low voltage NPN power Darlington transistor. Features. Application. Description

TDA W CAR RADIO AUDIO AMPLIFIER

Order code Temperature range Package Packaging

LM134-LM234-LM334. Three terminal adjustable current sources. Features. Description

Foreign Taxes Paid and Foreign Source Income INTECH Global Income Managed Volatility Fund

ST High voltage fast-switching NPN power transistor. Features. Applications. Description

SWITCH-MODE POWER SUPPLY CONTROLLER PULSE OUTPUT DC OUTPUT GROUND EXTERNAL FUNCTION SIMULATION ZERO CROSSING INPUT CONTROL EXTERNAL FUNCTION

Description. Table 1. Device summary

HCC/HCF4032B HCC/HCF4038B

IRF740 N-CHANNEL 400V Ω - 10A TO-220 PowerMESH II MOSFET

STEVAL-IEG001V2. Smart real-time vehicle tracking system. Features

Transcription:

AN974 APPLICATION NOTE Real time clock with ST7 Timer Output Compare By MCD Application Team 1 INTRODUCTION The purpose of this note is to present how to use the ST7 Timer output compare function. As an application example, this document presents how to generate a real time clock with counters for seconds, minutes and hours, based on a fixed basic time base. 2 GENERATING A TIME BASE WITH ST7 TIMER The ST7 timer output compare function can be used to generate the fixed time base. 2.1 TIMER CONFIGURATION AND INITIALIZATION The application example is managed using the output compare interrupts. The ST7 timer has two output compare functions whose interrupts are both enabled by the OCIE bit in the CR1 register. In this case, the Output Compare 1 (OC1) is used for time base generation while the second one (OC2) is ignored when it generates an interrupt each time the free running counter value matches the value in the OC2 register. To minimize the CPU load, we need to choose the maximum time base value that has to be multiplied to obtain one sec. For this reason the maximum timer clock divider ratio (1/8) is selected by the CC1 and CC0 bits in the CR2 register. 2.2 OUTPUT COMPARE UPDATE To maintain a fixed elapsed time between each Output Compare 1 interrupt generation, the Output compare registers (OC1HR, OC1LR) have to be updated with a fixed offset time base at each interrupt. (OCxHR, OCxLR ) = (OCxHR, OCxLR) + (OCxHR OCxLR ) offset Caution: As the ST7 can only handles 8-bit data and as the output compare function is inhibited between the write in the high (OCxHR) and the low (OCxLR) output compare registers, special care has to be taken when the updating of the 16-bit compare register. A typical algorithm flowchart is shown in Figure 1. AN974/0303 1/6 1

Figure 1. Output Compare Register Update Flowchart STORE OCxHR AND OCxLR REGISTER VALUES IN TEMPORARY REGISTERS UPDATE OCxHR AND OCxLR VALUES THROUGH TEMPORARY REGISTERS STORE NEW OCxHR REGISTER VALUE STORE NEW OCxLR REGISTER VALUE Based on the assumption that f CPU is 4-MHz, Table 1 gives some basic possible time bases with the Output compare register offset value (OCxHR, OCxLR). f timercnt = f CPU (cc1,cc0) = 4 MHz 8 = 500 KHz T timercnt = 2 us TimeBase (OCxHR OCxLR ) offset = T timercnt = TimeBase 2 us Table 1. Output Compare Register and Timebase Values with f timercnt at 500KHz Time Base [ms] 2 10 20 50 100 131.07 OCxHR OCxLR offset [hex] 03E8 1388 2710 61A8 C350 FFFF 3 REAL TIME CLOCK APPLICATION The real time clock application is based on four software counters (100ms, seconds, minutes and hours) updated by a 100ms ST7 timer output compare 1 interrupt. 2/6 2

These four counters are coded on one byte each and are updated by the Output Compare 1 interrupt routine as shown in Figure 2. Figure 2. Software Counter Update Flowchart OC1 INTERRUPT INCREMENT 100ms UPDATE OCxHR AND OCxLR REGISTER no 100ms CNT = 10? yes RESET 100ms INCREMENT SECOND no SECOND CNT = 60? yes RESET SECOND INCREMENT MINUTE no MINUTE CNT = 60? yes RESET MINUTE INCREMENT HOUR no yes HOUR CNT RESET HOUR = 24? 3/6

3.1 HARDWARE CONFIGURATION The real time clock application hardware is made of a ST72324 microcontroller timer which generates a 100ms time base through the Timer B Output Compare 1 function. Two of the software counters (seconds and minutes) are output by the microcontoller through I/O ports (PC, PF and PD) and displayed on LEDs as shown in Figure 3. The Seconds counter is shown with a red LED and the Minutes counter is shown with a pink LED. The selected crystal for this example has 8 MHz frequency which gives f CPU =4 MHz because the PLL is disabled and slow mode is not selected. Figure 3. Real Time Clock Application TIMER OC registers SOFTWARE I/O PORTS PC 2-7 PF 0,1,4,6,7 PD0 LED LED LED ST72324 RAM sw counter The RTC accuracy depends on the clock source (e.g. Resonator Oscillator) accuracy. Care should be taken especially for time critical applications. 4/6

4 SOFTWARE All the source files in assembly code as well as in C code are given in the zip file with this application note. The C code uses the software library (ST7 software library version 1.1). The source files are for guidance only. STMicroelectronics shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from use of this software. 5/6

THE PRESENT NOTE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH A NOTE AND/OR THE USE MADE BY CUSTOMERS OF THE INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights of STMicroelectronics. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of STMicroelectronics. The ST logo is a registered trademark of STMicroelectronics 2003 STMicroelectronics - All Rights Reserved. Purchase of I 2 C Components by STMicroelectronics conveys a license under the Philips I 2 C Patent. Rights to use these components in an I 2 C system is granted provided that the system conforms to the I 2 C Standard Specification as defined by Philips. STMicroelectronics Group of Companies Australia - Brazil - Canada - China - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - U.S.A. http://www.st.com 6/6