DALI Control Gear Software Stack

Similar documents
Guide to using the DALI LightNet tool

XC83x AP Application Note. Microcontrollers. intouch Application Kit - LED Matrix Display V1.0,

Implementing SPI Master and Slave Functionality Using the Z8 Encore! F083A

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

Dolphin In-Circuit programming Updating Firmware in the field

DAP miniwiggler V3. Application Note. Microcontrollers AP56004 V

PC Base Adapter Daughter Card UART GPIO. Figure 1. ToolStick Development Platform Block Diagram

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

Serial Communications

M68EVB908QL4 Development Board for Motorola MC68HC908QL4

Block 3 Size 0 KB 0 KB 16KB 32KB. Start Address N/A N/A F4000H F0000H. Start Address FA000H F8000H F8000H F8000H. Block 2 Size 8KB 16KB 16KB 16KB

Using the HCS12 Serial Monitor on Wytec Dragon-12 boards. Using Motorola s HCS12 Serial Monitor on Wytec s Dragon-12 boards

Security & Chip Card ICs SLE 44R35S / Mifare

Application Note, V 2.2, Nov AP32091 TC1766. Design Guideline for TC1766 Microcontroller Board Layout. Microcontrollers. Never stop thinking.

Local Interconnect Network Training. Local Interconnect Network Training. Overview

Lab Experiment 1: The LPC 2148 Education Board

Freescale Semiconductor, I

SKP16C62P Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

Modbus TCP / DALI converter

8051 MICROCONTROLLER COURSE

DS1621 Digital Thermometer and Thermostat

Hardware and Software Requirements

How To Use A Watt Saver On A Microcontroller (Watt Saver) On A Cell Phone Or Mp3 Player

Freescale Variable Key Security Protocol Transmitter User s Guide by: Ioseph Martínez and Christian Michel Applications Engineering - RTAC Americas

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

SafeSPI - Serial Peripheral Interface for Automotive Safety

8-bit AP Application Note. Microcontrollers. Hardware and Software Description DriveMonitor V

Single channel data transceiver module WIZ2-434

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

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

Computer Organization and Components

Production Flash Programming Best Practices for Kinetis K- and L-series MCUs

USER GUIDE EDBG. Description

7 OUT1 8 OUT2 9 OUT3 10 OUT4 11 OUT5 12 OUT6 13 OUT7 14 OUT8 15 OUT9 16 OUT10 17 OUT11 18 OUT12 19 OUT13 20 OUT14 21 OUT15 22 OUT16 OUT17 23 OUT18

Software User Guide UG-461

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

AN3265 Application note

Embedded Component Based Programming with DAVE 3

The Programming Interface

Field Software Updates Using TPMS LF An example using the Low Frequency radio (LFR) for wireless software updating

DS1621 Digital Thermometer and Thermostat

Freescale Semiconductor, Inc. Product Brief Integrated Portable System Processor DragonBall ΤΜ

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

ES_LPC4357/53/37/33. Errata sheet LPC4357/53/37/33. Document information

RN-131-PICTAIL & RN-171-PICTAIL Evaluation Boards

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

Keep it Simple Timing

AT15007: Differences between ATmega328/P and ATmega328PB. Introduction. Features. Atmel AVR 8-bit Microcontrollers APPLICATION NOTE

Computer and Set of Robots

PCAN-MicroMod Universal I/O Module with CAN Interface. User Manual. Document version ( )

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

Definitions and Documents

Using the HT46R46 I/O Ports to Implement Half-Duplex SPI Communication

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Command Processor for MPSSE and MCU Host Bus Emulation Modes

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

Chip Card & Security ICs Mifare NRG SLE 66R35

How To Develop A Toolstick

Bluetooth HID Profile

AN141 SMBUS COMMUNICATION FOR SMALL FORM FACTOR DEVICE FAMILIES. 1. Introduction. 2. Overview of the SMBus Specification. 2.1.

Using Altera MAX Series as Microcontroller I/O Expanders

A RF18 Remote control receiver MODULE

Programming Flash Microcontrollers through the Controller Area Network (CAN) Interface

PMC-XM-DIFF & EADIN/MODBUS Virtex Design

Quick Start Guide for High Voltage Solar Inverter DC-AC Board EVM. Version 1.3

ET-BASE AVR ATmega64/128

Embedded Systems on ARM Cortex-M3 (4weeks/45hrs)

