Fujitsu Microelectronics Europe Application Note MCU-AN E-V10 FR FAMILY 32-BIT MICROCONTROLLER MB91460 REAL TIME CLOCK APPLICATION NOTE

Similar documents
Fujitsu Microelectronics Europe Application Note MCU-AN E-V10 F²MC-FR FAMILY 32-BIT MICROCONTROLLER MB91460 RELOAD TIMER APPLICATION NOTE

FR FAMILY FR60 FAMILY ISR DOUBLE EXECUTION 32-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

Fujitsu Microelectronics Europe Application Note MCU-AN E-V12 F²MC-16FX FAMILY 16-BIT MICROCONTROLLER ALL SERIES CLOCK OUTPUT APPLICATION NOTE

F²MC-16LX FAMILY MB90XXX RELOCATED INTERRUPT VECTOR TABLE 16-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

F²MC-16FX FAMILY ALL SERIES FLASH SECURITY 16-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

F²MC-8L FAMILY MB89201 SERIES FLASH PROGRAMMING 8-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

F²MC-16LX FAMILY MB90F897 DUAL OPERATION FLASH 16-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

F²MC-8FX FAMILY MB951XX SERIES SYNCHRONOUS FLASH PROGRAMMING 8-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

GRAPHICS CONTROLLERS SPRITE ENGINE PERFORMANCE MB88F332 'INDIGO' MB88F333 'INDIGO-L' APPLICATION NOTE GRAPHICS COMPETENCE CENTER

16-Bit Emulator Setup for MB2141 and MB

MB90F3XX/F4XX/F5XX/F8XX/F9XX

F²MC-8FX FAMILY MB95100 SERIES EMULATOR HW SETUP 8-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

TRACE APPLICATION NOTE VERSION MB86R0X 'JADE' SERIES DEVICES & GREENHILLS TOOLCHAIN. Fujitsu Microelectronics Europe Application Note

The Bootconcept. of Fujitsu s MB91360 Devices

F²MC-16FX FAMILY ALL SERIES STANDBY MODES & POWER MANAGEMENT 16-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

Application Note. EMC Design Guide. F 2 MC-8L Family. History 04 th Jul 02 NFL V1.0 new version

Emulator Setup Instructions for MB91360

F2MC MB90385 series Evaluation Board Documentation. Revision Date Comment V New document

The following document contains information on Cypress products.

CPU369-Module Documentation. Fujitsu Microelectronics Europe GmbH Am Siebenstein Dreieich-Buchschlag, Germany

EMULATOR SETUP MB BIT COMPACT-ICE

Errata Sheet MB86296 Coral PA

Fujitsu Semiconductor Europe User Manual. FSEUGCC-UM_SK-86R12-CPU01_Rev1.1 EMERALD-P CPU MODULE SK-86R12-CPU01 USERGUIDE

Software Porting Access Library V02 to V03

EMULATOR SYSTEM MB

Application Note. Connecting standard LCD modules to. the MB90670/5 series. History 01 th Feb. 97 MM V1.0 started 28 th June 00 TKa V1.

Application Note. Startup DevKit16. History 19 th June 00 TKa V1.0 started 20 th June 00 TKa V1.1 Some minor text corrections

Fujitsu Microelectronics Europe Application Note MCU-AN E-V10 FR FAMILY 32-BIT MICROCONTROLLER MB91460 EDSU/MPU APPLICATION NOTE

F²MC-16FX FAMILY MB96340 KEY MATRIX INTERFACE USING I/O PORT 16-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

APIX AUTOMOTIVE SHELL SW-EMULATION USE CASE

SPI COMMUNICATION TO/FROM SERIAL EEPROM

FR FAMILY MB91460 SERIES MB91461 EMULATION 32-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

JASMINE- Subboard Documentation. Fujitsu Microelectronics Europe GmbH Am Siebenstein Dreieich-Buchschlag, Germany

FAQ list for MB86290 Cremson

