8051 Flash Microcontroller. Application Note. A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller



Similar documents
AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

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

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

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

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

Application Note. Atmel ATSHA204 Authentication Modes. Prerequisites. Overview. Introduction

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT91SAM ARM-based Flash MCU. Application Note

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

Application Note. Atmel CryptoAuthentication Product Uses. Atmel ATSHA204. Abstract. Overview

APPLICATION NOTE. Atmel AT04389: Connecting SAMD20E to the AT86RF233 Transceiver. Atmel SAMD20. Description. Features

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

APPLICATION NOTE. Atmel LF-RFID Kits Overview. Atmel LF-RFID Kit. LF-RFID Kit Introduction

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR1017: XMEGA - USB Hardware Design Recommendations. 8-bit Atmel Microcontrollers. Application Note. Features.

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Atmel AT02985: User s Guide for USB-CAN Demo on SAM4E-EK. Atmel AVR 32-bit Microcontroller. Features. Description.

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge

Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers. 8-bit Atmel Microcontrollers. Application Note.

AVR1321: Using the Atmel AVR XMEGA 32-bit Real Time Counter and Battery Backup System. 8-bit Microcontrollers. Application Note.

How To Design An Ism Band Antenna For 915Mhz/2.4Ghz Ism Bands On A Pbbb (Bcm) Board

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

AT88CK490 Evaluation Kit

APPLICATION NOTE. AT07175: SAM-BA Bootloader for SAM D21. Atmel SAM D21. Introduction. Features

Software Prerequisites Linux Ubuntu LTS. Estimated completion time: 15min. The goal of this hands-on is to:

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

General Porting Considerations. Memory EEPROM XRAM

USER GUIDE EDBG. Description

APPLICATION NOTE. Atmel AT01095: Joystick Game Controller Reference Design. 8-/16-bit Atmel Microcontrollers. Features.

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

Introducing a platform to facilitate reliable and highly productive embedded developments

AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

APPLICATION NOTE. Authentication Counting. Atmel CryptoAuthentication. Features. Introduction

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

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary. Features. Applications. 1. Description

8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

256K (32K x 8) Battery-Voltage Parallel EEPROMs AT28BV256

1Mb (64K x 16) One-time Programmable Read-only Memory

APPLICATION NOTE. Secure Personalization with Transport Key Authentication. ATSHA204A, ATECC108A, and ATECC508A. Introduction.

AVR106: C Functions for Reading and Writing to Flash Memory. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

AVR1003: Using the XMEGA Clock System. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

USER GUIDE. ZigBit USB Stick User Guide. Introduction

Application Note. 1. Introduction. 2. Associated Documentation. 3. Gigabit Ethernet Implementation on SAMA5D3 Series. AT91SAM ARM-based Embedded MPU

AT89LP Flash Data Memory. Application Note. AT89LP Flash Data Memory API. 1. Introduction. 2. Theory of Operation. 2.1 Flash Memory Operation

8-bit RISC Microcontroller. Application Note. AVR910: In-System Programming

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

Application Note. 8-bit Microcontrollers. AVR293: USB Composite Device

AVR2004: LC-Balun for AT86RF230. Application Note. Features. 1 Introduction

AN11008 Flash based non-volatile storage

Quest vworkspace Virtual Desktop Extensions for Linux

How to Calculate the Capacitor of the Reset Input of a C51 Microcontroller 80C51. Application Note. Microcontrollers. Introduction

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

APPLICATION NOTE. Atmel AVR600: STK600 Expansion, Routing and Socket Boards. Atmel Microcontrollers. Introduction

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

MODFLEX MINI GATEWAY ETHERNET USER S GUIDE

AVR32100: Using the AVR32 USART. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AT89C5131A Starter Kit... Software User Guide

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

APPLICATION NOTE. AT03155: Real-Time-Clock Calibration and Compensation. SAM3 / SAM4 Series. Scope

AN3998 Application note

APPLICATION NOTE. Atmel AVR2033: SAM-ICE Adapter Hardware User Manual. 8-bit Atmel Microcontrollers. Features. Introduction