Quick Start Guide. MRB-KW01 Development Platform Radio Utility Application Demo MODULAR REFERENCE BOARD

UM0834 User manual. Developing and debugging your STM8S-DISCOVERY application code. Introduction. Reference documents

TURBO PROGRAMMER USB, MMC, SIM DEVELOPMENT KIT

AVR Butterfly Training. Atmel Norway, AVR Applications Group

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

DS Wire Digital Thermometer and Thermostat

Virtual KNX/EIB devices in IP networks

What is Easy-Radio? Devices Covered. Frequency Hopping Transceiver. Where x00 denotes frequency of operation. E.g. 400 = 433MHz

PACKAGE OUTLINE DALLAS DS2434 DS2434 GND. PR 35 PACKAGE See Mech. Drawings Section

Bluetooth Audio Data Transfer between Bluetooth chipset (PMB6752&PMB6625) and TriCore Host TC1920

GPS/GLONASS SiRFstarV Evaluation Kit EVA5100-A

USBSPYDER08 Discovery Kit for Freescale MC9RS08KA, MC9S08QD and MC9S08QG Microcontrollers User s Manual

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

Embedded Multi-Media Card Specification (e MMC 4.5)

LED light control using DMX512 control method

Secure My-d TM and Mifare TM RFID reader system by using a security access module Erich Englbrecht (info@eonline.de) V0.1draft

Part Number Description Packages available

USER GUIDE Programming Adapter Cable for Fujitsu Flash Microcontroller- F²MC-16LX/FR Family Fujitsu Microelectronics America, Inc.

Byte code Interpreter for 8051 Microcontroller

6 0 0 V h i g h c u r r e n t H i g h S p e e d 3 I G B T o p t i m i z e d f o r h i g h - s w i t c h i n g s p e e d

AT89C5131A Starter Kit... Software User Guide

User Manual. AS-Interface Programmer

Old Company Name in Catalogs and Other Documents

UNIVERSITY OF CALIFORNIA. Los Angeles. Software for A Fault Tolerant. Microcontroller Network. A thesis submitted in partial satisfaction

WIZ-Embedded WebServer User s Manual (Ver. 1.0)

BLUETOOTH SMART CABLE REPLACEMENT

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

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

AN655 R ANGE TEST APPLICATION FOR EZRADIO AND EZRADIOPRO. 1. Introduction. 2. Supported Radio Types

TERMINAL Debug Console Instrument

RPDO 1 TPDO 1 TPDO 5 TPDO 6 TPDO 7 TPDO 8

MCB3101 (Class I) WiRobot Serial Bluetooth Wireless Module User Manual

AN1754 APPLICATION NOTE

Transcription:

XC800 Family DALI Control Gear Software Stack Application Note V1.3, 2012-10 Microcontrollers

Edition 2012-10 Published by Infineon Technologies AG 81726 Munich, Germany 2012 Infineon Technologies AG All Rights Reserved. LEGAL DISCLAIMER THE INFORMATION GIVEN IN THIS APPLICATION NOTE IS GIVEN AS A HINT FOR THE IMPLEMENTATION OF THE INFINEON TECHNOLOGIES COMPONENT ONLY AND SHALL NOT BE REGARDED AS ANY DESCRIPTION OR WARRANTY OF A CERTAIN FUNCTIONALITY, CONDITION OR QUALITY OF THE INFINEON TECHNOLOGIES COMPONENT. THE RECIPIENT OF THIS APPLICATION NOTE MUST VERIFY ANY FUNCTION DESCRIBED HEREIN IN THE REAL APPLICATION. INFINEON TECHNOLOGIES HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND LIABILITIES OF ANY KIND (INCLUDING WITHOUT LIMITATION WARRANTIES OF NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OF ANY THIRD PARTY) WITH RESPECT TO ANY AND ALL INFORMATION GIVEN IN THIS APPLICATION NOTE. Information For further information on technology, delivery terms and conditions and prices, please contact the nearest Infineon Technologies Office (www.infineon.com). Warnings Due to technical requirements, components may contain dangerous substances. For information on the types in question, please contact the nearest Infineon Technologies Office. Infineon Technologies components may be used in life-support devices or systems only with the express written approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure of that life-support device or system or to affect the safety or effectiveness of that device or system. Life support devices or systems are intended to be implanted in the human body or to support and/or maintain and sustain and/or protect human life. If they fail, it is reasonable to assume that the health of the user or other persons may be endangered.

