Download: AVR241: Direct driving of LCD display using general IO
AVR241: Direct driving of LCD display using general IO Features • Software driver for displays with one common line • Suitable for parts without on-chip hardware for LCD driving • Control up to 15 segments using 16 IO lines • Fully interrupt driven operation Introduction As a low power alternative to LEDs and 7-segment LED-displays, small Liquid Crystal Displays (LCD) with only a limited number of segments are becoming more and more popular. Due to complex driving waveforms, interfacing to LCDs has traditionally been done via a hardware driver either integrated in the LCD or MCU. But as the co...
Author: Walway Shared: 8/19/19
Downloads: 1804 Views: 4855
AVR241: Direct driving of LCD display usinggeneral IO
Features• Software driver for displays with one common line • Suitable for parts without on-chip hardware for LCD driving • Control up to 15 segments using 16 IO lines • Fully interrupt driven operation
IntroductionAs a low power alternative to LEDs and 7-segment LED-displays, small Liquid Crystal Displays (LCD) with only a limited number of segments are becoming more and more popular. Due to complex driving waveforms, interfacing to LCDs has traditionally been done via a hardware driver either integrated in the LCD or MCU. But as the complexity of the waveform is dependent on the number of back planes in the LCD, these small LCDs with few common lines are less complex and software interfaces can be suitable. This application note describes software driving of LCDs with one common line, using the static driving method. Figure 1. An AVR driving a LCD display directly, using general IO.
Microcontrollers Application NoteRev. 2569A-AVR-04/04,
Theory of operationThis section provides an overview of common features and a introduction to terminology used in relation to LCD glass. Theory will focus upon driving of LCD glass with one common line.
Terminology used in This section describes the terminology used throughout this document.relation to LCD Segment One of the bars/dots in a LCD display, controlled individually. Frame A frame is equivalent to one period of the cyclic waveform that is written to a segment. Figure 2 gives a further explanation of what a frame is. Frame rate Frame rate is the number of frames per second. The frame rate should normally be kept high enough to avoid that the human eye perceives the segments as flickering and low enough to avoid ghosting. Ghosting occurs when segments are energized due to cross talk between segment lines. The frame rate should normally be kept between 30 and 100 Hz. Common line Electrical connection terminal shared by all display segments. Segment line Electrical connection terminal connected to a single segment.
LCD glass The LCD is based upon a display technology that uses rod-shaped molecules (liquidcrystals) that flow like liquid and bend light. Non-energized, the crystals direct light through two polarization filters, allowing a natural background color to show, making it invisible. When energized, they redirect the light to be absorbed in one of the polarizers, causing the dark appearance making it visible. The smallest viewing element that can be turned visible/invisible (energized/non-energized) is referred to as a display segment. Each display segment has two connection terminals. One terminal is connected to a segment driver and the other to a common terminal. One common terminal is shared by a number of segments. Applying a voltage between the common terminal and a segment terminal energizes the segment. Additionally the segment voltage has to be alternated. DC (direct current) will cause electrophoresis effects in the liquid crystal and will degrade the display. Consequently the voltages on both the common terminal and the segment terminals must alter. There are basically two driving methods for displays: Static and multiplexed. In the multiplexed driving method many displays share segment lines, and the controlling of several common lines multiplexes the displays. This method will need a variety of complex waveforms and multiple analog levels to be sent to the display. In the static driving method only one common line is used and each display segment will have their unique terminal. This method will need relatively simple waveforms applied to terminals. However, the static driving method is not suitable for LCDs with many segments since each segment will need one dedicated output-pin from the MCU. For more LCD theory please refer to application note AVR065: LCD Driver for the STK502 and AVR Butterfly. This application note will use the static driving method. Figure 2 shows energized and non-energized segments and their driving waveforms. 2 AVR241,
AVR241Figure 2. 2 segments connected to 1 common terminal. Segment line 1 Segment line 0 Common line Non- Energized energized segment segment Vlcd Vlcd Seg 0 Seg 1 Gnd Gnd Vlcd Vlcd Com Com Gnd Gnd Vlcd Vlcd Gnd Seg 0 -Com Gnd Seg 1 - Com -Vlcd -Vlcd Frame Frame Frame Frame Seg0 Seg1,
Power consumptionFigure 3 shows a simplified equivalent circuit for a LCD. For a RC network like this the main power consumption will occur in the region where the input waveforms are toggling due to increased current through C1 and C2, hence lowering the LCD frame rate will decrease the power consumption. In general the frame rate should be kept above 30Hz to avoid display flickering. Though, in low power applications (e.g. battery applications) the frame rate could be less than 30Hz as long as the display contrast/flickering is satisfying for the given application. R1: Segment- and common-plane resistance. R2: Liquid crystal resistance. C1: Barrier- and alignment-layer capacitance. C2: Liquid crystal capacitance. Figure 3. Simplified LCD equivalent circuit. C1 R1 Segment line R2 C2 Common line 4 AVR241,
AVR241 ImplementationThis section contains a description on how to connect a LCD to the AVR and how the software should be implemented. The application can be tested directly on a STK500 with a single-common LCD connected. Program code is written in C for the IAR EWAVR v. 2.28A, but other compilers can be used with only minor changes of the code. This application note is made with an ATmega16, but any AVR microcontroller with sufficient number of IO pins may be used. The software is tested with a LCD type S5080D from Clover Display.
Physical connection The application describes driving of 15 segments forming a 2x7-segment display + 1“dot” segment as shown in figure 2. Controlling of all 15 segments and the common line requires 16 I/O pins. This number can be reduced in applications where a lower number of LCD-segments are required. Software contains functions for easy writing of data to the LCD. Figure 4. Physical connection of a 2x7+1 segment LCD. “Dot”-segment on digit 1 is not connected.
VCCDIG1A: a a PD0:PD6 DIG1G DIG2A: fbfbg g PB0:PB6 DIG2G PB7 DOT2ececd d
AVR PD7 COMDIG1 DOT 2 DIG2
Firmware description The LCD driver software is interrupt driven and suitable for use in low powerapplications. The software consists of the function LCD_print() which is the driver interface and the function LCD_update() which is used by the driver to write to the LCD. Including the driver in an existing application is done as follows: 1. Add LCD_drive.c to the project and LCD_drive.h to the include files. 2. Set up a timer interrupt as described in section below. 3. Call the function LCD_update() once for each timer interrupt. 4. Print to LCD by using the function LCD_print(). LCD_main.c shows an implementation of this application on an ATmega16 running from the internal 1Mhz RC-oscillator. LCD driver interface Table 1. LCD driver C function description. Function Arguments Return LCD_print(global) Unsigned char digit, Unsigned char ASCII_data Unsigned char LCD_print() is used by the main application to prepare data for LCD_update(). The function receives ASCII values for the LCD to display, converts it to segment patterns and initiates a LCD update. Input arguments for LCD_print describe what digit to access (char digit) and what ASCII value (char ASCII_data) to output on the digit. The digit number to access should be in the range [1,2]. Figure 4 shows the digit numbering. The ASCII input needs to follow certain rules to match the LCD: 5. Bit 0:6 should contain a 7-bit ASCII code in the range given by Table 2. 6. Bit 7 turns the LCD “dot”-segment on/off. Bit 7 = 1 turns “dot”-segment ON and bit 7 = 0 turns “dot”-segment OFF. Notice that only “dot”-segment for digit 2 can be written. ASCI_data:7 should always be 0 when printing to digit 1. The functions return value is “1” for success and “0” for failure. Failure means that the input arguments are outside the range described above or that the “dot”-segment on digit 1 is signaled to be switched “ON”. 6 AVR241,
AVR241Table 2. LCD output given by input argument ASCII_data to function LCD_print(). Input character LCD output Input character LCD output(7 bit ASCII) (7 bit ASCII) '0' '9' '1' 'A' '2' 'B' '3' 'C' '4' 'D' '5' 'E' '6' 'F' '7' ' ' (Space) (Blank) '8' LCD_update Table 3. LCD driver C function description. Function Arguments Return LCD_update() Void Void LCD_update() reads the global struct variable maintained by LCD_print() and outputs them to the port pins driving the LCD. The function generates the LCD driving frames and need to be called by a Timer/Counter interrupt to ensure a stable frame rate., Setting up the timer interrupt In order to obtain a 50% duty cycle driving waveform as shown in Figure 2, some of the code should be implemented within a timer interrupt service routine. The display outputs have to be updated twice within each LCD frame. This means that the interrupt frequency has to be twice the LCD frame rate. Considerations to make when selecting frame rate is given in the theory section above. For most applications the frame rate should be approximately 30Hz giving a interrupt frequency at 60 Hz. The function LCD_update() should be called once for each timer interrupt. Example program The example program LCD_main.c, provided with this application note, shows an implementation of the driver software in an ATmega16. TCNT0 is configured to generate an interrupt every 17mS using the internal 1MHz RC-oscillator as clock source. The LCD is written to by the main application by using the function LCD_print(). 8 AVR241,
AVR241 Flowchart for function Figure 5. Flowchart for function LCD_print(). LCD_print()LCD_print() "Dig" range No OK? Return 0 Yes Dot "ON" on Yes dig 1? Return 0 No "ASCI_data" No range OK? Return 0 Yes Data_var = Pattern depended upon "ASCII_data" No dig == 1? Yes LCD.digit1 = LCD.digit2 = Data Data_var var | "Dot bit" Return 1,
Flowchart for function Figure 6. Flowchart for function LCD_update() LCD_update()LCD_update(void) Seq = 0? No Yes Set outputs given by global LCD Toggle PORTB data variables. Toggle PORTD Seq=1; Seq=0; Return
Flowchart for exampleprogram Figure 7. Flowchart for example program. Start TCNT0 IRQ Config. sleep LCD_update(); mode Set up TCNT0 Return from IRQ IRQ every 17 mS Port init: PORTB -> output PORTD -> output LCD_print(); Enable global IRQ Sleep 10 AVR241,
Atmel Corporation Atmel Operations2325 Orchard Parkway Memory RF/Automotive San Jose, CA 95131, USA 2325 Orchard Parkway Theresienstrasse 2 Tel: 1(408) 441-0311 San Jose, CA 95131, USA Postfach 3535 Fax: 1(408) 487-2600 Tel: 1(408) 441-0311 74025 Heilbronn, Germany Fax: 1(408) 436-4314 Tel: (49) 71-31-67-0
Regional Headquarters Microcontrollers Fax: (49) 71-31-67-2340 Europe 2325 Orchard Parkway 1150 East Cheyenne Mtn. Blvd.Atmel Sarl San Jose, CA 95131, USA Colorado Springs, CO 80906, USA Route des Arsenaux 41 Tel: 1(408) 441-0311 Tel: 1(719) 576-3300 Case Postale 80 Fax: 1(408) 436-4314 Fax: 1(719) 540-1759 CH-1705 Fribourg Switzerland La Chantrerie Biometrics/Imaging/Hi-Rel MPU/ Tel: (41) 26-426-5555 BP 70602 High Speed Converters/RF Datacom Fax: (41) 26-426-5500 44306 Nantes Cedex 3, France Avenue de Rochepleine Tel: (33) 2-40-18-18-18 BP 123
Asia Fax: (33) 2-40-18-19-60 38521 Saint-Egreve Cedex, FranceRoom 1219 Chinachem Golden Plaza ASIC/ASSP/Smart Cards Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80 77 Mody Road Tsimshatsui Zone Industrielle East Kowloon 13106 Rousset Cedex, France Hong Kong Tel: (33) 4-42-53-60-00 Tel: (852) 2721-9778 Fax: (33) 4-42-53-60-01 Fax: (852) 2722-1369 1150 East Cheyenne Mtn. Blvd.
Japan Colorado Springs, CO 80906, USA9F, Tonetsu Shinkawa Bldg. Tel: 1(719) 576-3300 1-24-8 Shinkawa Fax: 1(719) 540-1759 Chuo-ku, Tokyo 104-0033 Japan Scottish Enterprise Technology Park Tel: (81) 3-3523-3551 Maxwell Building Fax: (81) 3-3523-7581 East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743
Literature Requestswww.atmel.com/literature Disclaimer: Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company’s standard warranty which is detailed in Atmel’s Terms and Conditions located on the Company’s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel’s products are not authorized for use as critical components in life support devices or systems. © Atmel Corporation 2004. All rights reserved. Atmel® and combinations thereof, AVR® , and AVR Studio® are the registered trademarks of Atmel Corporation or its subsidiaries. Microsoft® , Windows® , Windows NT® , and Windows XP® are the registered trademarks of Microsoft Corporation. Other terms and product names may be the trademarks of others]
8-bit Microcontroller Application Note Rev. 0938B–AVR–01/03 AVR204: BCD Arithmetics Features • Conversion 16 Bits ↔ 5 Digits, 8 Bits ↔ 2 Digits • 2-digit Addition and Subtraction • Superb Speed and Code Density • Runable Example Program Introduction This application note lists routines for BCD arith
8-bit Microcontroller Application Note Rev. 2530B–AVR–01/04 AVR065: LCD Driver for the STK502 and AVR Butterfly Features • Software Driver for Alphanumeric Characters • Liquid Crystal Display (LCD) Contrast Control • Interrupt Controlled Updating • Conversion of ASCII to LCD Segment Control Codes (S
8-bit Instruction Set Rev. 0856D–AVR–08/02 Instruction Set Nomenclature Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two’s complement overflow indicator S: N ⊕ V, For signed tests H: Half Carry Flag T: Transfer bit used by BLD and BST instructions I: Gl
8-bit Microcontroller Application Note Rev. 0933B–AVR–05/02 AVR102: Block Copy Routines Features • Program Memory (Flash) to SRAM Copy Routine • SRAM to SRAM Copy Routine • Extremely Code Efficient Routines Flash → SRAM: 6 Words, SRAM → SRAM: 5 Words • Runable Test/Example Program Introduction This
Novice’s Guide to AVR Development intended for "Bare Bone" AVR basics.Download these files to a temporary folder on your computer. ( e.g. C:\Temp ): people with no AVR STUDIO 4 This file contains the AVR Studio 4 Program. This The AVR microcontrollers are divided into three groups:
Novice’s Guide to AVR Development Preparing your PC for AVR Development Basic AVR Knowledge An Introduction Let's make an easy start, and download the files that we will need later on. The AVR Microcontroller family is a modern architecture, with all the bells andFirst you should download the files
AVR079: STK600 Communication Protocol Features 8-bit • Supported Commands and Command options • Command and Answer package formats Microcontrollers 1 Introduction Application Note This document describes the STK®600 protocol. The firmware is distributed with AVR Studio® 4.14 or later. The definition
8-bit Instruction Set Rev. 0856G–AVR–07/08 Instruction Set Nomenclature Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two’s complement overflow indicator S: N ⊕ V, For signed tests H: Half Carry Flag T: Transfer bit used by BLD and BST instructions I: Gl
Designer’s Designing for Efficient Production Corner with In-System Re-programmable Flash µCs By: OJ Svendlsi always the component where the majority of the engi- neering hours are spent. Thus, making sure the micro- For products where time-to-market and efficient pro- controller has what it takes t
AVR069: AVRISP mkII Communication Protocol Features • General commands • ISP commands • Return values • Parameters 1 Introduction This document describes the AVRISP mkII protocol. The firmware is distributed with AVR Studio 4.12 or later. Download the latest AVR Studio from the Atmel web site, http:
Studio® Integrated Development A COMPLETE SOFTWARE ENVIRONMENT TO Environment DEVELOP AVR® APPLICATIONS. IT’S FREE!
MICROCONTROLLERSStudio® Integrated Development A COMPLETE SOFTWARE ENVIRONMENT TO Environment DEVELOP AVR® APPLICATIONS. IT’S FREE! AVR Studio® is an Integrated Development Environment for writing and debugging AVR applications in Windows® 98/XP/ME/2000 and Windows NT® environments. AVR Studio provi
Hexadecimal Object File Format Specification Revision A January 6, 1988 This specification is provided "as is" with no warranties whatsoever, including any warranty of merchantability, noninfringement, fitness for any particular purpose, or any warranty otherwise arising out of any proposal, specifi
AVR914: CAN & UART based Bootloader for AT90CAN32, AT90CAN64, & AT90CAN128 1. Features • UART Protocol 8-bit – UART used as Physical Layer – Based on the Intel Hex-type records Microcontrollers – Auto-baud • CAN Protocol – CAN used as Physical Layer Application Note – 7 re-programmable ISP CAN ident
AVR Microcontrollers Application Note AVR495: AC Induction Motor Control Using the Constant V/f Principle and a Space-vector PWM Algorithm 1. Features • Cost-effective and energy efficient 3-phase induction motor drive • Interrupt driven • Low memory and computing requirements 2. Introduction In a p
AVR Microcontrollers Application Note AVR494: AC Induction Motor Control Using the constant V/f Principle and a Natural PWM Algorithm
AVR Microcontrollers Application Note AVR494: AC Induction Motor Control Using the constant V/f Principle and a Natural PWM Algorithm 1. Features • Cost-effective and flexible 3-phase induction motor drive • Interrupt driven • Low memory and computing requirements 2. Introduction Electrical power ha
AVR465: Single-Phase Power/Energy Meter with Tamper Detection Features • Cost-Effective and Flexible Single-Phase Energy Meter • Fulfills IEC 61036 Accuracy Requirements for Class 1 Meters • Detects, Signals and Continues to Measure Accurately Under At Least 20 Different Tamper Conditions • Design E
AVR453: Smart Battery Reference Design Features • Support for up to 4 Li-Ion series-connected battery cells • Battery protection by dedicated Hardware - Deep under voltage protection - Over-current protection during charging - Over-current protection during discharging - Short circuit protection • C
8-bit Microcontroller Application Note AVR450: Battery Charger for SLA, NiCd, NiMH and Li-Ion Batteries Features
8-bit Microcontroller Application Note Rev. 1659B–AVR–11/02 AVR450: Battery Charger for SLA, NiCd, NiMH and Li-Ion Batteries Features • Complete Battery Charger Design • Modular “C” Source Code and Extremely Compact Assembly Code • Low Cost • Supports Most Common Battery Types • Fast Charging Algori
Getting started with the AVR battery charger reference design. The AVR battery charger reference design is designed for use with several types of batteries and various number of battery cells. The AVR battery charger reference design is supplied with resistor values for scaling down the charge volta
8-bit Microcontroller Application Note Rev. 2534A–AVR–05/03 AVR415: RC5 IR Remote Control Transmitter Features • Utilizes ATtiny28 Special HW Modulator and High Current Drive Pin • Size Efficient Code, Leaves Room for Large User Code • Low Power Consumption through Intensive Use of Sleep Modes • Cos
AVR336: ADPCM Decoder Features • AVR Application Decodes ADPCM Signal in Real-Time • Supports Bit Rates of 16, 24, 32 and 40 kbit/s • More Than One Minute Playback Time on ATmega128 (at 16 kbit/s) • Decoded Signal Played Using Timer/Counter in PWM Mode 1 Introduction Adaptive Differential Pulse Code
8-bit Microcontroller Application Note Rev. 1181B–AVR–04/03 AVR360: Step Motor Controller Features • High-speed Step Motor Controller • Interrupt Driven • Compact Code (Only 10 Bytes Interrupt Routine) • Very High Speed • Low Computing Requirement • Supports all AVR Devices Introduction This applica
8-bit RISC Microcontroller Application Note AVR335: Digital Sound Recorder with AVR and Serial DataFlash Features
8-bit RISC Microcontroller Application Note Rev. 1456B–01/04 AVR335: Digital Sound Recorder with AVR and Serial DataFlash Features • Digital Voice Recorder • 8-bit Sound Recording • 8 KHz Sampling Rate • Sound Frequency up to 4000 Hz • Maximum Recording Time 2 1/4 Minutes • Very Small Board Size • O
USB in a Nutshell. Making Sense of the USB Standard. Starting out new with USB can be quite daunting. With the USB 2.0 specification at 650 pages one could easily be put off just by the sheer size of the standard. This is only the beginning of a long list of associated standards for USB. There are U
What is USB Enumeration? Enumeration is the process by which a USB device is attached to a system and is assigned a specific numerical address that will be used to access that particular device. It is also the time at which the USB host controller queries the device in order to decide what type of d
CYCLIC REDUNDANCY CHECKS IN USB Introduction The USB specification calls for the use of Cyclic Redundancy Checksums (CRC) to protect all non-PID fields in token and data packets from errors during transmission. This paper describes the mathematical basis behind CRC in an intuitive fashion and then e
File: X:\USERS\IGOR\DOC\WORD\Atmel\USB to RS232 Application Note\Firmware\USBtoRS232_ATmega8\AVR Studio 4 project\USBtoRS232.asm 1.2.2004
1 ;*************************************************************************** 2 ;* USBSTACKFORTHEAVRFAMILY3;* 4 ;* File Name :"USBtoRS232.asm" 5 ;* Title :AVR309:USB to UART protocol converter 6 ;* Date :01.02.2004 7 ;* Version :2.8 8 ;* Target MCU :ATmega8 9 ;* AUTHOR :Ing. Igor Cesko 10 ;* Slovak
File: X:\USERS\IGOR\DOC\WORD\Atmel\USB to RS232 Application Note\Firmware\USBtoRS232_AT90S2313\AVR Studio 4 project\USB90S2313.asm 26.1.2004
1 ;*************************************************************************** 2 ;* USBSTACKFORTHEAVRFAMILY3;* 4 ;* File Name :"USB90S2313.asm" 5 ;* Title :AVR309:USB to UART protocol converter (simple - small FIFO) 6 ;* Date :26.01.2004 7 ;* Version :2.2 8 ;* Target MCU :AT90S2313-10 9 ;* AUTHOR :I
AVR309: Software Universal Serial Bus (USB) Features • USB (Universal Serial Bus) protocol implemented in firmware • Supports Low Speed USB (1.5Mbit/s) in accordance with USB2.0 • Implementation runs on very small AVR devices, from 2kBytes and up • Few external components required - One resistor for
8-bit Microcontrollers Application Note AVR270: USB Mouse Demonstration Features • Runs with AT90USB Microcontrollers at 8MHz • USB Low Power Bus Powered Device (less then 100mA) • Supported by any PC running Windows® (98SE or later), Linux® or Mac OS®. • 3Kbytes of Code Required • X, Y Movement, Le
8-bit Microcontroller Application Note Rev. 2547A–AVR–11/03 AVR244: AVR UART as ANSI Terminal Interface Features • Make use of standard terminal software as user interface to your application. • Enables use of a PC keyboard as input and ascii graphic to display status and control information. • Driv