A:AW21024X_AW21036X的open或short检测,需在灯常亮状态下执行。核心操作逻辑是先点亮所有LED灯,再通过寄存器配置启动检测并读取结果,具体操作流程及参数配置如下:
1、 点亮所有LED,完成以下寄存器配置步骤:
1) 使能芯片:0x00寄存器的CHIPEN位设置为1;
|
GCR: Global Control Register(Address 00H)
|
|
|
Bit
|
Symbol
|
R/W
|
Description
|
Default
|
|
0
|
CHIPEN
|
RW
|
Chip enable
0: Disable (default)
1: Enable
|
0
|
2) 将所有LED灯的亮度BRx和颜色COLx都设置为0xff
|
BR: BR Register(Address 01H~24H)
|
|
|
Bit
|
Symbol
|
R/W
|
Description
|
Default
|
|
7:0
|
BR
|
RW
|
Individual 8bit BR parameter for LED1~36.
After configuring the BR registers, should write 0x00 to register UPDATE to update the data.
|
0x00
|
|
COL0~COL35: COL Register(Address 4AH~6DH)
|
|
|
|
|
Bit
|
Symbol
|
R/W
|
Description
|
Default
|
|
|
|
7:0
|
COL
|
RW
|
Individual 8bit COL parameter for LED1~36.
|
0x00
|
|
|
3) 通过给0x49寄存器写0x00让亮度BRx寄存器的值生效
|
UPDATE: Update Register(Address 49H)
|
|
|
Bit
|
Symbol
|
R/W
|
Description
|
Default
|
|
7:0
|
UPDATE
|
W
|
Write 0x00 to update BR register.
|
0x00
|
4) 将0x78寄存器的bit7:bit5设置为b111,即PWM占空比设置成100%
|
SSCR: Spread Spectrum Control Register (Address 78H)
|
|
|
Bit
|
Symbol
|
R/W
|
Description
|
Default
|
|
7
|
PWMDIS2
|
RW
|
0: PWM duty of LED 25~36 determined by BR24~BR35
1: PWM duty of LED 25~36 fixed as 100%
|
0
|
|
6
|
PWMDIS1
|
RW
|
0: PWM duty of LED 13~24 determined by BR12~BR23
1: PWM duty of LED 13~24 fixed as 100%
|
0
|
|
5
|
PWMDIS0
|
RW
|
0: PWM duty of LED 1~12 determined by BR0~BR11
1: PWM duty of LED 1~12 fixed as 100%
|
0
|
5) 根据当前项目使用的LED参数和硬件电阻大小,设置全局电流(0x6E寄存器);推荐设置为0x0f
|
GCCR: Global Control Register(Address 6EH)
|
|
|
Symbol
|
R/W
|
Description
|
Default
|
|
|
GCC
|
RW
|
Global current control.
|
0x00
|
|
注意:
(K=200, VREXT = 0.4V, n=1, 2, 3, …, 36)
2、 打开open或short检测,同步设置open和short阈值(0x71寄存器);
|
OSDCR: Open Short Detect Control Register(Address 71H)
|
|
|
Bit
|
Symbol
|
R/W
|
Description
|
Default
|
|
3
|
OTH
|
RW
|
Open threshold
0: 0.1V
1: 0.2V
|
0
|
|
2
|
STH
|
RW
|
Short threshold
0: VDD-1V
1: VDD-0.5V
|
0
|
|
1:0
|
OSDE
|
RW
|
Open short detect enable
b0x: Detect disable
b10: Short detect enable
b11: Open detect enable
|
00
|
3、 延时50ms;
4、 读0x72~0x76寄存器查看检测结果,其对应的位置如下:
|
5、 OSST0~3: Open/Short Status Register (Address 72H~75H)
|
|
|
Bit
|
Symbol
|
R/W
|
Description
|
Default
|
|
7:0
|
OSST
|
R
|
Open/short status of LED1~LED32
0: No open/short event detected
1: Open/short event detected
|
0x00
|
|
OSST4: Open/Short Status Register (Address 76H)
|
|
|
Bit
|
Symbol
|
R/W
|
Description
|
Default
|
|
7:4
|
RESERVED
|
R
|
Reserved
|
0000
|
|
3:0
|
OSST
|
R
|
Open/short status of LED33~LED36
0: No open/short detected
1: Open/short detected
|
0000
|
6、 用AW21036QNR举例如下:
1. //1.点亮所有灯
2. // Chip enable
3. aw_i2c_writebyte(I2C_ADDR, 0x00, 0x01);
4. // Set BRx
5. for(int i = 0;i < NUMS; i++){ //NUMS是LED的个数
6. aw_i2c_writebyte(I2C_ADDR, 0x01 + i, 0xFF);
7. }
8. // Set SLx
9. for(int i = 0;i < NUMS; i++){ //NUMS是LED的个数
10. aw_i2c_writebyte(I2C_ADDR, 0x4A + i, 0xFF);
11. }
12. // update BRx
13. aw_i2c_writebyte(I2C_ADDR, 0x49, 0x00);
14. // Set pwm duty
15. aw_i2c_writebyte(I2C_ADDR, 0x78, 0xE0);
16. // Set global current
17. aw_i2c_writebyte(I2C_ADDR, 0x6E, 0x0f); //需要根据项目进行计算设置
18.
19. //2.开始short检测
20. aw_i2c_writebyte(I2C_ADDR, 0x71, AW210XX_STH << 2 | AW210XX_BIT_SHORT_EN); // AW210XX_STH是短路的阈值,0=VDD-1V,1=VDD-0.5V;AW210XX_BIT_SHORT_EN = 0x02是short检测
21. soft_delay(50); //延时50ms
22. for(int i = 0x72;i < 0x76; i++){
23. aw_i2c_readbyte(I2C_ADDR, i, short_result); //short_result值就是咱们short检测结果,按照手册描述查找对应位置
24. }
25. //3.开始open检测
26. aw_i2c_writebyte(I2C_ADDR, 0x71, AW210XX_OTH << 3 | AW210XX_BIT_OPEN_EN); // AW210XX_OTH是open的阈值,0=0.1V,1=0.2V; AW210XX_BIT_SHORT_EN = 0x03是short检测
27. soft_delay(50); //延时50ms
28. for(int i = 0x72;i < 0x76; i++){
29. aw_i2c_readbyte(I2C_ADDR, i, open_result); //open_result值就是咱们open检测结果,按照手册描述查找对应位置
30. }
31. //4.软件复位并按照项目需求进行初始化