dma

What is missing to make stm32 ADC DMA work? Transfer Compete does not occur

我是研究僧i 提交于 2019-12-11 01:14:14
问题 I am using a stm32f3 discovery board and the HAL from CubeMX. I am trying to use 2 ADC channels at ADC4. I configured DMA in circular mode. Befor the main loop in main, I call: HAL_ADC_Start_DMA(&hadc4, DMA_adc4_buffer, 16); I implemented the functions HAL_ADC_ConvHalfCpltCallback and HAL_ADC_ConvCpltCallback . Now the strange part: HAL_ADC_ConvHalfCpltCallback is called regularly, HAL_ADC_ConvCpltCallback is NOT. It tells me, that the ADC with DMA transfer is running fine. But why is

程序员需要了解的硬核知识之控制硬件

孤街醉人 提交于 2019-12-10 21:45:40
应用和硬件的关系 我们作为程序员一般很少直接操控硬件,我们一般通过 C、Java 等高级语言编写的程序起到间接控制硬件的作用。所以大家很少直接接触到硬件的指令,硬件的控制是由 Windows 操作系统 全权负责的。 你一定猜到我要说什么了,没错,我会说但是,任何事情没有绝对性,环境的不同会造成结果的偏差。虽然程序员没法直接控制硬件,并且 Windows 屏蔽了控制硬件的细节,但是 Windows 却为你开放了 系统调用 功能来实现对硬件的控制。在 Windows 中,系统调用称为 API ,API 就是应用调用的函数,这些函数的实体被存放在 DLL 文件中。 下面我们来看一个通过系统调用来间接控制硬件的实例 假如要在窗口中显示字符串,就可以使用 Windows API 中的 TextOut 函数。TextOut 函数的语法(C 语言)如下 BOOL TextOut{ HDC hdc, // 设备描述表的句柄 int nXStart, // 显示字符串的 x 坐标 int nYStart, // 显示字符串的 y 坐标 LPCTSTR lpString, // 指向字符串的指针 int cbString // 字符串的文字数 } 那么,在处理 TextOut 函数的内容时,Windows 做了些什么呢?从结果来看,Windows 直接控制了作为硬件的显示器。但 Windows

零拷贝 zero-copy 原理

点点圈 提交于 2019-12-10 13:11:18
引言 传统的 Linux 操作系统的标准 I/O 接口是基于数据拷贝操作的,即 I/O 操作会导致数据在操作系统内核地址空间的缓冲区和应用程序地址空间定义的缓冲区之间进行传输。这样做最大的好处是可以减少磁盘 I/O 的操作,因为如果所请求的数据已经存放在操作系统的高速缓冲存储器中,那么就不需要再进行实际的物理磁盘 I/O 操作。但是数据传输过程中的数据拷贝操作却导致了极大的 CPU 开销,限制了操作系统有效进行数据传输操作的能力。 零拷贝( zero-copy )技术可以有效地改善数据传输的性能,在内核驱动程序(比如网络堆栈或者磁盘存储驱动程序)处理 I/O 数据的时候,零拷贝技术可以在某种程度上减少甚至完全避免不必要 CPU 数据拷贝操作。 什么是零拷贝? 零拷贝就是一种避免 CPU 将数据从一块存储拷贝到另外一块存储的技术。针对操作系统中的设备驱动程序、文件系统以及网络协议堆栈而出现的各种零拷贝技术极大地提升了特定应用程序的性能,并且使得这些应用程序可以更加有效地利用系统资源。这种性能的提升就是通过在数据拷贝进行的同时,允许 CPU 执行其他的任务来实现的。 零拷贝技术可以减少数据拷贝和共享总线操作的次数,消除传输数据在存储器之间不必要的中间拷贝次数,从而有效地提高数据传输效率。而且,零拷贝技术减少了用户应用程序地址空间和操作系统内核地址空间之间因为上下文切换而带来的开销

How can I read from the pinned (lock-page) RAM, and not from the CPU cache (use DMA zero-copy with GPU)?

孤者浪人 提交于 2019-12-10 12:21:13
问题 If I use DMA for RAM <-> GPU on CUDA C++, How can I be sure that the memory will be read from the pinned (lock-page) RAM, and not from the CPU cache? After all, with DMA, the CPU does not know anything about the fact that someone changed the memory and about the need to synchronize the CPU (Cache<->RAM). And as far as I know, std :: memory_barier () from C + +11 does not help with DMA and will not read from RAM, but only will result in compliance between the caches L1/L2/L3. Furthermore, in

STM32 USART串口DMA 接收和发送流程详解

廉价感情. 提交于 2019-12-09 15:04:52
https://blog.csdn.net/weibo1230123/article/details/80506484 1.dma发送流程 1.配置DMA发送中断 - NVIC_Init 2.配置串口中断 - NVIC_Init 3.GPIO配置 - GPIO_Init 4.DMA发送配置 -DMA_Init DMA初始化 -DMA_ITConfig 开启DMA发送中断 5.串口参数初始化 - USART_Init 2.dma接收流程 1.配置串口中断 - NVIC_Init 2.GPIO配置 - GPIO_Init 3.DMA接收配置 -DMA_Init DMA初始化 4.串口参数初始化 - USART_Init 5.开启串口中断 3.DMA发送接收流程 1.配置DMA发送中断 - NVIC_Init 2.配置串口中断 - NVIC_Init 3.GPIO配置 - GPIO_Init 4.DMA发送配置 -DMA_Init DMA初始化 -DMA_ITConfig 开启DMA发送中断 3.DMA接收配置 -DMA_Init DMA初始化 4.串口参数初始化 - USART_Init 5.开启串口中断 总结: 1.DMA接收不需要中断 2.DMA发送完毕触发的是DMA发送中断,DMA接收完成触发的是串口空闲中断,都会触发一个中断标志位,可以判断一下。 来源: oschina 链接:

pci_alloc_consistent uncached memory

半腔热情 提交于 2019-12-08 04:41:37
问题 Is it fair to say that pci_alloc_consistent allocates a contiguous non-cached, non-paged kernel memory chunk. The reason I'm asking is that I saw this comment in some kernel/driver code (not in vanilla kernel sources), and I think I understand that the memory is presented as contiguous, however not sure that it's allocated non-cached, because the idea of cache coherency is to maintain data in the cache and DMA memory consistent. Also, not sure why they call it non-paged. E.g. https://www

Why am I getting a high address when I use kmalloc with GFP_DMA in Linux?

二次信任 提交于 2019-12-07 15:37:40
问题 I am writing a device driver for a DMA device in Linux. In Linux Device Drivers, Chapter 15, it says: For devices with this kind of limitation, memory should be allocated from the DMA zone by adding the GFP_DMA flag to the kmalloc or get_free_pages call. When this flag is present, only memory that can be addressed with 24 bits is allocated. Alternatively, you can use the generic DMA layer (which we discuss shortly) to allocate buffers that work around your device’s limitations I am calling

Ring buffers and DMA

守給你的承諾、 提交于 2019-12-06 14:29:28
问题 I'm trying to understand everything that happens in between the time a packet reaches the NIC until the time the packet is received by the target application. Assumption: buffers are big enough to hold an entire packet. [I know it is not always the case, but I don't want to introduce too many technical details] One option is: 1. Packet reaches the NIC. 2. Interrupt is raised. 2. Packet is transferred from the NIC buffer to OS's memory by means of DMA. 3. Interrupt is raised and the OS copies

利用AXI-DMA批量发送数据到DMA

旧街凉风 提交于 2019-12-06 04:55:43
1.1 主函数 int main ( void ) { XGpio_Initialize(&Gpio, AXI_GPIO_DEV_ID); XGpio_SetDataDirection(&Gpio, 1, 0); init_intr_sys(); XGpio_DiscreteWrite(&Gpio, 1, 1); axi_dma_test(); } 1.2 三个简单函数 (1)、XGpio_Initialize(&Gpio, AXI_GPIO_DEV_ID); 本语句对GPIO进行初始化,对实例数据进行配置。 (2)、XGpio_SetDataDirection(&Gpio, 1, 0); 设置GPIO的方向,向通道1写0,0:输出,1:输入。 (3)、XGpio_DiscreteWrite(&Gpio, 1, 1); 设置GPIO的输出为1。 一、 init_intr_sys函数分析 1、DMA_Intr_Init(&AxiDma,0); DMA中断实例化函数,将要配置的DMA信息先lookupConfig再进行CfgInitialize,DMA采用块模式(Block mode),如果是Sg模式,则配置失败。 2、Timer_init(&Timer,TIMER_LOAD_VALUE,0); 定时器初始化函数,传入参数有定时器结构、加载值,设备ID