GRAPHICS CONTROLLERS DEVICE SETUP AND FUJITSU DEVELOPER SUITE

Fujitsu Semiconductor Europe Application Note. an-mb86r12-apixprbs-rev0-20 MB86R12 EMERALD-P REV 0.2 APIX PRBS APPLICATION NOTE

F²MC-16LX/FRLITE FAMILY COMPARISON OF MB90340 AND MB91270 SERIES MCU

LAMP CONTROL AND MONITOR WITH PPG AND ADC

MB88F334 Indigo2 MB88F335 Indigo2-S MB88F336 Indigo2-N

Application Note APIX PRBS

Fujitsu Microelectronics Europe User Guide FMEMCU-SG MB88121 SERIES MB91460 SERIES EVALUATION BOARD SK-91F467-FLEXRAY SOFTWARE GUIDE

SC2000 Smart Kit Selection Checklist

FR FAMILY SK MAIN V1.2 EVALUATION BOARD USER GUIDE. Fujitsu Microelectronics Europe User Guide FMEMCU-UG

Fujitsu Microelectronics Europe Application Note MCU-AN E-V13 FR FAMILY 32-BIT MICROCONTROLLER MB91460 SWB MONITOR DEBUGGER APPLICATION NOTE

Tutorial. How to use Keil µvision with Spansion templates Spansion Inc.

FR30 example interface to external Flash Memory

GRAPHICS CONTROLLERS APIX PCB-DESIGN GUIDELINE

Fujitsu Microelectronics Europe Application Note MCU-AN E-V12 FR FAMILY 32-BIT MICROCONTROLLER MB91265 SERIES 16-BIT MAC UNIT APPLICATION NOTE

Errata Sheet MB86298 'Ruby'

End User License Agreement

MB86297A Carmine PCB Design Guide

GRAPHICS CONTROLLERS

Fujitsu Semiconductor Europe User Manual. FSEUGCC-UM_SK-88F336-01_Rev1.0 INDIGO2-N STARTERKIT SK-88F USER MANUAL

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

1.2. MCU64 Board User Guide. Development tools for 16LX Family FUJITSU MICROELECTRONICS EUROPE. Version

F²MC-8L/16LX/16FX/FR FAMILY

F²MC-8L/16LX/FR FAMILY ALL SERIES GALEP-4 8/16/32-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

STAINLESS STEEL CAST FITTINGS 150lb 304 & 316 Stainless Steel Cast Fittings Specifications

PATGuard Time Manager 2

FME FR FLASHPROGRAMMER

SonicWALL CDP 2.1 Agent Tool User's Guide

Ludlum Lumic Data Logger Software Manual Version 1.1.xx

PCMCIA Flash Card User Guide

SOFTUNE WORKBENCH MONITOR DEBUGGER FOR 8FX

FR FAMILY MB91460 SERIES FLASH PROGRAMMING 32-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

AhnLab Software License Agreement

STARTERKIT SK-86R03 'JADE-L' USERS GUIDE

FlukeView. Users Manual. Software for ScopeMeter Test Tools

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

Shimadzu LabSolutions Connector Plugin

User Manual. Atlona HDMI CAT5 Receiver to be used with AT-HD19SS or AT-HD50SS [Long Range] AT-HDRS

Instruction Sheet. PCS Series. Fiber\Cable Management Spool

ABB Network Partner. User s Manual CAP/REx 500*2.0

F²MC-8FX FAMILY MB95200H/210H SERIES HOW TO USE DBG PIN 8-BIT MICROCONTROLLER APPLICATION NOTE

ssj1708 User s Manual Version 1.3 Revised February 2nd, 2009 Created by the J1708 Experts

AtlonA. 1x12 HDMI Distribution Amplifier v1.3 AT-HD-V112. User Manual

P O W E R S U P P L Y M A N U A L

EMULATOR SYSTEM MB2147

Font Software - Commercial Desktop License

Specific Terms And Conditions for hi!share International Prepaid Airtime Top- Up Value Added Service ( hi!share International Terms )

