STM32H7 | DMA传输期间缺少portenta H7数据(ADC到内存)

发布于 2025-01-28 06:44:24 字数 808 浏览 6 评论 0原文

我目前正在使用STM32H747XI(portenta H7)。我是用DMA1编程ADC1以以1MSP的形式获取16bits数据。

对不起,我无法共享我的整个代码,但是我将尝试尽可能准确地描述我的配置。

我正在使用1MHz计时器触发的ADC1。 ADC正在以DMA圆形和双缓冲区模式为连续模式。我尝试了直接模式,并用完整的FIFO爆发。我没有DMA错误Intercrupe,也没有ADC超支。

我的外围活动正在运行,但我陷入了两个问题的前面。第一期,我在8192 UINT16_T的缓冲区中使用Arduino函数USBSerial.Write(BUF,LEN)将其发送到USB CDC上。在这种情况下,USB传输正确,但是我的缓冲区中有一些丢失的数据。 DMA增量内存但不写。因此,我没有缺少示例,但是值是错误的(属于旧的缓冲区)。

您可以看到以下数据图: 带有8192个样本的传输

如果我加倍缓冲尺寸,则此问题已固定,但另一个问题是固定的。如果数据缓冲区长于16384字节,则USB VPC传输失败。一些数据被剪切。我试图通过不同的发送和延迟来解决此问题,但行之有效。我仍然有同样的削减。

在这里,同一脚本的数据图带有更长的缓冲区:用16384个样本的缓冲区(32768 byte)<) /a>

感谢您的帮助。我仍然可用。

I'm currently working on STM32H747XI (Portenta H7). I'am programming the ADC1 with the DMA1 to get 16bits data at 1Msps.

I'm sorry, I can't share my entire code but I will therefore try to describe my configuration as precisely as possible.

I'm using the ADC1 trigged by a 1MHz timer. The ADC is working in continus mode with the DMA circular and double buffer mode. I tryed direct mode and burst with a full FIFO. I have no DMA error interrupe and no ADC overrun.

My peripheral are running but I'm stuck front of two issues. First issue, I'am doing buffer of 8192 uint16_t and I send it on the USB CDC with the arduino function USBserial.Write(buf,len). In this case, USB transfer going right but I have some missing data in my buffer. The DMA increments memory but doesn't write. So I don't have missing sample but the value is false (it belongs to the old buffer).

You can see the data plot below :
transfer with buffer of 8192 samples

If I double the buffer size, this issue is fixed but another comes. The USB VPC transfer fail if the data buffer is longer than 16384 byte. Some data are cut. I tried to solve this with differents sending and delays but it doesn't work. I still have the same kind of cut.

Here the data plot of the same script with a longer buffer : transfer withe buffer of 16384 sample (32768 byte)

Thank you for your help. I remain available.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧情勿念 2025-02-04 06:44:24

对于快速检查,请尝试禁用数据缓存。您可能无法正确管理缓存,或者您没有在使用DMA的内存空间中禁用缓存。
外围设备不知道缓存,因此您必须手动管理它。在这种情况下,您还必须将缓冲区与缓存线对齐。

请参阅 an4839

For a fast check try to disable data cache. You're probably not managing cache correctly or you haven't disable caching in the memory space where you're using DMA.
Peripherals are not aware of cache so you must manage it manually. You have also to align buffers to cache lines in this case.

Refer to AN4839

花海 2025-02-04 06:44:24

我正在使用STM32H750。 dcache禁用。我拥有的缓冲区是在RAM_D1中。我正在使用CDC。

在USB DMA禁用的情况下,事情有效。

用DMA Wireshark向我展示,urb_function_sync_reset_pipe_and_clear_stall
我确实得到了2-5个tra​​snfers,然后停滞了。

我也需要DMA,因为如果没有DMA,USB HAL驱动程序写入功能需要太多的CPU周期和我的ADC管道上的超支。该问题受到Windows主机的繁忙程度的影响...当不忙碌时,非DMA可以工作。但是,当我的PC Side应用程序非常忙时,串行读取速度较慢,因此数据会备份各种级别的缓冲。当PC消耗数据增益时,STM32H7试图将大量数据寄回,而这些非DMA传输会采取太多的周期。

