OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 4310|回复: 1

ADC通过DMA传输的数据检查

[复制链接]

1

主题

2

帖子

0

精华

新手入门

积分
4
金钱
4
注册时间
2020-10-26
在线时间
2 小时
发表于 2021-1-14 12:16:53 | 显示全部楼层 |阅读模式
3金钱
STM32F103ZE
用HAL库写的,ADC通过一个500kHz的定时器PWM来触发,通过DMA的循环模式往一个数组里面放采样的数据
但是现在有需求是要能够捕获到一个不知道什么时候发送过来的脉冲波,也就是说需要能够让STM32知道自己接收到了一个脉冲,也就是说我需要在主函数里面对DMA的数组进行不断的检查,是否存储到了大于某个阈值的电压信号,并且在一个DMA周期以后关掉DMA防止原有的数据被覆盖。
但是主函数的运行实在是太慢了,一次循环从stlink里面看到CNDTR已经了0x200以上,也就是说这个判断完全不及时,这直接导致了我不能够及时检测到数据,也不能及时地关闭掉DMA,从而导致波形被复覆盖掉了。

请问以上问题有什么其他的解决思路吗?不需要现成的代码,有个思路就行了。顺便说一下因为之后还要做FFT缓冲区最大可以给4096点。

最佳答案

查看完整内容[请看2#楼]

用模拟看门狗试试,设置合适的阈值直接通过中断触发检测到的事件,在没有有效脉冲的情况下CPU就不用一直比较了。 RM0008文件的11.3.7节: Analog watchdogThe AWD analog watchdog status bit is set if the analog voltage converted by the ADC isbelow a low threshold or above a high threshold. These thresholds are programmed in the12 least significant bits of the ADC_HTR and ADC_LTR 16-bit registers. An inter ...
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

8

主题

154

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
439
金钱
439
注册时间
2018-12-21
在线时间
126 小时
发表于 2021-1-14 12:16:54 | 显示全部楼层
用模拟看门狗试试,设置合适的阈值直接通过中断触发检测到的事件,在没有有效脉冲的情况下CPU就不用一直比较了。
RM0008文件的11.3.7节:
Analog watchdogThe AWD analog watchdog status bit is set if the analog voltage converted by the ADC isbelow a low threshold or above a high threshold. These thresholds are programmed in the12 least significant bits of the ADC_HTR and ADC_LTR 16-bit registers. An interrupt can beenabled by using the AWDIE bit in the ADC_CR1 register.The threshold value is independent of the alignment selected by the ALIGN bit in theADC_CR2 register. The comparison is done before the alignment (see Section 11.5).The analog watchdog can be enabled on one or more channels by configuring theADC_CR1 register as shown in Table 66.
Capture.PNG
回复

使用道具 举报

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

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-15 18:12

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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