Release Information. Revision History. Version: build 018 Release Date: 23 rd November 2011

UltraAV DisplayPort to HDMI Display MST Hub

F²MC-8FX FAMILY MB95200H/210H SERIES HOW TO USE DBG PIN 8-BIT MICROCONTROLLER APPLICATION NOTE

Trimble S6 and SPS700 Total Station Firmware

Atlona 1 by 4 HDMI Distribution Amplifier

over HDBaseT w/poe, IR & RS-232C

Webfont License End User License Agreement (EULA)

KEYBOARD DEVELOPMENT USING EXTERNAL INTERRUPT

Manual NEWBASE WebShot 1.4. Copyright by NEWBASE GmbH, Hamburg, Germany

If the firmware version indicated is earlier than the "Version 1.06", please update the unit s firmware.

Aellius LynX Office Lookup Enhancements

Quick Start Guide. Model 0260 Secondary Electronics

mikroelektronika GLCD Font Creator

FAQ list for Coral. Fujitsu Microelectronics Europe GmbH

HDEXT50M USER MANUAL Extend HD Signals over CAT 5/5e/6 up to 164ft.(50m) All Rights Reserved Version: HDEXT50M_2017V1.2

Beta Testing Licence Agreement

1. License Grant; Related Provisions.

OfficeServ Link User Manual

CX Recorder. User Guide. Version 1.0 February 8, Copyright 2010 SENSR LLC. All Rights Reserved. R V1.0

IPNexus Server Secure Instant Messaging & Integrated Collaboration

Transcription:

Fujitsu Microelectronics Europe Application Note MCU-AN-300075-E-V10 FR FAMILY 32-BIT MICROCONTROLLER MB91460 REAL TIME CLOCK APPLICATION NOTE

Revision History Revision History Date 2008-06-05 First Version; MPi Issue This document contains 18 pages. MCU-AN-300075-E-V10-2 - Fujitsu Microelectronics Europe GmbH

Warranty and Disclaimer Warranty and Disclaimer To the maximum extent permitted by applicable law, Fujitsu Microelectronics Europe GmbH restricts its warranties and its liability for all products delivered free of charge (e.g. software include or header files, application examples, target boards, evaluation boards, engineering samples of IC s etc.), its performance and any consequential damages, on the use of the Product in accordance with (i) the terms of the License Agreement and the Sale and Purchase Agreement under which agreements the Product has been delivered, (ii) the technical descriptions and (iii) all accompanying written materials. In addition, to the maximum extent permitted by applicable law, Fujitsu Microelectronics Europe GmbH disclaims all warranties and liabilities for the performance of the Product and any consequential damages in cases of unauthorised decompiling and/or reverse engineering and/or disassembling. Note, all these products are intended and must only be used in an evaluation laboratory environment. 1. Fujitsu Microelectronics Europe GmbH warrants that the Product will perform substantially in accordance with the accompanying written materials for a period of 90 days form the date of receipt by the customer. Concerning the hardware components of the Product, Fujitsu Microelectronics Europe GmbH warrants that the Product will be free from defects in material and workmanship under use and service as specified in the accompanying written materials for a duration of 1 year from the date of receipt by the customer. 2. Should a Product turn out to be defect, Fujitsu Microelectronics Europe GmbH s entire liability and the customer s exclusive remedy shall be, at Fujitsu Microelectronics Europe GmbH s sole discretion, either return of the purchase price and the license fee, or replacement of the Product or parts thereof, if the Product is returned to Fujitsu Microelectronics Europe GmbH in original packing and without further defects resulting from the customer s use or the transport. However, this warranty is excluded if the defect has resulted from an accident not attributable to Fujitsu Microelectronics Europe GmbH, or abuse or misapplication attributable to the customer or any other third party not relating to Fujitsu Microelectronics Europe GmbH. 3. To the maximum extent permitted by applicable law Fujitsu Microelectronics Europe GmbH disclaims all other warranties, whether expressed or implied, in particular, but not limited to, warranties of merchantability and fitness for a particular purpose for which the Product is not designated. 4. To the maximum extent permitted by applicable law, Fujitsu Microelectronics Europe GmbH s and its suppliers liability is restricted to intention and gross negligence. NO LIABILITY FOR CONSEQUENTIAL DAMAGES To the maximum extent permitted by applicable law, in no event shall Fujitsu Microelectronics Europe GmbH and its suppliers be liable for any damages whatsoever (including but without limitation, consequential and/or indirect damages for personal injury, assets of substantial value, loss of profits, interruption of business operation, loss of information, or any other monetary or pecuniary loss) arising from the use of the Product. Should one of the above stipulations be or become invalid and/or unenforceable, the remaining stipulations shall stay in full effect Fujitsu Microelectronics Europe GmbH - 3 - MCU-AN-300075-E-V10

