Datasheet

EXAMPLE 2: FADE-IN/FADEOUT EFFECTS AND CHANGING MAPPING OF LEDS
In this example ramp instruction is used to produce fade-in/fade-out effects. Note: The use of a logarithmic PWM profile with ramp
instruction ensures the light and color changes appear smooth to the human eye. The same effect is repeated for all the LEDs by
changing the engine1-to-LED mapping. After that, the intensity of the LEDs is increased gradually and finally all the LEDs are set
OFF.
row1: dw 0000000000000001b ;Map green LED = D1 on the eval. board.
dw 0000000000000010b ;Map blue LED = D2 on the eval. board.
dw 0000000001000000b ;Map red LED = D7 on the eval. board.
dw 0000000000000100b ;Map green LED = D3 on the eval. board.
dw 0000000000001000b ;Map blue LED = D4 on the eval. board.
dw 0000000010000000b ;Map red LED = D8 on the eval. board.
dw 0000000000010000b ;Map green LED = D5 on the eval. board.
dw 0000000000100000b ;Map blue LED = D6 on the eval. board.
row9: dw 0000000100000000b ;Map red LED = D9 on the eval. board.
row10: dw 0000000111111111b ;Map all LEDs on the eval. board.
.segment program1 ;Program for engine 1.
mux_map_start row1 ;Map the first LED.
mux_ld_end row9 ;End address of the mapping data table.
loop1: ramp 1.0, 255 ;Increase PWM 0->100% in 1 second.
ramp 1.5, -255 ;Decrease PWM 100->0% in 1.5 seconds.
wait 0.4; ;Wait for 0.4 seconds.
mux_map_next ;Set the next row active in the mapping table.
branch 8,loop1 ;Loop 8 times
loop2: ramp 0.5, 128 ;Increase PWM by 128 steps in 0.5 second.
mux_map_next ;Set the next row active in the mapping table.
;Note roll over of the mapping.
branch 17, loop2 ;Loop 17 times.
mux_map_addr row10 ;Set row10 active (all LEDs mapped).
set_pwm 0; ;Set all the LEDs OFF.
rst ;Reset program counter and start the program again.
.segment program2
;Program for engine 2 (empty).
rst
.segment program3
;Program for engine 3(empty).
rst
AN-2227 - LP5523 Evaluation Kit
Copyright © 1999-2012, Texas Instruments Incorporated 19