Fujitsu Microelectronics Europe Application Note MCU-AN-300071-E-V10 FR FAMILY 32-BIT MICROCONTROLLER MB91460 ALARM COMPARATOR APPLICATION NOTE
Revision History Revision History Date 2008-04-22 V1.0, First draft, HPi Issue This document contains 13 pages. MCU-AN-300071-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 (eg. 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-300071-E-V10
Contents Contents REVISION HISTORY... 2 WARRANTY AND DISCLAIMER... 3 CONTENTS... 4 1 INTRODUCTION... 5 1.1 Key Features... 5 2 THE ALARM COMPARATOR... 6 2.1 Introduction... 6 2.2 Block Diagram... 6 2.3 Voltage Detection Areas... 7 2.4 Standby Modes... 7 2.5 Registers... 8 2.5.1 Alarm Comparator Control/Status Register (ACSRn)... 8 2.5.1.1 States of OUT0 and OUT1 and Voltage Condition... 8 3 ALARM COMPARATOR EXAMPLE... 9 3.1 Under-Voltage and Over-Voltage with AVDD and AVSS as Reference Voltage... 9 4 ADDITIONAL INFORMATION... 11 LIST OF FIGURES... 12 LIST OF TABLES... 13 MCU-AN-300071-E-V10-4 - Fujitsu Microelectronics Europe GmbH
Chapter 1 Introduction 1 Introduction This application note describes the functionality of the Alarm Comparator and gives some examples. The Alarm Comparator is used for detection of under-voltage or over-voltage conditions. 1.1 Key Features Detection of Under-Voltage and Over-Voltage by comparison of external voltage input with AVDD/AVSS Generation of Interrupt on detection of Under-Voltage or Over-Voltage condition Controlled power consumption by choosing appropriate power mode Run Mode by default (after power-on) Fujitsu Microelectronics Europe GmbH - 5 - MCU-AN-300071-E-V10
Chapter 2 The Alarm Comparator 2 The Alarm Comparator THE BASIC FUNCTIONALITY OF THE ALARM COMPARATOR 2.1 Introduction The Alarm Comparator is used to detect under-voltage and over-voltage at an external analog input pin. It can be compared with AVDD/AVSS. It can be switched to fast or slow detection mode. The slow mode reduces the power consumption of this module. By default, the alarm comparator is in run mode. 2.2 Block Diagram Figure 2-1 shows the internal block diagram of the Alarm Comparator. Figure 2-1: Alarm Comparator block diagram MCU-AN-300071-E-V10-6 - Fujitsu Microelectronics Europe GmbH
Chapter 2 The Alarm Comparator 2.3 Voltage Detection Areas AV DD 0.8 AV DD 0.4 AV DD AV SS Over-Voltage Normal Operation Under-Voltage 2.4 Standby Modes Figure 2-2: Voltage Detection Areas It should be noted that the digital part of the alarm comparator is stopped in STOP or TIMER mode and it s operating in SLEEP mode. The analog part status is dependent on the PD bit of the ACSRn register. Hence it is possible to wake up only from the SLEEP mode (and not from STOP or TIMER mode) in the event of under / over voltage interrupts (if the analog comparator is in RUN mode and these interrupts are enabled). Before switching to these modes it is advisable to put the alarm comparator in the power down mode, if the current consumption is critical for the application. For this purpose the interrupt should be disabled first and then alarm comparator should be put to power down mode. Fujitsu Microelectronics Europe GmbH - 7 - MCU-AN-300071-E-V10
Chapter 2 The Alarm Comparator 2.5 Registers 2.5.1 Alarm Comparator Control/Status Register (ACSRn) Bit No. Name Explanation Initial Value 7 MD Mode Select 0 6 OV_EN Over-Voltage Interrupt Enable 5 UV_EN Under-Voltage Interrupt Enable Output of Alarm 4 OUT2 Comparator UV 3 OUT1 Output of Alarm Comparator OV 2 IRQ Interrupt Request 1 IEN Interrupt Enable 0 0 PD Power Down Mode 1 1 X X X 0 Value Operation 0 Slow Mode (less power consumption) 1 Fast Mode (high power consumption) 0 No Interrupt in case of Over-Voltage 1 Interrupt in case of Over-Voltage 0 No Interrupt in case of Under-Voltage 1 Interrupt in case of Under-Voltage 0 ALARMn < 0.4 * AVDD 1 ALARMn > 0.4 * AVDD 0 ALARMn < 0.8 * AVDD 1 ALARMn > 0.8 * AVDD 0 No Under-Voltage or Over-Voltage Condition detected 1 Under-Voltage or Over-Voltage Condition detected 1 0 Disable Interrupt 1 Enable Interrupt 0 Run Mode (Analog Part) 1 Power Down Mode (Analog Part) Table 2-1: ACSRn 2.5.1.1 States of OUT0 and OUT1 and Voltage Condition OUT0 OUT1 Condition 0 0 Under-Voltage 0 1 Not possible 1 0 Normal Operation 1 1 Over-Voltage Table 2-2: Analog Comparator Outputs in Different Voltage Conditions 1 It should be noted that the IRQ bit will be set with the next positive transition of CLKP after detecting an interrupt event and it will remain set unless and until the under-voltage or over-voltage condition persists. In such situation if the IEN is set to 1, the interrupt service routine will be executed even after clearing the IRQ bit in it. Hence to clear an interrupt caused by a persistent Under-Voltage or Over-Voltage condition the OVEN and/or UVEN bits should be cleared first and then the IRQ bit should be cleared separately. MCU-AN-300071-E-V10-8 - Fujitsu Microelectronics Europe GmbH
Chapter 3 Alarm Comparator Example 3 Alarm Comparator Example EXAMPLE FOR THE ALARM COMPARATOR 3.1 Under-Voltage and Over-Voltage with AVDD and AVSS as Reference Voltage In this example AVDD and AVSS are used for Reference Voltage. Please note that in this example the root cause for the Alarm Comparator interrupt is not reset. If under-voltage or over-voltage persists after the ISR, the interrupt is generated again. To prevent this, the IEN bit or OVEN and/or UVEN bits of the ACSR0 may be set to 0 in the ISR before clearing the interrupt flag (IRQ). Main.c /* 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 InitAlarmComp (void) { ACSR0 = 0x62; // Slow Mode, Over and Undervoltage, Interrupt enable, Run Mode } /*---------------------------------------------------------------------------*/ void main(void) { InitIrqLevels(); set_il(7); // allow all levels EI(); // globally enable interrupts InitAlarmComp(); } while(1); /*---------------------------------------------------------------------------*/ interrupt void AlarmISR (void) { if (ACSR0_OUT1 && ACSR0_OUT2) { // Overvoltage (Vin > 0.8 * AVDD) // // Do something... } else { // Undervoltage (Vin < 0.4 * AVDD) // // Do something... } ACSR0 = 0x62; // clear Interrupt } Fujitsu Microelectronics Europe GmbH - 9 - MCU-AN-300071-E-V10
Chapter 3 Alarm Comparator Example vectors.c /* 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) {... } ICR60 = 30; /* Alarm Comperator 0 */... /* ISR prototype */ interrupt void AlarmISR (void);... #pragma intvect AlarmISR 136 // Alarm Comparator of MB9634x Series... With the following schematic, the code above can be tested easily. Figure 3-1: Example Test Schematic MCU-AN-300071-E-V10-10 - Fujitsu Microelectronics Europe GmbH
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_alarmcomp It can be found on the following Internet page: http://mcu.emea.fujitsu.com/mcu_product/mcu_all_software.htm Fujitsu Microelectronics Europe GmbH - 11 - MCU-AN-300071-E-V10
List of Figures List of Figures Figure 2-1: Alarm Comparator block diagram... 6 Figure 2-2: Voltage Detection Areas... 7 Figure 3-1: Example Test Schematic... 10 MCU-AN-300071-E-V10-12 - Fujitsu Microelectronics Europe GmbH
List of Tables List of Tables Table 2-1: ACSRn... 8 Table 2-2: Analog Comparator Outputs in Different Voltage Conditions... 8 Fujitsu Microelectronics Europe GmbH - 13 - MCU-AN-300071-E-V10