Contents Contents REVISION HISTORY... 2 WARRANTY AND DISCLAIMER... 3 CONTENTS... 4 1 INTRODUCTION... 5 1.1 Key Features... 5 2 THE REAL TIME CLOCK... 6 2.1 Block Diagrams... 6 2.2 Registers... 8 2.2.1 Timer Control Register (WTCR)... 8 2.2.2 Timer Control Extended Register (WTCER)... 9 2.2.3 Sub-Second Register (WTBR)... 9 2.2.4 Second/Minute/Hour Registers (WTSR, WTMR, WTHR)... 10 2.2.5 Clock Source Selection... 10 2.2.5.1 Clock Source Configuration Register (CSCFG)... 10 3 REAL TIME CLOCK EXAMPLES... 11 3.1 RTC with main clock source and without interrupts... 11 3.2 Re-Initialize the RTC with Sub clock... 12 3.3 Initialize the Sub-Second Register in ISR... 13 3.4 Read the Time inside ISR... 14 3.5 Read the Time inside application... 15 4 ADDITIONAL INFORMATION... 16 LIST OF TABLES... 17 LIST OF FIGURES... 18 MCU-AN-300075-E-V10-4 - Fujitsu Microelectronics Europe GmbH

Chapter 1 Introduction 1 Introduction This application note describes the functionality of the Real Time Clock and gives some examples. 1.1 Key Features Clock selectable as Main Clock, Sub Clock and RC Clock 100KHz RTC is not deactivated during Stop Mode Interrupts selectable for: ½ second, 1 second, 1 minute, 1 hour, and 1 day Fujitsu Microelectronics Europe GmbH - 5 - MCU-AN-300075-E-V10

Chapter 2 The Real Time Clock 2 The Real Time Clock THE BASIC FUNCTIONALITY OF THE REAL TIME CLOCK 2.1 Block Diagrams Figure 2-1 shows the internal block diagram of the Real Time Clock. Figure 2-1: Real Time Clock block diagram MCU-AN-300075-E-V10-6 - Fujitsu Microelectronics Europe GmbH

Chapter 2 The Real Time Clock Figure 2-2 shows the simplified block diagram of the Real Time Clock. Figure 2-2: Simplified Real Time Clock block diagram Fujitsu Microelectronics Europe GmbH - 7 - MCU-AN-300075-E-V10

