Atmel AVR1618: ATxmegaB ASCII Character Mapping. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction



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

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

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

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

USER GUIDE EDBG. Description

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

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

Introducing a platform to facilitate reliable and highly productive embedded developments

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

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

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

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

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

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

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

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

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

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

AT91SAM ARM-based Flash MCU. Application Note

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

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

USER GUIDE. ZigBit USB Stick User Guide. Introduction

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

AT88CK490 Evaluation Kit

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

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

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

General Porting Considerations. Memory EEPROM XRAM

Atmel AVR4950: ASF - USB Host Stack. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

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

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

Atmel AVR ATxmega384C3 microcontroller OLED display with pixels resolution Analog sensors. Ambient light sensor Temperature sensor

APPLICATION NOTE. Atmel AT01180: Barcode and QR code scanner User Guide. Atmel 32-bit Microcontroller. Features. Introduction

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

8-bit Atmel Microcontrollers. Application Note. Atmel AVR211: Wafer Level Chip Scale Packages

CryptoAuth Xplained Pro

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

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

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

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

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

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

QT1 Xplained Pro. Preface. Atmel QTouch USER GUIDE

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

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

Two mechanical buttons Two user LEDs Four expansion headers. Board controller with USB interface. One power LED and one status LED

AN3998 Application note

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

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

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

APPLICATION NOTE. Atmel AVR911: AVR Open Source Programmer. 8-bit Atmel Microcontrollers. Features. Introduction

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

AVR241: Direct driving of LCD display using general IO. 8-bit Microcontrollers. Application Note. Features. Introduction AVR

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

AVR127: Understanding ADC Parameters. Introduction. Features. Atmel 8-bit and 32-bit Microcontrollers APPLICATION NOTE

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

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

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

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

8-bit Microcontroller. Application Note. AVR222: 8-point Moving Average Filter

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

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

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

MODFLEX MINI GATEWAY ETHERNET USER S GUIDE

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

Atmel AVR4904: ASF - USB Device HID Keyboard Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

AVR311: Using the TWI Module as I2C Slave. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AVR315: Using the TWI Module as I2C Master. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

DACC (Digital-to-Analog Converter Controller) The outline of this documentation is as follows: Module Overview. Special Considerations

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

AT11805: Capacitive Touch Long Slider Design with PTC. Introduction. Features. Touch Solutions APPLICATION NOTE

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

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

Atmel AVR4905: ASF - USB Device HID Generic. 8-/32-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

AN AES encryption and decryption software on LPC microcontrollers. Document information

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

Transcription:

Atmel AVR1618: ATxmegaB ASCII Character Mapping Features ASCII character mapping available on Atmel AVR XMEGA B microcontrollers Atmel XMEGA-B1 Xplained evaluation kit compatible On-board LCD display glass Structures within glass - 7-segment numeric - 14-segment alphanumeric 8-bit Atmel Microcontrollers Application Note 1 Introduction The ASCII character mapping built-in the LCD controller of Atmel AVR XMEGA B devices allows setting and clearing pixels of a 7-, 14-, or 16-segment character simply by writing the corresponding ASCII code. This application note presents an example that demonstrates 7- and 14-segment character handling using the XMEGA-B1 Xplained kit. Figure 1-1. XMEGA-B1 Xplained kit. Rev.

2 Environment The demonstration is based on the HAtmel XMEGA-B1 Xplained kith with Atmel ATxmega128B1 (1Uwww.atmel.com/xplainedH) and its dedicated LCD glass C42048A. Firmware is available on HAtmel AVR Software FrameworkH and HAtmel AVR Studio 5H as the following examples: LCD C42048A glass example XMEGA-B1 Xplained Atxmega128B1 LCD controller example XMEGA-B1 Xplained Atxmega128B1 Table 2-1. LCD definitions and acronyms. Liquid crystal display. LCD A passive display panel with terminal lines leading directly to a segment. Segment or pixel LCD panel active area which can be turned ON or OFF. Each segment has two lines. One is connected to a SEG line the other is connected to a COM line. All segments are connected in a matrix (see Figure 2-1). Common line or backplane line Segment line 1/(number of COM lines on a LCD display) COM SEG Duty Bias 1/(number of voltage levels used driving a LCD display -1) DP Decimal point Figure 2-1. LCD matrix. SEG0 SEG1 SEG2 SEG3 Segment Line 0 Segment Line 1 Segment Line 2 Segment Line 3 COM0 Common Line 0 Segment 0 Segment 1 Segment 2 Segment 3 COM1 Common Line 1 Segment 4 Segment 5 Segment 6 Segment 7 2 Atmel AVR1618

