DESCRIPTION:
DALICG02_Example2_XMC12: This example demonstrates very basic DALI control gear (IEC 62386-102) functionality using DALICG02.
The XMC1200 Boot Kit, combined with the Colour LED card, acts as the DALI control gear. This example is created for demonstration 
with the OSRAM DALI MCU as the DALI control device. However, any other DALI master can be used too. DALI commands supported in 
this example are Direct Arc Power Commands and Reset.
COLORLAMP01 app is also used in this example for driving the LED1 on the Color LED card.
IO003 app is used in this example to turn LED2 and LED3 off, as they are not used. 

REQUIREMENTS:
- J-Link Drivers installed on PC
- J-Link v4.59 or above
- DALI Control Gear:
  - XMC1200 Boot Kit + Colour LED Card
- DALI Control Device:
  - OSRAM Digital potentiometer DALI MCU (http://www.osram.com/osram_com/products/electronics/light-management-systems/mcu/dali-mcu/index.jsp?productId=)
    or any other DALI control device

SETUP:
- Connect Colour LED Card to XMC1200 Boot Kit
- Wire the 2 DALI communication lines from the DALI control device to DALI port on Colour LED Card

HOW TO CREATE THE PROJECT:
1) Instantiate the COLORLAMP01, DALICG01 and IO003 Apps from App Selection View. 

2) In the COLORLAMP01 UI select 3 Channels (Red, Green and Blue) and Dimming Engine as Source of Dimming.

3) In each of the BCCUCH01 UIs, enable channel at initialization and flicker watchdog in the Channel Configuration tab.
   In the Intensity and Packer Configuration tab, set channel intensity to 1365 (33.33%).
    
4) In BCCUDIM01 UI, enable dimming engine at initialization, and disable dither function.

5) In BCCUGLOBAL UI, set the Flicker Watchdog ON-bit insertion threshold to 1000 (0.1 %).

6) In CLK002 UI, set MCLK to 32000 kHz and PCLK = 2*MCLK in the Clock Configuration tab.

7) In DALICG01 UI, select Control Gear protocol.

8) In MANC01 select Encoding technique as Using IO and system app, 
   Bit rate = 1200 Hz, Minimum valid bit rate = 600 Hz, Maximum valid bit rate = 1800 Hz,
   Encode bit = 8 bits, Decode bit = 16 bits.
   
9) In IO003 UI, select 6 port pins and enable output driver. 

10) Map Manual Pin Assignment:
   - BCCUCH0/0 to P0.4
   - BCCUCH0/1 to P0.11
   - BCCUCH0/2 to P0.1
   - MANC01/0 captureinput pin to P0.2 
   - IO004/0 pin to P0.3 (encoder pin)
   - IO003/0 pin1-pin6 to P0.5-P0.10 respectively
   
OBSERVATIONS:
If using OSRAM Digital potentiometer DALI MCU as DALI control device,
1. Turn on/off the lamp by short push onto rotary knob.

2. Adjust the brightness level by turning the rotary knob in clockwise or anti-clockwise direction.

3. To set a minimum brightness level, adjust brightness to desired level. Then, push and hold rotary knob until setting is confirmed
   by a one time blinking of the lamp.

4. To reset the minimum brightness level, turn lamp off. Then, push and hold rotary knob. Reset is confirmed by a one time blinking
   of the lamp.

5. To fix a switch on level, adjust brightness to desired level. Then, push the rotary knob briefly twice (double click). Setting is
   confirmed by two times blinking of the lamp.

6. To delete the switch on level, turn off the lamp. Then, push the rotary knob briefly twice (double click). Deletion is confirmed
   with the turning on of the lamp to MAX level.
    
If using any other DALI control devices,
1. Send DIRECT ARC POWER command: If the ARC power value is within MAX (254) and 
    MIN (1) the power level changes accordingly. If ARC power value 0 is sent, the lamp 
    turns off.

2. Send RESET command: DALI variables are reset, and lamp goes to MAX level (254).