Chapter 2 The Real Time Clock 2.2 Registers Please write always 0 to the Reserved bits when accessing a register, if not stated otherwise. 2.2.1 Timer Control Register (WTCR) Bit No. Name Explanation Value Operation 0 Interrupt disabled Interrupt Request at 1-Day (24 15 INTE3 Interrupt, if 24 Hour (1- Hour) 1 Day)Counter overflow 0 Write: Clear Request 14 INT3 1-Day Interrupt Flag/Clear 1 Interrupt Request 0 Interrupt disabled 13 INTE2 Interrupt Request at 1-Hour Interrupt, if 1 Hour 1 Counter overflow 0 Write: Clear Request 12 INT2 1-Hour Interrupt Flag/Clear 1 Interrupt Request 0 Interrupt disabled 11 INTE1 Interrupt Request at 1-Minute Interrupt, if Minute 1 Counter overflow 0 Write: Clear Request 10 INT1 1-Minute Interrupt Flag/Clear 1 Interrupt Request 0 Interrupt disabled 9 INTE0 Interrupt Request at 1-Second Interrupt, if Second 1 Counter overflow 0 Write: Clear Request 8 INT0 1-Second Interrupt Flag/Clear 1 Interrupt Request 7-5 - Reserved - - 4 - Undefined - - 3 RUN Operation Status 2 UPDT Update Counter with written Values into WTSR, WTHR, and WTMR 0 RTC inactive 1 RTC is active 0 Write: No effect 1 Write: Update 1 - Undefined - - 0 Clear Clock and Stop it 0 ST Start 1 Load Values and Start 1 clock Table 2-1: WTCR 1 It is recommended to set the ST-Bit to 0, when changing the clock time of the RTC. MCU-AN-300075-E-V10-8 - Fujitsu Microelectronics Europe GmbH

Chapter 2 The Real Time Clock 2.2.2 Timer Control Extended Register (WTCER) Bit No. Name Explanation Value Operation 7 - Undefined - - 6 - Undefined - - 5 - Undefined - - 4 - Undefined - - 3 - Undefined - - 2 - Undefined - - 0 Interrupt disabled 1 INTE4 Enable Interrupt Request at Half- Second (500 ms) 1 0 INT4 Half-Second Interrupt Flag/Clear 2.2.3 Sub-Second Register (WTBR) Table 2-2: WTCER Interrupt, if Half-Second Counter overflow 0 Write: Clear Request 1 Interrupt Request This register contains the 21-Bit reload value, which divides the clock source. The value to be programmed in WTBR register should be actual source clock-frequency (one among CLKMAIN, CLKSUB or CLKRC100KHz) divide by 4 in order to get half a second interrupt (0.5 s). This is also because there is a default prescaler of divide by 2 (please refer Figure 2-2). The lower 8 Bits of this value is stored in WTBR2, the middle 8 Bits of this value is stored in WTBR1 and the remaining upper 5 Bits of the value in the lower 5 Bits of WTBR0. The following table shows example values for different clock sources. Clock Source WTBR decimal WTBR hexadecimal Main Clock 4 MHz 1000000 0x0F4240 RC Clock 100 khz 25000 0x0061A8 Sub Clock 32768 Hz 8192 0x002000 Table 2-3: Clock Source and WTBR values Sub-Second Registers can be accessed via byte/half-word/word access. Fujitsu Microelectronics Europe GmbH - 9 - MCU-AN-300075-E-V10

Chapter 2 The Real Time Clock 2.2.4 Second/Minute/Hour Registers (WTSR, WTMR, WTHR) The lower 6 Bits of the WTSR contains the actual second counter value. Writing a value to it memorizes the value. The Second-Counter is updated with this value by writing 1 to WTCR_UPDT. The lower 6 Bits of the WTMR contains the actual minute counter value. Writing and reading has the same behaviour like for WTSR. The lower 5 Bits of the WTHR contains the actual hour counter value. Writing and reading has the same behaviour like for WTSR. Please store only reasonable values to these registers. If values, that do not present a clock time, are used, the behaviour of the RTC will be undefined. These registers can be accessed via byte/half-word access. 2.2.5 Clock Source Selection The RTC clock source can be selected using CSC[1:0] bits of Clock Source Configuration Register (CSCFG). 2.2.5.1 Clock Source Configuration Register (CSCFG) Bit No. Name Explanation Value Operation 0, 0 Main Clock (CLKMAIN) 1, 0 CKC1,0 RTC Clock Select Selection 0, 1 Sub Clock (CLKSUB) 1, 0 RC Clock (CLKRC100kHz) 1, 1 prohibited Table 2-4: WTCKSR The other bits of CSCFG register are not discussed here. MCU-AN-300075-E-V10-10 - Fujitsu Microelectronics Europe GmbH