Atmel AVR1618 3 ASCII character mapping 3.1 Ease of use The Atmel ATxmega128B1 LCD controller can automatically handle ASCII characters. Instead of setting and clearing segments of a digit, the user enters the ASCII code and the digit decoder updates the segment values in the display memory. Figure 3-1. ASCII mapping. CTRLG Address START_SEG ldi sts n tio a z iali Init Data Assembly Code temp, DIGIT_TYPE START_SEG LCD_base + LCD_CTRLG_offset, temp CTRLH Automatic Increment CTRLG Address START_SEG + 2 r cte a r a Ch 1st Data Assembly Code ldi sts temp, DIGIT_TYPE START_SEG LCD_base + LCD_CTRLG_offset, temp ldi sts temp, ASCII_CODE_4 LCD_base + LCD_CTRLH_offset, temp ASCII_CODE_4 CTRLH Automatic Increment CTRLG Address START_SEG + 4 er act r a Ch 2nd Data ASCII_CODE_7 Assembly Code ldi sts temp, DIGIT_TYPE START_SEG LCD_base + LCD_CTRLG_offset, temp ldi sts temp, ASCII_CODE_4 LCD_base + LCD_CTRLH_offset, temp ldi sts temp, ASCII_CODE_7 LCD_base + LCD_CTRLH_offset, temp... CTRLH To initiate ASCII character mapping the user has to set-up the segment type and a pointer on the SEG line number where the group of digits begins (LCD_CTRLG). Then, this works as a FIFO. The user writes the ASCII value of the first digit into the control register (LCD_CTRLH). When the segments are updated, the pointer is automatically incremented (or decremented) with the number of SEG lines used for the digit. The pointer is now ready for a new ASCII writing. 3

Figure 3-2. Supported digit types. 7-Segment - 3 COM term. - 3 SEG term. 7-Segment - 4 COM term. - 2 SEG term. 14-Segment - 4 COM term. - 4 SEG term. 16-Segment - 3 COM term. - 6 SEG term. 3.2 LCD control register G 7 6 5 4 3 2 1 0 TDG[1:0] STSEG[5:0] LCD_CTRLG TDG[1:0]: Type of Digit This bit-field specifies the number of segments and COM/SEG lines of the digit. TDG[1:0] Type of digit 00 7-segment with COM[2:0] / 3 SEG 01 7-segment with COM[3:0] / 2 SEG 10 14-segment with COM[3:0] / 4 SEG 11 16-segment with COM[2:0] / 6 SEG STSEG[5:0]: Start Segment STSEG bit-field defines the first segment line used to write the digit. This bit-field is automatically incremented or decremented (according to the DEC value of LCD.CTRLH register) by the number of SEG lines used in the digit. TDG[1:0] Type of digit Increment/decrement number 00 7-segment - 3 COM / 3 SEG 3 01 7-segment - 4 COM/ 2 SEG 2 10 14-segment - 4 COM / 4 SEG 4 11 16-segment - 3 COM / 6 SEG 6 3.3 LCD control register H 7 6 5 4 3 2 1 0 DEC DCODE[6:0] LCD_CTRLH DEC: Decrement Writing this bit to one automatically decrements the STSEG bit-field of LCD_CTRLG register by the number of SEG lines used by the digit. If this bit is written to zero, the STSEG bit-field is incremented by the number of segment lines used by the digit. This action takes place once the digit decoding is finished and prepares the next call to the Digit Decoder. 4 Atmel AVR1618

DCODE[6:0]: Display Code Atmel AVR1618 DCODE bit-field will be computed by the digit decoder, and converted to display codes, and then automatically written into the display memory according to the STSEG value. The table entry code, DCODE [6:0], is the 7-bit ASCII code of the digit. 5

4 LCD C42048A glass The LCD C42048A has been especially designed for the Atmel XMEGA-B1 Xplained kit. It comes with four COM by 40 SEG lines LCD glass running at 3.0V and it includes 4 groups of segments (pixels): Seven 14-segment alphanumeric digits Five 7-segment numeric digits with negative sign and DPs (decimal points) One bar graph of nine segments (pixels) 13 icons of one segment (pixel) Total: 155 segments (pixels). Figure 4-1. Segment groups of LCD C42048A. C42048A 4.1 14-segment alphanumeric digits The alphanumeric digits have been routed to match with the third digit type (TDG[1:0]=2) supported by the Digit Decoder of the Atmel ATxmega128B1 device and defined in LCD_CTRLG register (14-segment with four COM lines). This assignment leaves two pixels not used by the Digit Decoder in locations COM0/SEG(n+1) and COM3/SEG(n+2). The alphanumeric digits are named from A0 up to A6. NOTE A6 (digit on the left) is driven by SEG[12:15] A5 is driven by SEG[16:19] A0 (digit on the right) is driven by SEG[39:36] To keep the same character scan order than in a C-string (left to right), STSEG will have to be incremented (DEC=0) by 4. 6 Atmel AVR1618