APPLICATION NOTE. AT16268: JD Smart Cloud Based Smart Plug Getting. Started Guide ATSAMW25. Introduction. Features

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

Using Altera MAX Series as Microcontroller I/O Expanders

AVR1324: XMEGA ADC Selection Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

AN10866 LPC1700 secondary USB bootloader

Capacitive Touch Technology Opens the Door to a New Generation of Automotive User Interfaces

CryptoAuth Xplained Pro

New Features and Enhancements

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

RDF1. RF Receiver Decoder. Features. Applications. Description. Ordering Information. Part Number Description Packages available

How To Fix An Lmx9838 Bluetooth Serial Port Module With Bluetooth (Bluetooth 2) From A Bluetooth Bluetooth 4.2 Device With A Bluembee 2.2 Module

AT91 ARM Thumb Microcontrollers. Application Note. Interfacing a PC Card to an AT91RM9200-DK. Introduction. Hardware Interface

AN LPC1700 timer triggered memory to GPIO data transfer. Document information. LPC1700, GPIO, DMA, Timer0, Sleep Mode

etpu Host Interface by:

Transcription:

A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller Features Temperature range -55 C to +125 C in.5 C increments LCD Display RS485 Interface Applicable to any AT89LP Microcontroller C and Assembly 1. Introduction The system presented in this application note implements a simple digital thermometer that includes a built-in LCD and RS-485 communication port. It is designed around the Atmel AT89LP2052 processor, a DS1620 digital thermometer/thermostat from Dallas Semiconductor, a small 8 X 2 LED backlit LCD, and an RS485 line interface. The system, shown in Figure 4-1, can be used as the basis for developing custom solutions for networked and stand alone data collection and control equipment. It can be centrally powered due to its low current requirement and its small size allows it to be placed almost anywhere. 2. Software The LCD driver is written entirely in C and compiles under Micro-C (from Dunfield Development Systems) using the tiny memory model. Although a canonical stackbased implementation, Micro-C includes a number of special features that make it quite suitable for generating ROMable code for small systems. The overhead incurred performing stack manipulations is made up by the library functions that are all hand coded in an highly optimized assembler. As an added benefit, Micro-C comes with fully documented library source code so special modifications can be made as circumstances arise. The first few functions contained in the LCD driver module are conventional C library implementations. PutString displays a null terminated string by merely passing characters off to PutChar until a null byte is encountered. PutChar outputs a character at a time to the LCD and handles the newline character by advancing the cursor to the beginning of the next line. PositionLcd simply sets the cursor address to the value specified by the caller. The ClearLcd function is used to clear the entire LCD and home the cursor. The functions that follow concern themselves with actual physical communication to the LCD. Since there is not a direct correspondence between the LSI s data RAM and the LCD s physical mapping, it is necessary to keep watch for certain boundary conditions. When a boundary is encountered, the cursor must be repositioned in order to keep the output contiguous. Since all displayable data must pass through DataWr, it makes sense to contain the corrective actions here. To handle this problem, keep track of the logical cursor position and invoke a remedial maneuver whenever discontinuity may occur. 8051 Flash Microcontroller Application Note

