Tool/software:
Unfortunately, the autonomous mode on my LP5080 is not working as expected. In the following code, an LED should theoretically start at 0, increase to a certain brightness, and then return to 0. However, with this code, the LED starts very bright and then becomes unpredictably dimmer and brighter. Where could the issue lie?
When I control each LED individually, everything works as intended. The brightness can be adjusted using current and PWM, and manual dimming through loops works perfectly as well.
#include <i2c.h> #include <LP5810.h> /*Chip address*/ #define I2C_LP581X_5BIT_ADDRESS 0x15 /***************************************************************************//** *Register Address ******************************************************************************/ /* Device Configuration Register Address*/ #define Chip_Enable_Register 0x000 #define Dev_Config0_Register 0x001//Max Current Sink Current & Boost Output Voltage #define Dev_Config1_Register 0x002//Direct Connected Outputs(Only effective when configured to Mix Drive Mode) & LED Configuration & PWM Dimming Frequency Setting #define Dev_Config2_Register 0x003//Scan Line FET Number in Matrix Mode #define Dev_Config3_Register 0x004//LED Autonomous Control Enable #define Dev_Config4_Register 0x005//LED Autonomous Control Enable #define Dev_Config5_Register 0x006//LED Exponential Dimming Curve Enable #define Dev_Config6_Register 0x007//LED Exponential Dimming Curve Enable #define Dev_Config7_Register 0x008//PWM Phase Align Method #define Dev_Config8_Register 0x009//PWM Phase Align Method #define Dev_Config9_Register 0x00A//PWM Phase Align Method #define Dev_Config10_Register 0x00B//PWM Phase Align Method #define Dev_Config11_Register 0x00C//Line Change Time & Vsync setting #define Dev_Config12_Register 0x00D//LSD Fault Comparator Threshold & Action When LSD/LOD & Clamp Behavior setting /*Command registers*/ #define Update_CMD_REG 0x010 //Write 55h to send this command #define Start_CMD_REG 0x011 //Write FFh to send this command #define Stop_CMD_REG 0x012 //Write AAh to send this command #define Pause_CMD_REG 0x013 //Write 33h to send this command #define Continue_CMD_REG 0x014 //Write CCh to send this command /*LED_EN Registers*/ #define LED_EN1 0x020 /*FAULT_CLEAR REGISTERS*/ #define Fault_CLR_REG 0x022 /*RESET REGISTERS*/ #define RESET_REG 0x023 /*MANUAL_DC REGISTERS*/ /*LED0/LED1/LED2/LED3/LED_A0/LED_A1/LED_A2/LED_B0/LED_B1/LED_B2/LED_C0/LED_C1/LED_C2/LED_D0/LED_D1/LED_D2/ */ #define Manual_DC_GAP 0x001 #define Manual_DC_LED_1 0x030 #define Manual_DC_LED_2 0x031 #define Manual_DC_LED_3 0x032 #define Manual_DC_LED_4 0x033 /*MANUAL_PWM REGISTERS*/ /*LED0/LED1/LED2/LED3/LED_A0/LED_A1/LED_A2/LED_B0/LED_B1/LED_B2/LED_C0/LED_C1/LED_C2/LED_D0/LED_D1/LED_D2/ */ #define Manual_PWM_GAP 0x001 #define Manual_PWM_LED_1 0x040 #define Manual_PWM_LED_2 0x041 #define Manual_PWM_LED_3 0x042 #define Manual_PWM_LED_4 0x043 /*MANUAL_DC REGISTERS*/ /*LED0/LED1/LED2/LED3/LED_A0/LED_A1/LED_A2/LED_B0/LED_B1/LED_B2/LED_C0/LED_C1/LED_C2/LED_D0/LED_D1/LED_D2/ */ #define Auto_DC_GAP 0x001 #define Auto_DC_START 0x050 /*AUTONOMOUS CONTROL REGISTERS*/ /*LED0/LED1/LED2/LED3/LED_A0/LED_A1/LED_A2/LED_B0/LED_B1/LED_B2/LED_C0/LED_C1/LED_C2/LED_D0/LED_D1/LED_D2/ */ #define LED_AEU_GAP 0x01A #define AEU_GAP 0x008 #define LED0_Pause_Time 0x080 #define LED0_Playback_Time 0x081 #define LED0_AEU1_PWM1 0x082 #define LED0_AEU1_PWM2 0x083 #define LED0_AEU1_PWM3 0x084 #define LED0_AEU1_PWM4 0x085 #define LED0_AEU1_PWM5 0x086 #define LED0_AEU1_SlOPE_TIME1 0x087 #define LED0_AEU1_SlOPE_TIME2 0x088 #define LED0_AEU1_PT1 0x089 #define LED0_AEU2_PWM1 0x08A #define LED0_AEU2_PWM2 0x08B #define LED0_AEU2_PWM3 0x08C #define LED0_AEU2_PWM4 0x08D #define LED0_AEU2_PWM5 0x08E #define LED0_AEU2_SlOPE_TIME1 0x08F #define LED0_AEU2_SlOPE_TIME2 0x090 #define LED0_AEU2_PT1 0x091 #define LED0_AEU3_PWM1 0x092 #define LED0_AEU3_PWM2 0x093 #define LED0_AEU3_PWM3 0x094 #define LED0_AEU3_PWM4 0x095 #define LED0_AEU3_PWM5 0x096 #define LED0_AEU3_SlOPE_TIME1 0x097 #define LED0_AEU3_SlOPE_TIME2 0x098 #define LED0_AEU3_PT1 0x099 #define LED1_Pause_Time 0x09A #define LED1_Playback_Time 0x09B #define LED1_AEU1_PWM1 0x09C #define LED1_AEU1_PWM2 0x09D #define LED1_AEU1_PWM3 0x09E #define LED1_AEU1_PWM4 0x09F #define LED1_AEU1_PWM5 0x0A0 #define LED1_AEU1_SlOPE_TIME1 0x0A1 #define LED1_AEU1_SlOPE_TIME2 0x0A2 #define LED1_AEU1_PT1 0x0A3 #define LED1_AEU2_PWM1 0x0A4 #define LED1_AEU2_PWM2 0x0A5 #define LED1_AEU2_PWM3 0x0A6 #define LED1_AEU2_PWM4 0x0A7 #define LED1_AEU2_PWM5 0x0A8 #define LED1_AEU2_SlOPE_TIME1 0x0A9 #define LED1_AEU2_SlOPE_TIME2 0x0AA #define LED1_AEU2_PT1 0x0AB #define LED1_AEU3_PWM1 0x0AC #define LED1_AEU3_PWM2 0x0AD #define LED1_AEU3_PWM3 0x0AE #define LED1_AEU3_PWM4 0x0AF #define LED1_AEU3_PWM5 0x0B0 #define LED1_AEU3_SlOPE_TIME1 0x0B1 #define LED1_AEU3_SlOPE_TIME2 0x0B2 #define LED1_AEU3_PT1 0x0B3 /* FLAG Register Address*/ #define TSD_CONFIG_STATUS 0x300 #define LOD_STATUS1 0x301 #define LOD_STATUS2 0x302 #define LSD_STATUS1 0x303 #define LSD_STATUS2 0x304 /* TEST Register Address*/ #define OTP_CONFIG_Register 0x352 #define SRAM_CONFIG_Register 0x353 #define CLOCK_GATING_EN_Register 0x354 uint8_t I2C_TARGET_ADDRESS; uint8_t regAdr_8bit; uint16_t regAdr_10bit; /***************************************************************************//** *Function Definition ******************************************************************************/ void initLP5810(){ // Reset and configure writeRegister(RESET_REG, 0x66); writeRegister(Chip_Enable_Register, 0x01); writeRegister(Dev_Config0_Register, 0x0F); // 0x0 max current 25.5 mA, 0x0F 51 mA writeRegister(Dev_Config1_Register, 0x40); // LED direct drive mode writeRegister(Dev_Config3_Register, 0x0F); // Auto enable writeRegister(Dev_Config5_Register, 0x0); // exponential diming off writeRegister(Dev_Config12_Register, 0x0B); // Update updateCommand(); } void LED_Fade_IN_And_OUT(){ // Set LED Auto - LED enable writeRegister(LED_EN1, 0x0F); // Update updateCommand(); // Red LED AUto Start writeRegister(0x051, 0x0F); writeRegister(LED0_Pause_Time, 0x00); // APU1 and APU2 skipped writeRegister(LED0_Playback_Time, 0x01); // one time writeRegister(LED0_AEU1_PWM1, 0); // start at 0 writeRegister(LED0_AEU1_PWM2, 25); writeRegister(LED0_AEU1_PWM3, 50); // rise to 50 writeRegister(LED0_AEU1_PWM4, 25); writeRegister(LED0_AEU1_PWM5, 0); // end at 0 writeRegister(LED0_AEU1_SlOPE_TIME1, 0xAA); // 3 sek between all steps writeRegister(LED0_AEU1_SlOPE_TIME2, 0xAA); writeRegister(LED0_AEU1_PT1, 3); // repeat inf delay_ms(5); updateCommand(); delay_ms(5); writeRegister(Start_CMD_REG, 0xFF); } updateCommand(){ regAdr_10bit = Update_CMD_REG; I2C_TARGET_ADDRESS = (I2C_LP581X_5BIT_ADDRESS<<2) + (regAdr_10bit>>8); regAdr_8bit = (uint8_t) regAdr_10bit; I2C_Master_WriteRegByte(I2C_TARGET_ADDRESS, regAdr_8bit, 0x55); // update command to complete config delay_ms(5); } writeRegister(uint16_t regAdr_10bit, uint8_t value){ I2C_TARGET_ADDRESS = (I2C_LP581X_5BIT_ADDRESS<<2) + (regAdr_10bit>>8); regAdr_8bit = (uint8_t) regAdr_10bit; I2C_Master_WriteRegByte(I2C_TARGET_ADDRESS, regAdr_8bit, value); }