Chapter 3 Real Time Clock Examples 3 Real Time Clock Examples EXAMPLES FOR THE REAL TIME CLOCK 3.1 RTC with main clock source and without interrupts /* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */ /* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */ /* ELIGIBILITY FOR ANY PURPOSES. */ /* (C) Fujitsu Microelectronics Europe GmbH */ /*---------------------------------------------------------------------------*/ #define DividerMC 1000000 void InitRTCAfterReset (void) WTBR = DividerMC; // Set Sub-Second Prescaler WTCR_INTE0 = 0; WTCR_INTE1 = 0; WTCR_INTE2 = 0; WTCR_INTE3 = 0; WTCER_INTE4 = 0; CSCFG_CSC = 0; // No Interrupts // Main Clock Source WTSR = 56; // Seconds: 56 WTMR = 34; // Minutes: 34 WTHR = 12; // Hours: 12 WTCR_ST = 1; //... and go! void main(void)... InitRTCAfterReset (); // Init and start the RTC... The above example demonstrates how to initialize RTC immediately after a Reset. Here it is considered that the Main Clock is 4 MHz. Fujitsu Microelectronics Europe GmbH - 11 - MCU-AN-300075-E-V10

Chapter 3 Real Time Clock Examples 3.2 Re-Initialize the RTC with Sub clock /* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */ /* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */ /* ELIGIBILITY FOR ANY PURPOSES. */ /* (C) Fujitsu Microelectronics Europe GmbH */ /*---------------------------------------------------------------------------*/ #define DividerSC 8192 void InitRTC (void) WTCR_ST = 0; // Stop the RTC while (WTCR_RUN!= 0); // Wait till the RTC stops WTBR2 = (0xFFFF & DividerSC); // Set Sub-Second Prescaler WTBR1 = (DividerSC >> 16); WTSR = 28; // Seconds: 28 WTMR = 59; // Minutes: 59 WTHR = 18; // Hours: 18 CSCFG_CKC = 1; WTCR_ST = 1; // Sub Clock Source //... and go! The above examples demonstrates how to initialize the Sub-Second, Second, Minute & Hour registers if the RTC is already running. Here it is considered that the Sub Clock is 32.768 khz. MCU-AN-300075-E-V10-12 - Fujitsu Microelectronics Europe GmbH

Chapter 3 Real Time Clock Examples 3.3 Initialize the Sub-Second Register in ISR /* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */ /* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */ /* ELIGIBILITY FOR ANY PURPOSES. */ /* (C) Fujitsu Microelectronics Europe GmbH */ /*---------------------------------------------------------------------------*/ #define DividerRC 25000 interrupt void RealTimeClock (void) WTCR_INT0 = 0; // Clear the interrupt flag WTBR2 = (0xFFFF & DividerRC); // Set Sub-Second Prescaler WTBR1 = (DividerRC >> 16); The above examples demonstrates how to initialize the Sub_Second register within the RTC interrupt service routine (if RTC is already running). Here the RTC does not need to be stopped since there is enough time to securely modify the registers until the next reload operation (next second interrupt). It should be noted that the RTC Second interrupt needs to be enabled. Please note, that the corresponding interrupt vector and level has to be defined in the vectors.c module of our standard template project. /* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */ /* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */ /* ELIGIBILITY FOR ANY PURPOSES. */ /* (C) Fujitsu Microelectronics Europe GmbH */ /*---------------------------------------------------------------------------*/ void InitIrqLevels(void)... ICR58 = 30; /* Real Time Clock */ /* Calibration Unit */... interrupt void RealTimeClock (void); // Prototype... #pragma intvect RealTimeClock 132 /* Real Time Clock */ Fujitsu Microelectronics Europe GmbH - 13 - MCU-AN-300075-E-V10

