首页 > 常见问题 | 艾为电子 > [FAQ0701480]AW20144X_20198X_AW20216X如何实现open或short检测?

[FAQ0701480]AW20144X_20198X_AW20216X如何实现open或short检测?

Sensor&呼吸灯 2025-10-30 阅读量: 121 点赞量: 68

A:1、 AW20144X_20198X_20216Xopenshort检测需要在灯常亮是进行;所以需要点亮所有灯,其流程如下:

1) 使能芯片和当前项目使用的SW通道:

l PAGE0页的0x00寄存器的CHIPEN位设置为1

l PAGE0页的0x00寄存器的SWSEL根据项目使用的SW设置。

GCR: Global Control Register (Page 0: Address 0x00)

Bit

Symbol

R/W

Description

Default

7:4

SWSEL

R/W

Active the SW number select

0000: SW1 active SW2~SW12 not active

0001: SW1~SW2 active SW3~SW12 not active

0010: SW1~SW3 active SW4~SW12 not active

0011: SW1~SW4 active SW5~SW12 not active

0100: SW1~SW5 active SW6~SW12 not active

0101: SW1~SW6 active SW7~SW12 not active

0110: SW1~SW7 active SW8~SW12 not active

0111: SW1~SW8 active SW9~SW12 not active

1000: SW1~SW9 active SW10~SW12 not active

1001: SW1~SW10 active SW11~SW12 not active

1010: SW1~SW11 active SW12 not active

1011~1111: SW1~SW12 active

1011

0

CHIPEN

R/W

Chip enable

0: Disable

1: Enable

0

2) PAGE1页所有灯珠的PWMxPAGE2页所有灯珠的SLx都设置为0xff

PWMx (x=0~215): PWM Configure Register (Page 1: Address 0x00~0xD7)

Bit

Symbol

R/W

Description

Default

7:0

PWMx

R/W

PWM modulated

0x00

SLx (x=0~215): SL Configure Register (Page 2: Address 0x00~0xD7)

Bit

Symbol

R/W

Description

Default

7:0

SLx

R/W

Control the constant current

0x00

3) 根据项目在PAGE0页的0x01寄存器设置全局电流;推荐设置为0x0f

GCCR: Global Current Control Register (Page 0: Address 0x01)

Bit

Symbol

R/W

Description

Default

7:0

GCC

R/W

Global current control

0x00

注意:

Open判断的条件是:CSx引脚上的电压小于VTHopenPAGE00x2B寄存器OTH bit00.1V10.2V);