XC82x/XC83x Revision History: V1.3 2012-10 Previous Version(s): V1.2 2012-03 Page Subjects (major changes since last revision) - Updated DALI Control Gear Schematic - Part 1; Changed R5 from 1K to 560R Trademarks We Listen to Your Comments Is there any information in this document that you feel is wrong, unclear or missing? Your feedback will help us to continuously improve the quality of this document. Please send your proposal (including a reference to this document) to: mcdocu.comments@infineon.com Application Note 3 V1.3, 2012-10

Table of Contents Table of Contents 1 Overview....................................................................... 5 2 DALI Protocol................................................................... 7 2.1 Receiving DALI Forward Frame..................................................... 7 2.2 Sending Backward Frame.......................................................... 7 3 DALI Control Gear Software Stack.................................................. 8 3.1 Software Structure................................................................ 8 3.2 Hardware Abstraction Layer Configuration.............................................. 8 3.2.1 GPIO Module................................................................... 8 3.2.1.1 GPIO Initialisation............................................................. 9 3.2.2 Timer 0 and Timer 2 Modules...................................................... 9 3.2.2.1 Timer 0...................................................................... 9 3.2.2.2 Timer 2...................................................................... 9 3.3 DALI Protocol Module............................................................. 10 3.4 DALI Commands Handler Module................................................... 10 3.4.1 Process Command............................................................. 10 3.4.2 Fading Control................................................................. 11 3.4.3 DALI Variables................................................................. 11 3.4.4 Memory Banks................................................................. 12 4 API Routines................................................................... 13 4.1 Arc Power Level................................................................. 13 4.2 Program DALI Variables.......................................................... 13 4.3 Status of Lighting Device.......................................................... 13 4.4 Light On....................................................................... 13 5 Conditional Compilation Option................................................... 14 6 Preparing Software Stack for LED Application....................................... 15 6.1 Hardware Setup................................................................. 15 6.2 Downloading LED Example Code Using DAP miniwiggler................................ 16 6.3 Hardware Abstraction Layer....................................................... 17 6.4 Application Layer................................................................ 18 6.5 Compiler Options and Linker Address Allocation........................................ 18 6.6 Software Package................................................................ 19 6.7 Schematic...................................................................... 19 7 Summary...................................................................... 22 8 Acronyms, Abbreviations and Special Terms........................................ 22 9 References.................................................................... 22 10 Appendix..................................................................... 23 10.1 Flow Charts..................................................................... 23 10.2 DALI Variables.................................................................. 24 Application Note 4 V1.3, 2012-10

Overview 1 Overview Digital Addressable Lighting Interface (DALI) is a communication protocol for lighting control in buildings. The interface was first described in Annex E, IEC60929 standard for fluorescent lamp ballast. Subsequently, it was updated to the new standard IEC-62386, to include other lighting devices, such as LED and HID for example. The standard for control interface of electronic control gears was published in June 2009. The standard for lighting control devices is scheduled to be published in 2012. DALI requires only a pair of wires to form the bus for communication to all devices on a single DALI network. Each piece of operating equipment with a DALI interface can be communicated with, over DALI, individually. Using a bidirectional data exchange, a DALI controller can query and set the status of each connected lighting device. As a standalone system, DALI can be operated with a maximum of 64 devices. Alternatively, DALI can be used as a subsystem via DALI gateways for connection to building management systems. Grouped System : Brightness control within large open - plan office, lecture halls or conference rooms. DALI can provide zoned or localised control of lighting. Control could be offered through infra-red remote control or a software control with GUI support, or used together as an easy configuration tool to group loads together. Offering flexibility in customised lighting. DALI Control Device(s) (e.g. Control Panel, Remote Controller, software control with GUI support) DALI Power Supply DALI Bus DALI Control Gear (e.g. Lamp) DALI Control Gear (e.g. Lamp) Can connect up to 64 DALI Control Gear Complex System : Multiple DALI systems can be connected together utilising gateways to building management systems. Software programs offer more sophisticated programming functionality for grouped systems, such as scenesetting, timeclock, and partition control. Building Management System Gateway Gateway Gateway Gateway DALI Control Device(s) (e.g. Control Panel, Remote Controller, software control with GUI support) DALI Systems DALI Systems DALI Systems DALI Bus DALI Power Supply DALI Control Gear (e.g. Lamp) DALI Control Gear (e.g. Lamp) Can connect up to 64 DALI Control Gear Figure 1 DALI System Types Application Note 5 V1.3, 2012-10

