- 打卡等级:初来乍到
- 打卡总天数:4
- 最近打卡:2025-05-01 06:58:22
金牌会员
- 积分
- 1333
|
发表于 2024-7-10 05:14:16
|
显示全部楼层
本帖最后由 jmg 于 2024-7-10 06:58 编辑
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[n] 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.
|
|