Figure 4-2. Alphanumeric digit routing. Atmel AVR1618 A6 A5 A4 A3 A2 A1 A0 f g h i b j d k e ll m nc 4.2 7-segment numeric digits The numeric digits have been routed to match with the second digit type (TDG[1:0]=1) supported by the Digit Decoder of the Atmel ATxmega128B1 and defined in LCD_CTRLG register (7-segment with four COM lines). This assignment leaves one pixel not used by the Digit Decoder in location COM3/SEG(n+1). This place has been used for DP and must be manually set/cleared. The numeric digits are named from D0 up to D3. NOTE D3 is driven by SEG[8:9] D2 is driven by SEG[6:7] D0 (digit on the right) is driven by SEG[2:3]. D0 has no DP To keep the same character scan order than in a C-string (left to right), STSEG will have to be decremented (DEC=1) by 2. D4 digit is specific and will only display four values: -, -1, 0 & 1. It will be manually driven. DP for D4 is located COM3/SEG10. 7

Figure 4-3. Numeric digit routing. D4 D3 a D2 D1 D0 a b f g b c p e d c p 8 Atmel AVR1618

Atmel AVR1618 5 Software implementation 5.1 Software driver 5.1.1 Code of driver /** * \brief Send a sequence of ASCII characters to LCD glass. * * This function enables LCD segments (pixels) via the Digit Decoder. * The function will write the maximum number of bytes passed as * argument, and will stop writing if a NULL character is found. * * \param lcd_tdg Type of digit to decode. * \param first_seg First SEG where the first data will be written. * \param data Data buffer. * \param width Maximum number of data. * \param dir Direction (==0: Left->Right,!=0: Left<-Right). */ void lcd_write_packet(enum LCD_TDG_enum lcd_tdg, uint8_t first_seg, const uint8_t *data, size_t width, uint8_t dir) { LCD.CTRLG = lcd_tdg ((first_seg<<lcd_stseg_gp) & LCD_STSEG_gm); if (dir!= 0) { dir = LCD_DEC_bm; while (width--) { if (*data == '\0') { break; // Stop on NULL char LCD.CTRLH = dir (*data++); 5.1.2 Driver arguments lcd_tdg This argument is used to choose one element of LCD_TDG_enu included in the device header ( iox128b1.h if GCC, ATxmega128B1.h if IAR ): typedef enum LCD_TDG_enum { LCD_TDG_7S_3C_gc = (0x00 << 6), /* 7-segment with 3 COMs */ LCD_TDG_7S_4C_gc = (0x01 << 6), /* 7-segment with 4 COMs */ LCD_TDG_14S_4C_gc = (0x02 << 6), /* 14-segment with 4 COMs */ LCD_TDG_16S_3C_gc = (0x03 << 6), /* 16-segment with 3 COMs */ LCD_TDG_t first_seg Define the first SEG line of the first digit to write. Note that inside the digit, the scanning of the SEG lines is incremental but outside the digit, this means considering the set of digits, the scanning order is defined by the dir argument *data Pointer on the ASCII string to display width Number of digits of the line or maximum of digits to drive. Note that size_t is an ANSI type equal to an unsigned char In the driver, this value can be cut off if a null character is found (end of ASCII string marker) 9

5.1.3 Arguments for the 14-segment digits of C42048A 5.1.4 Arguments for the 7-segment digits of C42048A dir Define the direction of the digit scanning If this scanning is the same as in *data++, this argument must be equal to zero. If not this argument must be different of zero lcd_tdg LCD_TDG_14S_4C_gc (14-segment with 4 COM lines) first_seg 12 (refer to Figure 4-2. Alphanumeric digit routing.) It corresponds to the first SEG line of the left digit A6 *data lcd_text (name defined and used in the example) width 7 (refer to Figure 4-2. Alphanumeric digit routing.) dir 0 (refer to Figure 4-2. Alphanumeric digit routing.) A6 is the left digit, it will receive the character lcd_text[0], first character pointed by *data++ Because D4 is manually managed, D3 becomes the left digit for the driver. lcd_tdg LCD_TDG_7S_4C_gc (7-segment with 4 COM lines) first_seg 8 (refer to Figure 4-3. Numeric digit routing.) It corresponds to the first SEG line of the left digit D3 *data lcd_num (name defined and used in the example) width 4 (refer to Figure 4-2. Alphanumeric digit routing.) dir 1 (refer to Figure 4-3. Numeric digit routing.) D3 is the left digit, it will receive the character lcd_numdata[0], first character pointed by *data++ 5.1.5 Control of limits The Digit Decoder itself surveys the address limit. The automatic increment/decrement doesn t overwrite the last addressed LCD data registers (LCD_DATAn) or adjacent registers. 5.2 Specialized macro functions for C42048A 5.2.1 Macro for the 14-segment digits 10 Atmel AVR1618 /** * \brief Write string to c42048a LCD glass alphanumeric field. * * This function will write the input string to the alphanumeric * field of the LCD glass. *

Atmel AVR1618 * \param data Pointer to the data input string */ static inline void c42048a_write_alpha_packet(const uint8_t *data) { lcd_write_packet(lcd_tdg_14s_4c_gc, FIRST_14SEG_4C, data, \ WIDTH_14SEG_4C, DIR_14SEG_4C); Where: Defined in device header: LCD_TDG_14S_4C_gc (see Section 5.1.2 Driver arguments) Defined in glass component header: #define FIRST_14SEG_4C 12 #define WIDTH_14SEG_4C 7 #define DIR_14SEG_4C 0 5.2.2 Macro for the 7-segment digits /** * \brief Write string to c42048a LCD glass numeric field. * * This function will write the input string to the numeric * field of the LCD glass. * * \param data Pointer to the data input string */ static inline void c42048a_write_num_packet(const uint8_t *data) { lcd_write_packet(lcd_tdg_7s_4c_gc, FIRST_7SEG_4C, data, \ WIDTH_7SEG_4C, DIR_7SEG_4C); Where: Defined in device header: LCD_TDG_7S_4C_gc (see Section 5.1.2 Driver arguments) Defined in glass component header: #define FIRST_7SEG_4C 8 #define WIDTH_7SEG_4C 4 #define DIR_7SEG_4C 1 11

6 Measurements To measure the efficiency of the Digit Decoder built-in the Atmel ATxmega128B1 device, we will create a specific software driver to manually handle (setting or clearing) digit segments (pixels), directly writing to the LCD.DATAn registers. This exercise is only done for 14-segment digit routed as defined for a digit type number 2 in the LCD.CTRLG register (TDG[1:0] = 2, LCD_TDG_14S_4C_gc) and for a direction left to right only. Since the built-in Digit Decoder is not used, we will define our own ASCII table with 16-bit elements. The LSB nibble will be the set of ordered bits for COM0, and so, the MSB nibble will be the set of ordered bits for COM3. The index used to get digit segments (pixels) in this table will be the ASCII character code. 6.1 Code of manual driver // 40 SEG lines in ATxmega128B1 #define LCD_MAX_NBR_OF_SEG 40 // ASCII 14-segment table const uint16_t ascii_table[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2E74, 0x0440, 0x23C4, 0x2544, 0x05E0, 0x25A4, 0x27A4, 0x0444, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2365, 0x07E4, 0xA545, 0x2224, 0xA445, 0x22A4, 0x02A4, 0x2724, 0x0000, 0x0000, 0x0000, 0x0000, 0x2220, 0x0678, 0x1668, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2660, 0x0000, 0x0000, 0x1818, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0004, 0x07E4, 0xA545, 0x2224, 0xA445, 0x22A4, 0x02A4, 0x2724, 0x0000, 0x0000, 0x0000, 0x0000, 0x2220, 0x0678, 0x1668, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2660, 0x0000, 0x0000, 0x1818, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 ; /** * \brief Send a sequence of ASCII characters to LCD glass. * * This function enables and disables LCD segments (pixels) * to display ASCII 14-segment character. * The function will write the maximum number of byte passed as * argument, and will stop writing if a NULL character is found. * * \param lcd_tdg Type of digit to decode. * \param data Data buffer. * \param width Maximum number of data. */ void lcd_pix_write_packet(uint8_t first_seg, const uint8_t *data, uint8_t width) { register8_t *pix_reg; uint8_t txt_i, com_i; uint8_t shift_todo, temp_data; 12 Atmel AVR1618 // Loop on the Array of ASCII characters for (txt_i = 0; txt_i < width; txt_i++) { if (*data == '\0') { break; // Stop on NULL char

Atmel AVR1618 temp_data; // Determine how many shift to do (0 or 4) shift_todo = ((first_seg + (4 * txt_i)) % 8); // Scanning all COM lines for (com_i = 0; com_i < 4; com_i++) { // Address of the corresponding data register pix_reg = (register8_t*) ((uint16_t) &LCD.DATA0) + (com_i * ((LCD_MAX_NBR_OF_SEG + 7) / 8)) + ((first_seg + (4 * txt_i))/ 8); // Get data temp_data = (uint8_t) ((ascii_table[data[txt_i]] & (0x000F << (4 * com_i))) >> (4 * com_i)); temp_data <<= shift_todo; // Writing in data register *pix_reg = (*pix_reg & ~(0x0F << shift_todo)) 6.2 Automatic versus manual handling 6.2.1 Code size 6.2.2 Execution time 6.2.3 Execution time formulas Compiler: GCC Compiler option: -Os Automatic handling = 23% of manual handling Automatic handling: 42 bytes Manual handling: 180 bytes + 256 bytes per ASCII table Compiler: GCC Compiler option: -Os System frequency: 2 MHz Number of digits ( width ): 7 Automatic handling = 30 times faster than manual handling Automatic handling: 59.705µs Manual handling: 1817.315μs Unit: μc cycle Function set-up: ST Execution or set-up per digit: DG Number of digits: n Execution per COM: COM Number of COM: y Automatic handling: ST = 23, DG = 14, COM = 0 ST + n DG Manual handling: ST = 89, DG = 139, COM = 92 ST + n*dg + n*y*com 13

6.2.4 Benefits of automatic handling If there is no display update to do, the microcontroller can enter power-save mode. In active mode, the consumption typically is 1.1mA. In power-save mode, while LCD is running, the consumption typically is 5.1μA with the C42048A LCD glass connected. Less execution time Less time in active mode Less power consumption Figure 6-1. Benefits of ASCII character mapping. i(μa) 1100 1000 With ASCII character mapping Without ASCII character mapping Active mode 1100 μa 500 250 100 Less execution time Less time in Active mode 30xLess power consumption 7 ASCII Characters Power-save mode 5.1 μa 60 200 400 1000 1800 100 t(μs) 14 Atmel AVR1618

Atmel AVR1618 7 Recommended reading It is recommended to read the following documents to get an overall idea about Atmel AVR XMEGA and especially about XMEGA B devices: XMEGA Manual and Datasheets AVR1000: Getting Started Writing C-code for XMEGA AVR1005: Getting started with XMEGA AVR1010: Minimizing the power consumption of XMEGA devices AVR1500: Xplain training - XMEGA Basics AVR1912: XMEGA-B1 Xplained Hardware User Guide AVR 1926: XMEGA-B1 Xplained Getting Started 15

8 Table of contents Features... 1 1 Introduction... 1 2 Environment... 2 3 ASCII character mapping... 3 3.1 Ease of use... 3 3.2 LCD control register G... 4 3.3 LCD control register H... 4 4 LCD C42048A glass... 6 4.1 14-segment alphanumeric digits... 6 4.2 7-segment numeric digits... 7 5 Software implementation... 9 5.1 Software driver... 9 5.1.1 Code of driver... 9 5.1.2 Driver arguments... 9 5.1.3 Arguments for the 14-segment digits of C42048A... 10 5.1.4 Arguments for the 7-segment digits of C42048A... 10 5.1.5 Control of limits... 10 5.2 Specialized macro functions for C42048A... 10 5.2.1 Macro for the 14-segment digits... 10 5.2.2 Macro for the 7-segment digits... 11 6 Measurements... 12 6.1 Code of manual driver... 12 6.2 Automatic versus manual handling... 13 6.2.1 Code size... 13 6.2.2 Execution time... 13 6.2.3 Execution time formulas... 13 6.2.4 Benefits of automatic handling... 14 7 Recommended reading... 15 8 Table of contents... 16 16 Atmel AVR1618

Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: (+1)(408) 441-0311 Fax: (+1)(408) 487-2600 www.atmel.com Atmel Asia Limited Unit 01-5 & 16, 19F BEA Tower, Milennium City 5 418 Kwun Tong Road Kwun Tong, Kowloon HONG KONG Tel: (+852) 2245-6100 Fax: (+852) 2722-1369 Atmel Munich GmbH Business Campus Parkring 4 D-85748 Garching b. Munich GERMANY Tel: (+49) 89-31970-0 Fax: (+49) 89-3194621 Atmel Japan 16F, Shin Osaki Kangyo Bldg. 1-6-4 Osaki Shinagawa-ku Tokyo 104-0032 JAPAN Tel: (+81) 3-6417-0300 Fax: (+81) 3-6417-0370 2011 Atmel Corporation. All rights reserved. Atmel, Atmel logo and combinations thereof, AVR, AVR Studio, XMEGA, 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 THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY 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 AND 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 products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.