Overview LightNET DALI configuration SW for groups and scenes XC83x DALI Slave Board XC83x DALI Slave Board Power Supply XC83x SW Stack XC83x SW Stack Easy Kit as DALI Master Board DALI PHY DALI PHY USB/UART PC Connector XC83x SW Stack DALI PHY DALI BUS Figure 2 Block Diagram for DALI Control Device and Control Gear This document describes the DALI Software Stack for Control Gear solution, created to provide an application example for LED control. This solution is based on the published IEC standard and is implemented with the Infineon XC83x microcontroller. The following items are required for use with this application note: DALI-DMX512 board order number: KIT_DALI_RGB_XC836_DKV1 Figure 3 XC836 DALI-DMX512 Board Other application notes of interest are: AP08104: Guide to using DALI LightNet tool AP08105: DALI Demo using Touch Sense Control Application Note 6 V1.3, 2012-10

DALI Protocol 2 DALI Protocol DALI uses the Manchester encoded unidirectional serial protocol with a transmission rate of 1200bps ± 10%. LOGICAL 1 LOGICAL 0 Figure 4 Bi-phase levels: Logical 1, Logical 0 2.1 Receiving DALI Forward Frame Forward frame is the command frame received from the DALI master. It consists of 19-bits. START BIT STOP BITS Y A5 A4 A3 A2 A1 A0 S D7 D6 D5 D4 D3 D2 D1 D0-1 start bit, logical 1, bi-phase code - 1 address byte, YAAA AAAS, bi-phase code Y: short address( 0 ) or group/broadcast address ( 1 ) A: address bits S: direct arc power level ( 0 ) or command ( 1 ) - 1 data byte, XXXX XXXX, bi-phase code - 2 stop bits, 1, idle line Figure 5 Forward Frame Format 2.2 Sending Backward Frame Backward frame is sent only after the reception of a query command or a write memory command. It consists of 11-bits. START BIT STOP BITS D7 D6 D5 D4 D3 D2 D1 D0-1 start bit, logical 1, bi-phase code - 1 data byte, XXXX XXXX, bi-phase code - 2 stop bits, 1, idle line Figure 6 Backward Frame Format Application Note 7 V1.3, 2012-10

DALI Control Gear Software Stack 3 DALI Control Gear Software Stack This chapter describes the DALI Software Stack implemented for XC83x devices. 3.1 Software Structure Figure 7 shows the interface of the different software modules in the XC83x lighting application software. It consists of peripheral modules, the DALI Software Stack, and an application layer. The DALI Software Stack consists of the DALI protocol and commands handler. DALI Slave Software Application Main Inits All Modules LED controls LED status LED Control DALI Software Stack Start Timer 0 1msec DALI Commands Handler DALI address, and DALI command 520usec For RX 417usec For TX DALI Protocol Edge detected DALI response RX frame TX frame Read DALI variables Program DALI variables to Flash Hardware Abstraction Layer Timer0 (16-bit) Timer 2 Reload timer Interrupt T2EX P1.0 GPIO P0.5 BootROM user routine (Programming / Erasing) Flash CCU6 / GPIO / ADC DALI RX DALI TX LED Driver Figure 7 Software Structure for the XC83x 3.2 Hardware Abstraction Layer Configuration The config.h file stores the configuration of the GPIO and timers. The file can be modified according to the application requirements. 3.2.1 GPIO Module The default GPIO settings for DALI receive and transmit are P1.0 and P0.5 respectively. For the DALI receive, T2EX (Timer 2 External pin), must be mapped to these pins. Depending on the application and package used, the GPIO for DALI interface can be re-configured to other port pins. Refer to Table 1 for the GPIO pins that have T2EX as input function and can be used for DALI receive. Application Note 8 V1.3, 2012-10

