This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LP5523 Code Question

Other Parts Discussed in Thread: LP5523

Hi, 

I want to add an external trigger before the pattern. But always fail. Would you help to check it? (trigger w{e} ;)

row1: dw 0000000000000001b ;Map green LED = D1 on the eval. board.
dw 0000000000000010b ;Map blue LED = D2 on the eval. board.
dw 0000000000000100b ;Map red LED = D3 on the eval. board.
dw 0000000000001000b ;Map green LED = D4 on the eval. board.
dw 0000000000010000b ;Map blue LED = D5 on the eval. board.
dw 0000000000100000b ;Map red LED = D6 on the eval. board.
dw 0000000001000000b ;Map green LED = D7 on the eval. board.
dw 0000000010000000b ;Map blue LED = D8 on the eval. board.
row9: dw 0000000100000000b ;Map red LED = D9 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.
trigger w{e} ;
rst
.segment program2 ;Program for engine 1.
loop1: ramp 0.1, 255 ;Increase PWM 0->100% in 0.2 second.
trigger s{3} ;Send trigger to engine2
mux_map_next ;Set the next row active in the mapping table.
branch 8,loop1 ;Loop 8 times.
wait 0.2
rst ;Reset program counter and start the program again.
.segment program3 ;Program for engine 2.
mux_map_start row1 ;Map the first LED.
mux_ld_end row9 ;End address of the mapping data table.
loop2: trigger w{2} ;Wait for trigger from engine1.
ramp 0.18,-255 ;Decrease PWM 100->0% in 1 second.
mux_map_next ;Set the next row active in the mapping table.
branch 8,loop2 ;Loop 8 times.
rst

  • Hi Jerry,

    Looking at your code, I am not totally sure what you are trying to do. But if you want one engine to ramp up the LED and other engine to ramp down the LED and you want to externally trigger this sequence, I recommed few adjustments. See below:

    row1: dw 0000000000000001b ;Map green LED = D1 on the eval. board.
    dw 0000000000000010b ;Map blue LED = D2 on the eval. board.
    dw 0000000000000100b ;Map red LED = D3 on the eval. board.
    dw 0000000000001000b ;Map green LED = D4 on the eval. board.
    dw 0000000000010000b ;Map blue LED = D5 on the eval. board.
    dw 0000000000100000b ;Map red LED = D6 on the eval. board.
    dw 0000000001000000b ;Map green LED = D7 on the eval. board.
    dw 0000000010000000b ;Map blue LED = D8 on the eval. board.
    row9: dw 0000000100000000b ;Map red LED = D9 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.
    trigger w{e} ;
    rst
    .segment program2 ;Program for engine 1.  Remove these two lines as these are now creating program for engine2

    loop1: ramp 0.1, 255 ;Increase PWM 0->100% in 0.2 second.
    trigger s{3} ;Send trigger to engine2 Trigger to engine 3

    mux_map_next ;Set the next row active in the mapping table.
    branch 8,loop1 ;Loop 8 times. Note that actually this is now repeated 9 times

    wait 0.2
    rst ;Reset program counter and start the program again.


    .segment program3 ;Program for engine 2. (this is program for engine 3)

    mux_map_start row1 ;Map the first LED.
    mux_ld_end row9 ;End address of the mapping data table.
    loop2: trigger w{2} ;Wait for trigger from engine1. Now this needs to be corrected to w{1}, wait trigger from engine 1

    ramp 0.18,-255 ;Decrease PWM 100->0% in 1 second.
    mux_map_next ;Set the next row active in the mapping table.
    branch 8,loop2 ;Loop 8 times.
    rst

    Let me know how this works with these fixes.

    Thank you,

    Sami

  • Hi Sami,

    Thanks for your great suggestion. It works. But I want to the pattern is wait a trigger, after the trigger the pattern is running always. Should I use three segment to achieve it?

    row1: dw 0000000000000001b ;Map green LED = D1 on the eval. board.
    dw 0000000000000010b ;Map blue LED = D2 on the eval. board.
    dw 0000000000000100b ;Map red LED = D3 on the eval. board.
    dw 0000000000001000b ;Map green LED = D4 on the eval. board.
    dw 0000000000010000b ;Map blue LED = D5 on the eval. board.
    dw 0000000000100000b ;Map red LED = D6 on the eval. board.
    dw 0000000001000000b ;Map green LED = D7 on the eval. board.
    dw 0000000010000000b ;Map blue LED = D8 on the eval. board.
    row9: dw 0000000100000000b ;Map red LED = D9 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.
    trigger w{e} ;
    loop1: ramp 0.1, 255 ;Increase PWM 0->100% in 0.2 second.
    trigger s{2} ;Send trigger to engine2 Trigger to engine 3
    mux_map_next ;Set the next row active in the mapping table.
    branch 8,loop1 ;Loop 8 times. Note that actually this is now repeated 9 times
    wait 0.2
    rst ;Reset program counter and start the program again.

    .segment program2 ;Program for engine 2. (this is program for engine 3)
    mux_map_start row1 ;Map the first LED.
    mux_ld_end row9 ;End address of the mapping data table.
    loop2: trigger w{1} ;Wait for trigger from engine1. Now this needs to be corrected to w{1}, wait trigger from engine 1
    ramp 0.18,-255 ;Decrease PWM 100->0% in 1 second.
    mux_map_next ;Set the next row active in the mapping table.
    branch 8,loop2 ;Loop 8 times.
    rst

  • Hi Jerry,

    So you want to have only one time external triggering and the the program would run continuosly. I think you could do the following change to the looping:

    row1: dw 0000000000000001b ;Map green LED = D1 on the eval. board.
    dw 0000000000000010b ;Map blue LED = D2 on the eval. board.
    dw 0000000000000100b ;Map red LED = D3 on the eval. board.
    dw 0000000000001000b ;Map green LED = D4 on the eval. board.
    dw 0000000000010000b ;Map blue LED = D5 on the eval. board.
    dw 0000000000100000b ;Map red LED = D6 on the eval. board.
    dw 0000000001000000b ;Map green LED = D7 on the eval. board.
    dw 0000000010000000b ;Map blue LED = D8 on the eval. board.
    row9: dw 0000000100000000b ;Map red LED = D9 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.
    trigger w{e} ;
    loop1: ramp 0.1, 255 ;Increase PWM 0->100% in 0.2 second.
    trigger s{2} ;Send trigger to engine2 Trigger to engine 3
    mux_map_next ;Set the next row active in the mapping table.
    branch 0,loop1 ;Now the loop will be continuous and the program execution will not go to external trigger. The LED mapping will automatically go to the first mapping address after reaching the mapping table end.

    wait 0.2
    rst ;Reset program counter and start the program again. Basically you can remove these as the program would never reach these commands

    .segment program2 ;Program for engine 2. (this is program for engine 3)
    mux_map_start row1 ;Map the first LED.
    mux_ld_end row9 ;End address of the mapping data table.
    loop2: trigger w{1} ;Wait for trigger from engine1. Now this needs to be corrected to w{1}, wait trigger from engine 1
    ramp 0.18,-255 ;Decrease PWM 100->0% in 1 second.
    mux_map_next ;Set the next row active in the mapping table.
    branch 0,loop2 ;Loop continuosly

    rst Not needed if there is infinite looping

    Let me know if this helps you,

    Thank you,

    Sami

     

  • Hi Sami,

    It works. Thanks! 

  • Hi Sami,

    I want to press the trigger to start the LED loop and press the trigger again for stop it. Could you help it? Thanks!

    mapping_table: dw 0000000111111111b ;Red LEDs on the evaluation board.
    ;'1' = LED is mapped; '0'= LED isn't mapped.
    .segment program1 ;Begin of a segment.
    mux_map_start mapping_table ;Mapping table start address in the memory.
    ;The first row of the table will be activated
    trigger w{e} ;
    loop1: wait 0.484
    ramp 3, 255 ;PWM 0%->100% in 0.5 second.
    wait 0.484
    ramp 2, -255 ;PWM 100%->0% in 1 second.
    trigger s{2}
    branch 0,loop1 ;
    .segment program2
    mux_map_start mapping_table
    trigger w{e} ;
    rst

  • Hi Jerry,

    If you want to start and stop the program execution with the same triggering signal, I think you would need to have a different approach to this. The external triggering command waits for the external trigger and then moves on with the code execution, so you do not have any conditional possibility there. So with external trigger command, it is more difficult to do.

    However, LP5523 supports the variables and you can have conditional jumps with the variables. There are basically four different variables, two internal to engines, one global variable and then one variable which is controlled either from I2C register or through the ADC. There is a selection bit for that in register 36h. So you could set the ADC to read the voltage in INT-pin, connect your triggering to that pin and then you would set jumps according to that pin voltage level with the variable D.

    Do you have possibility to do this or change your HW to support this?

    Thank  you,

    Sami