Datasheet

EXAMPLE 3: USING MORE THAN ONE ENGINE AND NESTED LOOPS (LOOP INSIDE A LOOP)
This program below shows how to use all the three engines simultaneously. The engines are used to create a police beacon-type
light effect. Hint: To see the effect of separate engines, start/stop engines separately using Engine 1, Engine 2 and Engine 3 controls
instead of the Master control.
blue1: dw 0000000000000010b ;Map blue LED on D2.
blue2: dw 0000000000100000b ;Map blue LED on D6.
blue3: dw 0000000000001000b ;Map blue LED on D4.
red_led: dw 0000000010000000b ;Map red LED on D8.
.segment program1 ;Program for blue LEDs on D2 and D6.
mux_map_start blue1 ;Mapping table start address.
mux_ld_end blue2 ;Mapping table end address.
loop2:
loop1: set_pwm 255
wait 0.1
set_pwm 0
wait 0.05
branch 1, loop1
wait 0.2
mux_map_next
branch 3, loop2 ;Note nested loop (loop1 is within loop2).
loop4:
loop3: set_pwm 255
wait 0.05
set_pwm 0
wait 0.05
branch 5, loop3
mux_map_next
branch 3, loop4
rst
.segment program2 ;Program for red LED on D8.
mux_map_addr red_led ;Red LED mapping.
wait 0.45
ramp 0.5, 255 ;PWM 0%->100% in 0.5 second.
ramp 1, -255 ;PWM 100%->0% in 1 second.
rst
.segment program3 ;Program for blue LED on D4.
mux_map_start blue3 ;Mapping table start address.
set_pwm 255
wait 0.05
set_pwm 0
wait 0.2
set_pwm 255
wait 0.05
set_pwm 0
wait 0.45
rst
AN-2227 - LP5523 Evaluation Kit
20 Copyright © 1999-2012, Texas Instruments Incorporated