DALI Control Gear Software Stack Table 1 DALI Receive GPIO pin selection Package GPIO can be used for DALI RX TSSOP-28 P0.4, P0.6, P1.0, P2.0, P2.7, P3.2 1) DSO-24 P0.4, P0.6, P1.0, P2.0, P3.2 1) DSO-20 P0.4, P0.6, P1.0, P2.0 TSSOP-16 P0.4, P0.6, P1.0, P2.0 1) P3.2 cannot be used as DALI Receive pin if the boot mode is set to USER DIAGNOSTIC. Default settings: 1. DALI Transmit is on P0.5 #define DALI_TX_PIN P0_5 #define READ_DALI_TX_PIN P0_5 2. DALI Receive is on P1.0 #define DALI_RX_DATAIN P1_DATAIN #define READ_DALI_RX_PIN ACC_b0 #define T2EX_SEL 0x02 3.2.1.1 GPIO Initialisation GPIO settings for the DALI Transmit and Receive pains: Table 2 GPIO Settings Port Function Port Direction Mode Pull-up DALI Transmit P0.5 Out Push-pull Enabled DALI Receive P1.0 In Open Drain Disabled 3.2.2 Timer 0 and Timer 2 Modules The default settings for Timer 0 and Timer 2 are based on F PCLK = 24MHz. If a different peripheral clock frequency is selected, the settings for Timer 0 and Timer 2 have to be changed accordingly. 3.2.2.1 Timer 0 The Timer 0 serves as a 1 msec tick. The main loop is run every 1 msec (see Figure 18). The Interrupt Service Routine carries out the timing countdown required in the Software Stack. Default settings: Timer 0 = 0xD120, 1 msec tick 3.2.2.2 Timer 2 The Manchester encoding and decoding of the DALI frame is performed in the DALI Software Stack with the use of the Timer 2 module. The Timer 2 external pin, T2EX, is connected to the DALI RX to detect the falling / rising edge of the forward frame. Default settings: Timer 2 = 0xC4F0, 520 usec for DALI Reception. Timer 2 = 0xD8F0, 417 usec for DALI Transmission. Application Note 9 V1.3, 2012-10

DALI Control Gear Software Stack 3.3 DALI Protocol Module The T2_viTmr2() function handles the decoding and encoding of the DALI frames. Peripherals Modules DALI Protocol T2EX interupt Edge Detected Read DALI RX and shift the bit in the DALI command bufers All address and command bits received Set command ready flag. DALI Address DALI Command GPIO DALI RX DALI Commands Handler T2 overflow interrupt Timer overflow Read DALI RX pin and set edge trigger Figure 8 Decoding DALI Forward Frame Peripherals Modules DALI Protocol T2 overflow interrupt Timer overflow Software Manchester encoding All response bits transmitted DALI Response DALI Commands Handler GPIO DALI TX Bi-phase data Set Response transmitted flag. Figure 9 Encoding DALI Backward Frame 3.4 DALI Commands Handler Module The main purpose of this module is to process the DALI address and command data from the DALI protocol module. This module contains application interface routines and DALI functions for fade control, arc power control, and read / write memory. 3.4.1 Process Command The address byte of the DALI command is used to distinguish between a normal and a special command. This check is implemented in the DALI_vProcess_cmd() function. Figure 10 shows the flow of this function. Application Note 10 V1.3, 2012-10

DALI Control Gear Software Stack DALI Process Command Check DALI Address Address valid? No Address belong to special command Yes Address byte bit 1 = 1? No Yes Yes Standard Commands Direct arc power control Special commands No Return Figure 10 Process DALI command 3.4.2 Fading Control According to the DALI standard there are 15 different fade times and fade rates that control dimming. The fade control is executed every 1 msec during the fading process. It updates the current arc power and stops the fading process once the target arc power is reached. The fade time per step is calculated using the formula: Fade time per step = Fade Time (Target Arc Power Current Arc Power) steps To resolve the truncation error the formula is modified to: Fade time per 2 steps = Fade Time (Target Arc Power Current Arc Power) / 2 + 0.5 3.4.3 DALI Variables There are 34 DALI variables defined in the standard (see Table 12). The data from these 34 variables is returned to the DALI master, when requested through the query commands. 29 of the 34 variables can be updated by the DALI master through the configuration and special commands. Application Note 11 V1.3, 2012-10

