1.我正在编写用于连接DP1903和MCU的代码。 MCU由16MHz内部振荡器运行。
根据DP1903数据表;
TIH = 2us & T1L = 0.5us +-150ns
T0H = 0.5us,t0l = 2us +-150ns
Treset >= 24us
数据表: www.depuw.com/.../DP1903.pdf
第4页和第5页指定时间安排。
3.提及800kHz和400kHz速度的目的是什么? 我必须如何将其计入代码中?
数据表指定了第1点中已写入的计时,因此我需要根据该信息编写代码,对吗?
这800kHz是如何介于两者之间的? 这意味着什么?
4.假设我必须在某个给定点发送一个零脉冲,然后再发送一个复位脉冲。
因此,正时将为T0H,t0l和Treset,即
答 引脚高,0.5us
B. 引脚低电平,用于2.0us
C. 引脚低,用于24us
在步骤b之后,我必须再次将其设为高,然后再设为低? 与第4页相同,t0l完成位是否再次变为高? 或者仅用于展示,我可以将步进b和c组合在一起,并保持引脚低电平24 + 2 = 26 us?
5.附件是我的密码。 我在运行代码时有时看到一些问题。 代码在全速优化(即O3)上运行,
主要是打开所有指示灯蓝色时出现问题,指示灯不是全部呈蓝色亮起,而是出现一些白色的颜色。
6.我连接了100个LED。 还注意到,如果我延迟24小时,颜色根本不能正确显示,50小时有一些问题,再增加延迟不会有任何影响。 为什么会这样?
7.对于0.5us,使用8 nops,而对于2us,使用32 nops。
int main (void)
{
LED_PIN_OUTPT_LOW (低);
同时(1)
{
ws2811_reset_us (50);
对于(LED_cnt = 0U;LED_cnt < 100U;LED_cnt++)
{
ws2811_rgb_write(0xff, 0x00, 0x00);
}
DELAY秒(2);
ws2811_reset_us (50);
对于(LED_cnt = 0U;LED_cnt < 100U;LED_cnt++)
{
ws2811_rgb_write(0x00,0xff,0x00);
}
DELAY秒(2);
ws2811_reset_us (50);
对于(LED_cnt = 0U;LED_cnt < 100U;LED_cnt++)
{
ws2811_rgb_write(0x00,0x00,0xff);
}
delay_sec(2);
}
}/*函数在此处结束*/
静态void ws2811_rgb_write(uint8_t red, uint8_t green , uint8_t blue){
uINT8_t red_arr[8];
uINT8_t green_arr[8];
uINT8_t blue_arr[8];
uINT8_t cn;
UINT8_t idx;
/*将RGB的位值存储在数组*/中
IDX = 0x80U;
对于(cnt = 0U;cnt < 8U;cnt++)
{
IF (红色和idx)
{
red_arr[cnT]= 1U;
}
否则
{
red_arr[cnT]= 0U;
}
IF (绿色和idx)
{
green_arr[cn]= 1U;
}
否则
{
green_arr[cnt]= 0U;
}
IF (蓝色和idx)
{
blue_arr[cn]= 1U;
}
否则
{
blue_arr[cnT]= 0U;
}
IDX = idx >> 1U;
}
/*尽可能快地发送像素*/
/*红色像素*/
if (red_arr[0]){ ws2811_bit_set();} else { ws2811_bit_reset();}
IF (RED_ARr[1]){ ws2811_bit_set();} else { ws2811_bit_reset();}
IF (RED_ARr[2]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (red_arr[3]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (red_arr[4]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (red_arr[5]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (red_arr[6]){ ws2811_bit_set();} else { ws2811_bit_reset();}
IF (RED_ARr[7]){ ws2811_bit_set();} else { ws2811_bit_reset();}/*
绿色像素*/
if (green_arr[0]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (green_arr[1]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (green_arr[2]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (green_arr[3]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (green_arr[4]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (green_arr[5]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (green_arr[6]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (green_arr[7]){ ws2811_bit_set();} else { ws2811_bit_reset();}/*
blue pixel */
if (blue_arr[0]){ ws2811_bit_set();} else { ws2811_bit_reset();}
IF (blue_arr[1]){ ws2811_bit_set();} else { ws2811_bit_reset();}
IF (blue_arr[2]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (blue_arr[3]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (blue_arr[4]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (blue_arr[5]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (blue_arr[6]){ ws2811_bit_set();} else { ws2811_bit_reset();}
if (blue_arr[7]){ ws2811_bit_set();} else { ws2811_bit_reset();}
/*函数在此处结束*/
静态内联void ws2811_bit_set(void){
LED_PIN_ON();
__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();
__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();
__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();
__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();
LED_PIN_OFF();
__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation()
;}
静态内联void ws2811_bit_reset(void){
LED_PIN_ON();
__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();
LED_PIN_OFF();
__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();
__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();
__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();
__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation();__no_operation()
;}