Short判断的条件是:CSx引脚上的电压大于PVCC-VTHshort(手册的开短路描述VTHshort大小,例如AW20216QNRVTHshort =0.8V

SRCR: Open/Short Control Register (Page 0: Address 0x2B)

Bit

Symbol

R/W

Description

Default

5

OTH

R/W

Open threshold

0: 0.1V

1: 0.2V

0

2、 PAGE0页的0x00寄存器的OSDE打开openshort检测;

GCR: Global Control Register (Page 0: Address 0x00)

Bit

Symbol

R/W

Description

Default

2:1

OSDE

R/W

Open/short detect enable

0x: Detect disable

10: Short detect

11: Open detect

00

3、 延时100ms

4、 PAGE0页的0x03~0x26寄存器查看检测结果,其对应的位置如下:

OSR0~OSR35: Open/Short Status Register (Page 0: Address 0x03~0x26)

Bit

Symbol

R/W

Description

Default

5:0

OSR

R

Open/short status of LED0~LED215

0: Open/short not happen

1: Open/short happen

000000

5、 注意:需要先检测short,将其对应灯珠修改后再进行open检测

6、 AW20216QNR举例如下:

1、 //1.点亮所有灯

2、 // Chip enable and open SW1-SW11

3、 aw_i2c_writebyte(I2C_ADDR, 0xf0, 0xc0);

4、 aw_i2c_writebyte(I2C_ADDR, 0x00, 0xb1);

5、 // Set PWMx

6、 aw_i2c_writebyte(I2C_ADDR, 0xf0, 0xc1);

7、 for(int i = 0;i < NUMS; i++){ //NUMS is the number of LEDs

8、 aw_i2c_writebyte(I2C_ADDR, i,0xff);

9、 }

10、 // Set SLx

11、 aw_i2c_writebyte(I2C_ADDR, 0xf0, 0xc2);

12、 for(int i = 0;i < NUMS; i++){ //NUMS is the number of LEDs

13、 aw_i2c_writebyte(I2C_ADDR, i,0xff);

14、 }

15、 // Set global current

16、 aw_i2c_writebyte(I2C_ADDR, 0xf0, 0xc0);

17、 aw_i2c_writebyte(I2C_ADDR, 0x01, 0x0f); //Need to calculate based on the project

18、

19、 //2.开始short检测

20、 // Set short detection

21、 aw_i2c_readbyte(I2C_ADDR, 0x00, &reg_value);

22、 reg_value &= AW20144_BIT_CHIPEN_DIS; //AW20144_BIT_CHIPEN_DIS = (~(1<<0))

23、 reg_value |= AW20144_BIT_SHORT_EN; //AW20144_BIT_SHORT_EN (0x5)

24、 aw_i2c_writebyte(I2C_ADDR, 0x00, reg_value);

25、 soft_delay(100); //100ms

26、 for(int i = 0x03;i < 0x26; i++){

27、 aw_i2c_readbyte(I2C_ADDR, i, short_result); //short_result值就是咱们short检测结果,按照手册描述查找对应位置

28、 }

29、 //3.修好short位置

30、 //4.开始open检测

31、 // Set VTHopen

32、 aw_i2c_writebyte(I2C_ADDR, 0x29, 0x20);

33、 aw_i2c_writebyte(I2C_ADDR, 0x2B, 0x22); //0x02 OTH=0 VTHopen=0.1V,0x22 OTH=1 VTHopen=0.2V,

34、 // Set open detection

35、 aw_i2c_readbyte(I2C_ADDR, 0x00, &reg_value);

36、 reg_value &= AW20144_BIT_CHIPEN_DIS; //AW20144_BIT_CHIPEN_DIS = (~(1<<0))

37、 reg_value |= AW20144_BIT_OPEN_EN; //AW20144_BIT_OPEN_EN  (0x7)

38、 aw_i2c_writebyte(I2C_ADDR, 0x00, reg_value);

39、 soft_delay(100); //100ms

40、 for(int i = 0x03;i < 0x26; i++){

41、 aw_i2c_readbyte(I2C_ADDR, i, open_result); //open_result值就是咱们open检测结果,按照手册描述查找对应位置

42、 }

43、 aw_i2c_writebyte(I2C_ADDR, 0x29, 0x00);

44、 //5.软件复位并按照项目需求进行初始化

7、 AW20216SQNR举例如下:

1、 //1.点亮所有灯

2、 // Chip enable and open SW1-SW11

3、 aw_spi_writebyte(CMD_PAGE0, 0x00, 0xb1);

4、 // Set PWMx

5、 for(int i = 0;i < NUMS; i++){ //NUMS is the number of LEDs

6、 aw_spi_writebyte(CMD_PAGE1, i,0xff);

7、 }

8、 // Set SLx

9、 for(int i = 0;i < NUMS; i++){ //NUMS is the number of LEDs

10、 aw_spi_writebyte(CMD_PAGE2, i,0xff);

11、 }

12、 // Set global current

13、 aw_spi_writebyte(CMD_PAGE0, 0x01, 0x0f); //Need to calculate based on the project

14、

15、 //2.开始short检测

16、 // Set short detection

17、 aw_spi_readbyte(CMD_PAGE0, 0x00, &reg_value);

18、 reg_value &= AW20144_BIT_CHIPEN_DIS; //AW20144_BIT_CHIPEN_DIS = (~(1<<0))

19、 reg_value |= AW20144_BIT_SHORT_EN; //AW20144_BIT_SHORT_EN (0x5)

20、 aw_spi_writebyte(CMD_PAGE0, 0x00, reg_value);

21、 soft_delay(100); //100ms

22、 for(int i = 0x03;i < 0x26; i++){

23、 aw_spi_writebyte(CMD_PAGE0, i, short_result); //short_result值就是咱们short检测结果,按照手册描述查找对应位置

24、 }

25、 //3.修好short位置

26、 //4.开始open检测

27、 // Set VTHopen

28、 aw_spi_writebyte(CMD_PAGE0, 0x29, 0x20);

29、 aw_spi_writebyte(CMD_PAGE0, 0x2B, 0x22); //0x02 OTH=0 VTHopen=0.1V,0x22 OTH=1 VTHopen=0.2V,

30、 // Set open detection

31、 aw_spi_readbyte(CMD_PAGE0, 0x00, &reg_value);

32、 reg_value &= AW20144_BIT_CHIPEN_DIS; //AW20144_BIT_CHIPEN_DIS = (~(1<<0))

33、 reg_value |= AW20144_BIT_OPEN_EN; //AW20144_BIT_OPEN_EN  (0x7)

34、 aw_spi_writebyte(CMD_PAGE0, 0x00, reg_value);

35、 soft_delay(100); //100ms

36、 for(int i = 0x03;i < 0x26; i++){

37、 aw_spi_writebyte(CMD_PAGE0, i, open_result); //open_result值就是咱们open检测结果,按照手册描述查找对应位置

38、 }

39、 aw_spi_writebyte(CMD_PAGE0, 0x29, 0x20);

40、 //5.软件复位并按照项目需求进行初始化

返回FAQ列表