DALI Control Gear Software Stack 3.4.4 Memory Banks The DALI standard supports up to 256 memory banks, up to 256 bytes for each memory bank. Due to limited flash size, the implementation can support only 2 memory banks; Bank 0 and Bank 1. For a device with a flash size of 4K bytes: Bank 0 is 32 bytes and with read-only access. Bank 1 is 95 bytes and with read / write access. For a device with a flash size of 8K bytes: Bank 0 is 256 bytes and with read-only access. Bank 1 is 95 bytes and with read / write access. The default data of Memory Bank 0 is defined in the file called DALI_memory_bank0.c. The default data of Memory Bank 1 is defined in the file called DALI_Flash_Sect_default.c. Table 3 Memory Bank Address Allocation Device Flash Size Memory Bank 0 Memory Bank 1 (Default) XC82x / XC83x 4K Bytes 0x0EC0 to 0x0EDF (32 bytes) 0x0F20 to 0x0F7E (95 bytes) XC83x 8K Bytes 0x1E00 to 0x1EFF (256 bytes) 0x1F20 to 0x1F7E (95 bytes) At power-up, the device will retrieve the Memory Bank 1 data from the flash and place it into XRAM. Any changes to the Memory Bank 1 data requested by the DALI Master, will be carried out in XRAM. The routine Program_DALI_Variables() is to be called to copy the Memory Bank 1 data from the XRAM into the flash. This could be done before the device goes into power down mode or in the power-loss situation. Application Note 12 V1.3, 2012-10

API Routines 4 API Routines The DALI Software Stack provides 4 API routines: DALI_arc_power() - return the required arc power level. PROGRAM_DALI_variables() - to program the DALI variables and Memory Bank 1 data to flash if they are updated by the DALI master. LIGHT_status() - to update the DALI Software Stack on the status of the lighting device. LIGHT_on() - to indicate that the lighting device is turned on. 4.1 Arc Power Level The DALI Software Stack provides a routine that the user application can call to get the requested arc power level, DALI_arc_power(). If the return value is zero, the lamp/led has to be turned off. Table 4 Update arc power level to the Application layer Routine DALI_arc_power Inputs - Return 8-bits data: 0, minimum arc power level - maximum arc power level 4.2 Program DALI Variables This routine programs the updated DALI variables and Memory Bank 1 data, to the flash. If all the variables / data remain unchanged, there will be no programming action. Table 5 Program DALI variables routine Routine PROGRAM_DALI_variables() Inputs - Return - Resources used 32 bytes of IRAM for buffering data to be programmed Execution Time 14 msec - Flash programming done. 2.4 usec - Flash programming not done. 4.3 Status of Lighting Device If the lighting device is faulty or disconnected, this routine is to be called. Table 6 Status of Lamp / LED Routine LIGHT_status() Inputs 0 - Lighting Device OK 1 - Lighting Device faulty or disconnected Return - 4.4 Light On This routine will set bit 2 of the DALI status byte, indicating that the lighting device is powered on. The user application needs to call this routine after the pre-heating and ignition process of the lighting device are complete. Application Note 13 V1.3, 2012-10

Conditional Compilation Option Table 7 Light On Routine LIGHT_on() Inputs - Return - 5 Conditional Compilation Option Four conditional compilation preprocessor functions are defined. XC83X_8K - Flash size is 8Kbytes and the Memory banks are in upper 4K. SPECIAL_MODE_EN - DALI special commands (commands 258 to 270) are supported. MEMORY_BANK_EN - Read Memory Map access commands supported (commands 197, 273, 274) WRITE_MEMORY_EN - Write to Memory Map commands supported (commands 275). This option is not supported in 4K flash device. Figure 11 Keil Preprocessor Settings Application Note 14 V1.3, 2012-10

Preparing Software Stack for LED Application 6 Preparing Software Stack for LED Application This chapter describes an LED application example that uses the DALI Software Stack with the DALI-DMX512 board from Infineon. 6.1 Hardware Setup This section describes the hardware setup for this LED example. The DALI-DMX512 board has 3 LED drivers which are used to drive the LED channels. The PWM signal is generated using the CCU6 module and output through Ports 1.1, 1.3 and 1.5 to control the brightness level of the LED. DALI-DMX512 Board DALI Control Device DALI BUS DALI PHY LED 16V Power XC836 MCU PWM BCR421 LED Driver Figure 12 Overview of hardware setup Connect to 5V supply Programming Connector VCC GND VCC GND SPD On board LED Connect to DALI BUS Figure 13 Board Connections Application Note 15 V1.3, 2012-10