Chapter 3 Real Time Clock Examples 3.4 Read the Time inside ISR /* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */ /* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */ /* ELIGIBILITY FOR ANY PURPOSES. */ /* (C) Fujitsu Microelectronics Europe GmbH */ /*---------------------------------------------------------------------------*/ extern unsigned char second, minute, hour; interrupt void RealTimeClock (void) WTCR_INT0 = 0; second = WTSR; minute = WTMR; hour = WTHR; // Clear the interrupt flag It is recommended that the interrupts (INT0-4) should be used to read the time information, as this would eliminate the possibility of reading incorrect values from time (hour/minute/second) registers (in case of carry while reading). In the above example the Time information is read in the RTC Second (INT0) interrupt service routine. Please note that the corresponding interrupt vector and level has to be defined in the vectors.c module as shown in the above example. MCU-AN-300075-E-V10-14 - Fujitsu Microelectronics Europe GmbH

Chapter 3 Real Time Clock Examples 3.5 Read the Time inside application /* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */ /* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */ /* ELIGIBILITY FOR ANY PURPOSES. */ /* (C) Fujitsu Microelectronics Europe GmbH */ /*---------------------------------------------------------------------------*/ #define TRUE 1 #define FALSE 0 unsigned char second, minute, hour; unsigned char second1, minute1, hour1; unsigned int time, time1; void ReadTime (void) unsigned char result = FALSE; /* Normally this loop would exit at 1st iteration (e.g. 02:59:59 -> 03:00:00). In some cases only this loop will have 2 iterations at the max (e.g. 02:59:59 -> 03:59:59 (1st Iteration), 03:00:00 -> 03:00:00 (2nd Iteration)).*/ while (result!= TRUE) /* First Set of Time */ second = WTSR; minute = WTMR; hour = WTHR; /* Second Set of Time */ second1 = WTSR; minute1 = WTMR; hour1 = WTHR; /* Calculating absolute seconds for first set of time */ time = hour*3600 + minute*60 + second; /* Calculating absolute seconds for second set of time */ time1 = hour1*3600 + minute1*60 + second1; /* If the difference in the first & second set is 0 or 1 then the second set contains the latest accurate time information */ if (((time1 time) == 1) ((time1 time) == 0))) result = TRUE; /* The following condition takes care of day change situation 23:59:59 -> 00:00:00, and the second set contains the latest accurate time information */ else if (time == 86399 && time1 == 0) result = TRUE; // 23:59:59 -> 00:00:00 The above example demonstrates how the time can be read inside an application (without using interrupts). This also takes care of reading the time (hour/minute/second) registers at the very timing of changing over the hour or minute boundary. Here the time registers are read twice. Then it is converted into absolute seconds value and if difference between the old and the new value is 0/1 or the old value is 86399 & the new value is 0 (i.e. 23:59:59 -> 00:00:00), then the second set (second1/minute1/hour1) is considered to contain the correct time information. Fujitsu Microelectronics Europe GmbH - 15 - MCU-AN-300075-E-V10

Chapter 4 Additional Information 4 Additional Information Information about FUJITSU Microcontrollers can be found on the following Internet page: http://mcu.emea.fujitsu.com/ The software example related to this application note is: 91460_rtc_init_read It can be found on the following Internet page: http://mcu.emea.fujitsu.com/mcu_product/mcu_all_software.htm MCU-AN-300075-E-V10-16 - Fujitsu Microelectronics Europe GmbH

List of Tables List of Tables Table 2-1: WTCR... 8 Table 2-2: WTCER... 9 Table 2-3: Clock Source and WTBR values... 9 Table 2-4: WTCKSR... 10 Fujitsu Microelectronics Europe GmbH - 17 - MCU-AN-300075-E-V10

List of Figures List of Figures Figure 2-1: Real Time Clock block diagram... 6 Figure 2-2: Simplified Real Time Clock block diagram... 7 MCU-AN-300075-E-V10-18 - Fujitsu Microelectronics Europe GmbH