3. Digital Temperature There are two ways you can accomplish this: Read the LCD s status register (to get the cursor address) or Keep a local copy just for your reference. Not wanting to waste a pin to control the LCD s read/write line (it runs in write-only mode), the latter approach was adopted. Here, the global register (IRAM actually) variable Cursor is used for this purpose. Cursor is consulted prior to any data write operation. If a correction is necessary, a new cursor address is generated and dispatched to the LCD control register via CommandWr. Following this, DataWr splits the data byte into nibbles (remember the LCD operates using a 4- bit bus) and falls through to handle the actual physical transfer. Using Micro-C s extended preprocessor allows bit manipulation macros that expand directly to 8051 SETB and CLR instructions. Here, clearing DRS selects the LCD s data register and DEN is toggled to generate the data strobe. CommandWr operates similarly but does not have to deal with any cursor entanglements. It selects the command register as its destination by setting DRS high prior to clocking the nibbles across the interface. The initialization function InitLcd begins at a more rudimentary nibble oriented level since no assumption can be made as to the operational status of the LCD at this time. The first three sequences ensure that the transfer mode is set to operate over a 4-bit bus. Repeating the sequence three times ensures that the command will be recognized regardless of the operational mode of the LSI. (It is wise to make no assumptions when performing any low-level initialization.) Following this, the actual operating parameters are transferred to the LCD using the standard CommandWr function. Software for this application note may be downloaded from Atmel s Web Site or BBS. Temperature acquisition is handled using the DS1620 thermometer/thermostat IC from Dallas Semiconductor. The DS1620 contains all temperature measurement and signal conditioning circuitry on-chip and presents the processor with a 3-wire digital interface composed of a bidirectional data line DQ, a reset input \RST, and a clock input CLK. The temperature reading is provided in a 9 bit, two s complement format. The measurement range spans from -55 C to +125 C in.5 C increments. Data transfers into and out of the DS1620 are initiated by driving \RST high. Once the DS1620 s reset is released, a series of clock pulses is emitted by the processor to actually transfer the data. For transmission to the DS1620, data must be valid during the rising edge of the clock pulse. Data bits received by the processor are output on the falling edge of the clock and remain valid through the rising edge. Taking the clock high results in DQ assuming a high impedance state. The sequence can be immediately terminated by pulling \RST low which forces DQ into a high impedance state and concludes the transfer. Temperature data is transmitted over the 3- wire bus in lsb first format. A total of nine bits are transmitted where the most significant bit is the sign bit. If all nine bits are not of interest, the transfer can be terminated at any time by asserting \RST. The DS1620 support routines are coded in assembly. The DS1620 also has nonvolatile EEPROM configuration registers that hold thermostatic and operational control information. TempConfig is hardcoded to set the mode for operation under CPU control and continuous temperature conversion. Once in continuous conversion mode, the actual conversion process is started by issuing the start conversion command through TempConvert. Now the DS1620 can 2 Digital Thermometer using

Digital Thermometer using AT89LP2052 be read at any time and the last temperature conversion that was performed will be returned. This is accomplished by calling TempRead. The result is returned in the 16 bit accumulator as defined by Micro-C consisting of the B (msb) and ACC (lsb) registers. 4. Mainline Glue Coordination of the support drivers is managed by the main module. This module takes control after the Micro-C startup routine finishes. On entry, the code initializes the serial port, instructs the DS1620 to start performing temperature conversions, initializes the LCD, displays a log on message, and enters into an endless loop. This loop continuously reads the DS1620, performs a Celsius to Fahrenheit conversion, translates the resulting binary number to an ASCII string, and displays the conversion result on the LCD. Periodically the code falls through and toggles an LED and transmits the temperature data serially. The Celsius to Fahrenheit conversion is performed using the familiar equation: F = C * 9/5 + 32. Since the DS1620 returns temperature in.5 C increments the value is first divided by 2. Unlike the often impenetrable gyrations that result when working with numbers in assembler, the C representation of this calculation is perfectly clear in intent and function. A short sequence of divisions, modulos, and logical OR operations results in decimal ASCII values that make up the output string. 3

Figure 4-1. System Schematic AT89LP2052 4 Digital Thermometer using

Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: (+1) (408) 441-0311 Fax: (+1) (408) 487-2600 www.atmel.com 8051@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 Packring 4 D-85748 Garching b. Munich GERMANY Tel: (+49) 89-31970-0 Fax: (+49) 89-3194621 Atmel Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 JAPAN Tel: (+81) (3) 3523-3551 Fax: (+81)( 3) 3523-7581 2011 Atmel Corporation. All rights reserved. Atmel, Atmel logo and combinations thereof, 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 ATMEL S TERMS AND CONDITIONS OF SALE LOCATED ON ATMEL S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR- RANTY 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 OF 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 product 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 s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.