Preparing Software Stack for LED Application Table 8 shows the XC836 MCU pins usage in this LED example. Table 8 XC836 MCU Pins Assignment Pin Number Port Pin Pin Functionality 1 P2.7 Reserved for DMX512 2 P2.6-3 P2.5-4 P2.4 Power loss detection 5 P2.3 Reserved for DMX512 6 P2.2 Reserved for DMX512 7 P2.1 Reserved for DMX512 8 P2.0 Reserved for DMX512 9 P0.6 Reserved for DMX512 10 P0.5 DALI Transmit 11 P0.4 DALI Receive 12 V DDP I/O Port Supply 13 P1.3 CC61 LED Driver 14 P1.2-15 P1.1 CC60 LED Driver 16 P1.0-17 V SSP / V SSC I/O Port Ground / Core Supply Ground 18 V DDC Core Supply Output 19 P1.4-20 P1.5 CC62 LED Driver 21 P0.0-22 P0.1-23 P0.2-24 P0.3-25 P3.0 XTAL 26 P3.1 XTAL 27 P3.2 SPD 18 P0.7-6.2 Downloading LED Example Code Using DAP miniwiggler With the DAP miniwiggler, user can download the example code to the board by setting up the 3 pins as shown in Figure 14, through XC800 FLOAD in DAVEBENCH TM or KEIL UVision4. Application Note 16 V1.3, 2012-10

Preparing Software Stack for LED Application Power Conn (Connector X3) 5V Supply Connections for programming the DALI Control Gear using a DAP MINIWIGGLER 1 2 X3 VCC GND Programming Pin (Connector X2) VCC GND 3 2 1 X2 SPD 3 4 2 PC (KIT_DALI_RGB_XC836_DKV1) KIT_DAP_MINIWIGGLER_USB X3 X2 KIT_DAP_MINWIGGLER_USB KIT_DALI_RGB_XC836_DKV1 Figure 14 Programming the board using DAP miniwiggler 6.3 Hardware Abstraction Layer In the configuration file CONFIG.H, there are changes to the Timer 2 configuration, as shown in Table 9. Table 9 Configuration of GPIO and Timers in CONFIG.H Module Description Changes Timer 0 Timer 0 overflow timing No change Timer 2 Timer 2 overflow timing No change Define wakeup from power #define<space>pwr_down_wakeup_time<space>0x0960 down mode timing GPIO Define DALI transmit and DALI receive pins DALI receive pin is changed from P1.0 to P0.4. #define <SPACE> DALI_RX_DATAIN <SPACE> P0_DATAIN #define <SPACE> READ_DALI_RX_PIN <SPACE> ACC_b4 //P0.4 #define <SPACE> T2EX_SEL <SPACE> 0x01 // T2EX_1 at P0.4 Application Note 17 V1.3, 2012-10

Preparing Software Stack for LED Application 6.4 Application Layer In this LED example code, the following feature is added: Programming of the DALI variables is triggered when ADC channel 4 (P2.4) goes below 2V. This act as a power loss detection. The PROGRAM_DALI_variables() routine is called to program the DALI variables into the flash. 3 2 1 VCC GND SPD X2 X2 TP4 TP4 (KIT_DALI_RGB_XC836_DKV1) DALI Parameters Programming During power up, TP4 should not be connected. To simulate a power loss event, connect TP4 to GND DALI Control Gear (KIT_DALI_RGB_XC836_DKV1) Figure 15 Simulate Power Loss Event by connecting TP4 to GND. 6.5 Compiler Options and Linker Address Allocation For this LED example code, the compiler options XC83X_8K, SPECIAL_MODE_EN, MEMORY_BANK_EN and WRITE_MEMORY_EN are enabled. The address allocation for the DALI variables are defined in the linker file as shown in Table 10. Table 10 Address Allocation in the Linker Segments Description Address DALI_PARA DALI variables reset values 0x1DE0 to 0x1DFF DALI_MEMORY_BANK0 Memory Bank 0 0x1E00 to 0x1EFF DALI_FLASH_SECT_DEFAULT Flash Emulated EEPROM 0x1F00 to 0x1FFF DALI variables default values 0x1F01 to 0x1F1C Memory Bank 1 default values 0x1F20 to 0x1F7E Application Note 18 V1.3, 2012-10

Preparing Software Stack for LED Application 6.6 Software Package Table 11 lists the source files in the software package. Table 11 List of source files Files Description Start_xc.a51 Start up code for XC82x device. This is part of the compiler package Main.c Main loop and user application code to control the LED. Refer to Figure 18. DALI_main.c DALI Software Stack main function loop, refer to Figure 19. DALI.c DALI software module initialisation and DALI command handling. DALI_API.c Contains all the API routines described in Chapter 4. T01.c Timer 0 module initialisation and 1 msec interrupt service routine T2 Timer 2 module initialisation and the interrupt service routine that decode or encode the DALI frame. IO.c GPIO module initialisation. CC6.c CCU6 module initialisation ADC.c Setup channel 4 for power loss detection. DALI_para.c Defined the DALI parameter contents. DALI_memory_bank0.c Defined the memory bank 0 contents. DALI_Flash_Sect_default.c Defined the memory bank 1 contents. config.h Configuration of GPIO and definitions of timer overflow periods used in timer0 and timer2 modules. 6.7 Schematic The schematic for the DALI-DMX512 board is shown in Figure 16 and Figure 17. Application Note 19 V1.3, 2012-10

