好的。那就用10us中断,累计35次后反转。
或者用SPI模拟单总线协议?类似SPI驱动WS2812
这种的满足要求么{:4_171:} 要看下最小脉宽和最大脉宽都是多少us,脉宽变化一共几种,
中断响应时间有不确定性因素,得评估下可行性.
如果单次发送总时间不长的话,可以结合精确延时直接操作IO脚, 用 3个 STC8G2K64S4
wnagming 发表于 2024-7-9 20:57
你这个方法脉冲对齐都是问题
一个芯片输出主时钟,其它的用它当主频输入{:4_164:} 本帖最后由 jmg 于 2024-7-10 06:58 编辑
capcomsnk 发表于 2024-7-9 16:17
遇到新问题了,目前TIMER中断的方式来累计,1us中断一次来累计时间。低电平固定350us,到了时间也就是累计 ...
If your shortest time is 350us, do not use a 1us interrupt.
That uses far too much CPU resource.
Almost any reload timer with pin toggle can manage this.
You reload and interrupt just twice per pulse, once per edge.
eg prime by set timer to 0xffff and reload to 350us, then start.
The HW immediately pulls the pin low and loads T=350us.
On interrupt, if Pin = L then set reload=TH time, if pin = H set reload = 350us LOW
Repeat until your 18 pulses are done and disable timer.
The STC parts have a quirk where you need to pause TnR in order to reload R_TnH/L but that is a narrow fixed window.
You could also use a PWM block for this, where you set the LOW time and vary the reload time,thus needing one interrupt per pulse.
The PWM blocks are more complex, and you might not want to consume the whole PWM block for one pulse train on one pin.
页:
1
[2]