LP55231: Seemingly uncontrolled LED behavior using engines

Part Number: LP55231

Tool/software:

I have three sequences programmed into memory. I use one engine to run each of the sequences (never simultaneously). 

  • Pulsating white program using D1, D2 and D7
  • Solid white program (again, D1, D2 and D7)
  • Blinking orange program (only D2 and D7)

The sequences work on their own (tested when all outputs were off), but when switching from pulsating or solid sequence to blinking, the mapping seems bugged.

Sometimes the blue LED (D1) will be on and red is blinking (making blue - magenta - blue - magenta...), and sometimes red (D2) and green (D7) are blinking and blue is off (which is as intended!). This behavior seems quite random to me.

Here's my code:

uint8_t mapping_sequence[] = {
    // Mapping describing which output channels to use (stored in page 0)
    0x00, 0x43, // White (Red D2 + Blue D1 and Green D7)
    0x00, 0x02, // Red D2 (used for orange)
    0x00, 0x40, // Green D7 (used for orange)
};

uint8_t pulsating_white_sequence[] = {
    // Pulsating white program (stored in page 1)
    0x9F, 0x80, // Set mapping to instruction 0
    0x40, 0x00, // PWM off (all LEDs)
    0x40, PULSATING_PWM_HIGHEST, // PWM on
    PULSATING_CYCLES_PER_STEP | 0x01, PULSATING_PWM_STEPS, // Ramp down
    PULSATING_WAITING_CYCLES | 0x40, 0x00, // Wait
    PULSATING_CYCLES_PER_STEP, PULSATING_PWM_STEPS, // Ramp up
    0xA0, 0x03, // Jump to instruction 3
};

uint8_t solid_white_program[] = {
    // Solid white program (stored in page 2)
    0x9F, 0x80, // Set mapping to instruction 0
    PULSATING_CYCLES_PER_STEP, PULSATING_PWM_STEPS, // Ramp up (smooth transition from pulsing)
};

uint8_t blinking_orange_sequence[] = {
    // Blinking orange program (stored in page 3)
    0x9F, 0x80, // Set mapping to instruction 0
    0x40, 0x00, // PWM off (all LEDs)
    0x9F, 0x81, // Set mapping to instruction 1
    0x40, 0x00, // PWM off (Red)
    0x9F, 0x82, // Set mapping to instruction 2
    0x40, 0x00, // PWM off (Green)
    BLINKING_WAITING_CYCLES | 0x40, 0x00, // Wait
    0x9F, 0x81, // Set mapping to instruction 2
    0x40, PWM_RED_ORANGE_BLINKING, // PWM on
    0x9F, 0x82, // Set mapping to instruction 3
    0x40, PWM_GREEN_ORANGE_BLINKING, // PWM on
    BLINKING_WAITING_CYCLES | 0x40, 0x00, // Wait
    0xA0, 0x02, // Jump to instruction 2
};

The reason for the separate mappings for red and green (to make orange) is because I want the PWM/brightness value of both to be separately manageable, giving full control over the color that is seen.

Is something wrong with my code, or is my code bad practice or something?

  • Hi Laura,

    You have 3 sequences, Blinking orange program only control the D2 and D7. So I guess the state for D1 is depend on it state at the moment of the sequence. you can do some experiments to double check:

    1. Switch from Solid white program to Blinking orange program, D1 should be always on

    2. Switch from Pulsating white program to Blinking orange program, D1 should be random

    BTW, can you share me the main function of your code for analysis? you can send the code by email, here are my email address: leon-he@ti.com 

    BRs,

    Leon

  • Hello Leon,

    Thank you for your reply.

    I have checked the things you said, you are correct. When D1 is on while jumping to orange blinking, D1 stays on. But when D1 is off while jumping to orange blinking, D1 stays off.

    I thought this would be prevented by selecting all (D1, D2 and D7) in mapping and setting PWM to off. Do you have any idea why this is not the case?

    I will send the code to you by email.

    EDIT:
    I see that the green LED (D7) is actually blinking as well, but I set it so faint, that is was barely visible.

    Also it seems that the first one or two lines in the blinking code are not executed. And at the end of the blinking program I jump to instruction 2 (which is skipping the first two lines). When I make the end of the blinking program jump to instruction 0, the blue LED (D1) is off, but only after the second loop (so execute instructions 0 and 1 does nothing, then jump to instr. 0 and the D1 is off).

    Hope this gives some clarification. I still don't know why the first two lines don't seem to be executed the first time.

  • Hi Laura,

    Let's move to email to discuss this case. Thanks!

    BRs,

    Leon

  • Okay, I will wait for your reply.

  • Hi Laura,

    I have received your email.

    I will close this case since we can discuss this by email. thank you~

    BRs,

    Leon