Preparing Software Stack for LED Application Figure 16 DALI-DMX512 Board Schematic - Part 1 Application Note 20 V1.3, 2012-10

Preparing Software Stack for LED Application Figure 17 DALI-DMX512 Board Schematic - Part 2 Application Note 21 V1.3, 2012-10

Summary 7 Summary The DALI Control Gear Software Stack solution has been developed in accordance with the IEC62386 standard. The description in this application note shows how the solution can be customised for an LED control application. From the example, users will be able to customise the Software Stack to their own lighting application. 8 Acronyms, Abbreviations and Special Terms List of terms and abbreviations used throughout the document: API Application Programming Interface GPIO General Purpose Input / Output MCU Microcontroller Unit T2EX Timer 2 External Pin 9 References [1] IEC62386 Digital addressable lighting interface - Part 101: General requirements - System (Edition 1.0, 2009-06) [2] IEC62386 Digital addressable lighting interface - Part 102: General requirements - Control gear (Edition 1.0, 2009-06) [3] XC82x User s Manual version 1.1 [4] XC83x User s Manual version 1.1 Application Note 22 V1.3, 2012-10

Appendix 10 Appendix 10.1 Flow Charts Figure 18 and Figure 19 show the flow of the main loop and the DALI Software Stack. Main.c Peripherals Initialisation Enable interrupts 1 msec tick yes DALI Main no User code (Application) Figure 18 Software flow in main.c DALI Main DALI state machine Fade running no Power on condition yes yes Update light arc power according to the fade rate Set light to power on condition no Return Figure 19 Software Flow in DALI_main.c Application Note 23 V1.3, 2012-10

Appendix 10.2 DALI Variables List of variables defined in the DALI standard are shown in Table 12. Table 12 Declaration of DALI Variables Variables Default values Reset Values Range of Validity Memory Actual level Power On level 254 0, min to max 1 Byte RAM Power On Level 254 254 0 to 255 1 Byte Flash System Failure Level 254 254 0 to 255 1 Byte Flash Minimum Level Physical min Physical min Physical min to max 1 Byte Flash Maximum Level 254 254 MIN to 254 1 Byte Flash Fade Rate 7 7 1 to 15 1 Byte Flash Fade Time 0 0 0 to 15 1 Byte Flash Short Address 255 no change 0 to 63, 255 1 Byte Flash Search Address FF FF FFh FF FF FFh 00 00 00h to FF FF FFh 3 Bytes RAM Group 0-7 0000 0000b 0000 0000b 0 to 255 1 Byte Flash Group 8-15 0000 0000b 0000 0000b 0 to 255 1 Byte Flash Scene 0 255 255 0 to 255 1 Byte Flash Scene 1 255 255 0 to 255 1 Byte Flash Scene 2 255 255 0 to 255 1 Byte Flash Scene 3 255 255 0 to 255 1 Byte Flash Scene 4 255 255 0 to 255 1 Byte Flash Scene 5 255 255 0 to 255 1 Byte Flash Scene 6 255 255 0 to 255 1 Byte Flash Scene 7 255 255 0 to 255 1 Byte Flash Scene 8 255 255 0 to 255 1 Byte Flash Scene 9 255 255 0 to 255 1 Byte Flash Scene 10 255 255 0 to 255 1 Byte Flash Scene 11 255 255 0 to 255 1 Byte Flash Scene 12 255 255 0 to 255 1 Byte Flash Scene 13 255 255 0 to 255 1 Byte Flash Scene 14 255 255 0 to 255 1 Byte Flash Scene 15 255 255 0 to 255 1 Bytes Flash Status 1XX0 XXXXb 0X10 0XXXb 0 to 255 1 Byte RAM DTR undefined no change 0 to 255 1 Byte RAM DTR1 undefined no change 0 to 255 1 Byte RAM DTR2 undefined no change 0 to 255 1 Byte RAM Application Note 24 V1.3, 2012-10

www.infineon.com Published by Infineon Technologies AG