找回密码
 立即注册
楼主: capcomsnk

能否输出一组18个不同周期不同占空比的脉冲。

[复制链接]
  • 打卡等级:偶尔看看I
  • 打卡总天数:12
  • 最近打卡:2026-03-23 19:29:42
已绑定手机

17

主题

28

回帖

262

积分

中级会员

积分
262
发表于 2024-7-9 17:21:01 | 显示全部楼层
好的。那就用10us中断,累计35次后反转。
回复

使用道具 举报 送花

  • 打卡等级:以坛为家III
  • 打卡总天数:648
  • 最近打卡:2026-03-28 09:50:19

33

主题

2923

回帖

6583

积分

论坛元老

积分
6583
发表于 2024-7-9 17:34:04 | 显示全部楼层
capco*** 发表于 2024-7-9 17:21
好的。那就用10us中断,累计35次后反转。

或者用SPI  模拟单总线协议?  类似SPI驱动WS2812   

这种的满足要求么
参考例程并不是对技术参 考手册的补充,而是对技术参 考手册的解释。
技术参 考手册不应该需要参考例程作为补充,而是解释成了参考例程的样子
回复

使用道具 举报 送花

  • 打卡等级:以坛为家III
  • 打卡总天数:677
  • 最近打卡:2026-03-29 16:06:28

9

主题

621

回帖

4316

积分

论坛元老

积分
4316
发表于 2024-7-9 18:28:40 | 显示全部楼层
要看下最小脉宽和最大脉宽都是多少us,脉宽变化一共几种,
中断响应时间有不确定性因素,得评估下可行性.
如果单次发送总时间不长的话,可以结合精确延时直接操作IO脚,
回复

使用道具 举报 送花

  • 打卡等级:以坛为家I
  • 打卡总天数:364
  • 最近打卡:2026-03-29 10:59:24

844

主题

1万

回帖

2万

积分

管理员

积分
22775
发表于 2024-7-9 20:09:11 | 显示全部楼层
用 3个 STC8G2K64S4
截图202407092127504584.jpg
截图202407092128237507.jpg

回复

使用道具 举报 送花

  • 打卡等级:以坛为家III
  • 打卡总天数:783
  • 最近打卡:2026-03-29 11:38:35
已绑定手机

33

主题

381

回帖

3548

积分

论坛元老

机长

积分
3548
发表于 2024-7-9 21:43:48 | 显示全部楼层
wnagming 发表于 2024-7-9 20:57
你这个方法脉冲对齐都是问题

一个芯片输出主时钟,其它的用它当主频输入
业余撸代码,专业开飞机 https://gitee.com/STC-MCU
回复

使用道具 举报 送花

  • 打卡等级:偶尔看看I
  • 打卡总天数:13
  • 最近打卡:2025-11-12 06:39:47

5

主题

190

回帖

1563

积分

金牌会员

积分
1563
发表于 2024-7-10 05:14:16 | 显示全部楼层
本帖最后由 jmg 于 2024-7-10 06:58 编辑
capco*** 发表于 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[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.

回复

使用道具 举报 送花

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

GMT+8, 2026-3-29 20:16 , Processed in 0.106569 second(s), 80 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表