这些链接有所帮助,

https://community.st.com/t5/stm32-mcus-embedded-software/problem-with-stm32h747-h747-hs-usb-dma/mp/165464#m9835

https://community.st.com/t5/stm32-mcus/how-to-correctly-setup-your-application-to-use-usb-dma/ta-pa/49522“ rel =“ nofollow noreferrer”> https

//community.st.com/t5/stm32-mcus/how-to-correctly-setup-your-application-to-use-usb-dma/ta-p/49522

: > D1和D2域通过总线桥连接,两个都可以在D3域中访问数据。但是,从D3域到D1或D2域没有连接。 DMA1和DMA2控制器位于D2域中,除了ITCM和DTCM RAM(位于0x20000000)之外,几乎可以访问所有记忆。在大多数情况下,使用此DMA。 BDMA控制器位于D3域中,只能访问D3域中的SRAM4和备份SRAM。 MDMA控制器位于D1域中,可以访问包括ITCM/DTCM在内的所有记忆。该控制器主要用于处理域之间的D1外围设备和内存传输。在上图中,我们可以看到USBHS1和USBHS2位于D2域中,并且与DTCM RAM没有互连,这是大约所有USB项目中使用的默认内存。 当启用内部DMA USB时,项目将无法工作,因为DMA将无法访问DTCM中放置的数据缓冲区,并且会导致DMA传输错误

因此,

。具有OTG HS Core的驱动程序,启用DMA模式(在USB_Conf.h文件中定义USB_OTG_HS_INTERNAL_DMA_ENABLED)导致数据仅由4个字节中的多个发送。这是由于USB DMA不允许从非单词一致地址发送数据的事实。对于此特定应用,建议除非需要,否则请不要启用此选项。来自:UM1734用户手册STM32CUBE USB设备库DOCID025934 REV 1

我尚未符合我想要的最终结果,但是我可以与目标交换。

I am using STM32H750. DCache disabled. The buffer I have is in RAM_D1. I am using CDC.

With USB DMA disabled, things work.

With DMA WireShark shows me, URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL
I do get 2-5 trasnfers through, and then it stalls.

I also need DMA because without DMA, the USB HAL driver write function takes too many CPU cycles and my ADC pipelining overruns. The issue is impacted by how busy Windows host is... when not busy, non-DMA works. But when my PC side App is very busy, the serial read is slower, so data gets backed up on various levels of buffering. When PC consumes data gain, STM32H7 tries to send a lot of data back, and those non-DMA transfers take too many cycles.

These links helped,

https://community.st.com/t5/stm32-mcus-embedded-software/problem-with-stm32h747-hs-usb-dma/m-p/165464#M9835

https://community.st.com/t5/stm32-mcus/how-to-correctly-setup-your-application-to-use-usb-dma/ta-p/49522

And note this,

D1 and D2 domains are connected through bus bridges, both can also access data in D3 domain. However, there is no connection from D3 domain to D1 or D2 domain. The DMA1 and DMA2 controllers are located in D2 domain and can access almost all memories with exception of ITCM and DTCM RAM (located at 0x20000000). This DMA is used in most cases. BDMA controller is located in D3 domain and can access only SRAM4 and backup SRAM in D3 domain. MDMA controller is located in D1 domain and can access all memories, including ITCM/DTCM. This controller is mainly used for handling D1 peripherals and memory transfers between domains. In the previous figure, we can see that USBHS1 and USBHS2 are located in D2 domain and have no interconnection with DTCM RAM which is the default memory used in approximately all USB projects. Therefore when enabling the internal DMA USB, projects do not work, as DMA will not be able to access the data buffers placed in DTCM and it results in DMA transfer error.

and,

CDC known limitations When using this driver with the OTG HS core, enabling DMA mode (define USB_OTG_HS_INTERNAL_DMA_ENABLED in usb_conf.h file) results in data being sent only by multiple of 4 bytes. This is due to the fact that USB DMA does not allow sending data from non word-aligned addresses. For this specific application, it is advised not to enable this option unless required. From: UM1734 User manual STM32Cube USB device library DocID025934 Rev 1

I am not yet acheiving the final result I want, but i can exchange with the target.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文