阅读DMA Controller Core 官方手册

DMA控制器框架图

怎样去设定一个DMA控制器

实例化DMA控制器

参数配置界面如下图所示:

对于width of the DMA length register的配置尝试如下:

正如官方文档中描述的那样:

DMA Length register的位宽决定了DMA Length的最大值,决定了可以用这个DMA控制器传递数据的个数。

DMA的工作模式:

搭建一个系统:

数据从ROM里面,经过DMA控制器传送到RAM里面,软件程序单独在RAM_Pro内存空间里面运行。

注意:片上ROM与片上RAM可以不与Nios II 处理器相连,这样会导致处理器监控不到ROM和RAM里面的数据,在Eclipse里面的debug界面中没法查找到相应的内存空间,但是连上处理器之后,可以查询得到,建议连上

顶层例化:

 DMA控制器软件程序的编写:

需要根据用户手册来指导编写:

在Eclipse中编写代码如下:

/*
* "Hello World" example.
*
* This example prints 'Hello from Nios II' to the STDOUT stream. It runs on
* the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example
* designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT
* device in your system's hardware.
* The memory footprint of this hosted application is ~69 kbytes by default
* using the standard reference design.
*
* For a reduced footprint version of this template, and an explanation of how
* to reduce the memory footprint for a given application, see the
* "small_hello_world" template.
*
*/ #include <stdio.h>
#include <stdlib.h>
#include "sys/alt_dma.h"
#include "system.h"
static volatile int rx_done = ;
static void done(void* handle, void* data)
{
rx_done++;
} int main(int argc, char* argv[], char* envp[])
{
int rc;
alt_dma_txchan txchan;
alt_dma_rxchan rxchan;
void* tx_data = (void*) 0x2000;
void* rx_data = (void*) 0x1000;
if((txchan = alt_dma_txchan_open("/dev/dma")) == NULL)
{
printf ("Failed to open transmit channel\n");
exit();
} if((rxchan = alt_dma_rxchan_open("/dev/dma")) == NULL)
{
printf ("Failed to open receive channel\n");
exit();
} if((rc = alt_dma_txchan_send(txchan,tx_data,,NULL,NULL)) < )
{
printf ("Failed to post transmit request,reason = %i\n",rc);
exit();
} if ((rc = alt_dma_rxchan_prepare(rxchan,rx_data,,NULL,NULL)) < )
{
printf ("Failed to post read request,reason = %i\n",rc);
exit();
} while(!rx_done)
{
printf ("Transfer successful!\n");
}
printf ("Hello from Nios II!\n");
return ;
}

由于数据存储在片上的ROM和RAM中,因此可以用In-System Memory Content Editor来进行查看:

首先给ROM初始化数据文件和Instance ID:

 然后,同样需要给RAM分配Instance ID:

最后在In-System Memory Content Editor里面进行查看:

经过核对:数据传输无误。

阅读DMA Controller Core 官方手册的更多相关文章

  1. grub2详解(翻译和整理官方手册)

    翻译了grub2官方手册的绝大部分内容,然后自己整理了一下.因为内容有点杂,所以章节安排上可能不是太合理,敬请谅解. 本文目录: 1.1 基础内容 1.2 安装grub2 1.3 grub2配置文件 ...

  2. 翻译:CREATE FUNCTION语句(已提交到MariaDB官方手册)

    本文为mariadb官方手册:CREATE FUNCTION的译文. 原文:https://mariadb.com/kb/en/library/create-function/我提交到MariaDB官 ...

  3. Core官方DI剖析(1)--ServiceProvider类和ServiceCollection类

    前段时间看了蒋老师的Core文章,对于DI那一块感觉挺有意思,然后就看了一下Core官方DI的源码,这也算是第一个看得懂大部分源码的框架,虽然官方DI相对来说特别简单, 官方DI相对于其它框架(例如 ...

  4. MariaDB官方手册翻译

    MariaDB官方手册 翻译:create database语句(已提交到MariaDB官方手册) 翻译:rename table语句(已提交到MariaDB官方手册) 翻译:alter table语 ...

  5. 翻译:SET PASSWORD语句(已提交到MariaDB官方手册)

    本文为mariadb官方手册:SET PASSWORD的译文. 原文:https://mariadb.com/kb/en/library/set-password/我提交到MariaDB官方手册的译文 ...

  6. XtraDB/InnoDB的文件格式(已提交到MariaDB官方手册)

    本文为mariadb官方手册:XtraDB/InnoDB File Format的译文. 原文:https://mariadb.com/kb/en/library/xtradbinnodb-file- ...

  7. 翻译:SET Variable(已提交到MariaDB官方手册)

    本文为mariadb官方手册:SET Variable的译文. 原文:https://mariadb.com/kb/en/set-variable/我提交到MariaDB官方手册的译文:https:/ ...

  8. 翻译:赋值操作符(:=)(已提交到MariaDB官方手册)

    本文为mariadb官方手册:赋值操作符(:=)的译文. 原文:https://mariadb.com/kb/en/assignment-operator/ 我提交到MariaDB官方手册的译文:ht ...

  9. 翻译:last_value()函数(已提交到MariaDB官方手册)

    本文为mariadb官方手册:LAST_VALUE()的译文. 原文:https://mariadb.com/kb/en/last_value/我提交到MariaDB官方手册的译文:https://m ...

随机推荐

  1. Spring Relational Database

    为了避免持久化的逻辑分散到应用的各个组件中,将数据访问功能放到一个或多个专注于此项任务的组件中,这样的组件通常称为数据访问对象(DAO)或Repository. 为了避免应用与特定的数据访问策略耦合在 ...

  2. socket 映射服务器程序

    server #include <stdio.h> #include <sys/types.h> /* See NOTES */ #include <sys/socket ...

  3. Spring Boot 揭秘与实战(四) 配置文件篇 - 有哪些很棒的特性

    文章目录 1. 使用属性文件2. YAML文件 1.1. 自定义属性 1.2. 参数引用 1.3. 随机数属性 1.4. application-{profile}.properties参数加载 3. ...

  4. C# process 隐藏应用程序的进度条

    命令行参数那加上-ibck指定后台运行. string sourceFilepath = "d:\\测试.rar"; string targetFilepath = "d ...

  5. 2.15 富文本(richtext)

    2.15 富文本(richtext) 前言     富文本编辑框是做web自动化最常见的场景,有很多小伙伴不知从何下手,本篇以博客园的编辑器为例,解决如何定位富文本,输入文本内容一.加载配置    1 ...

  6. Python之路PythonNet,第三篇,网络3

    pythonnet   网络3 udp 通信 recvfrom sendtofork 多进程并发threading 多线程并发socketserver 系统模块 套接字的属性 setsockopt g ...

  7. The NMEA 0183 Protocol

    The NMEA 0183 Protocol NMEA0183 协议是由美国国家海洋电子协会开发.维护并发布的标准,用于航海远洋时使用的电子仪器之间的通信. 目前大部分的 GPS 接受设备都遵循这一标 ...

  8. python函数完整语法和分类

    函数初级 简介 # 函数是一系列代码的集合,用来完成某项特定的功能 优点 '''1. 避免代码的冗余2. 让程序代码结构更加清晰3. 让代码具有复用性,便于维护''' 函数四部分 '''1. 函数名: ...

  9. python------模块定义、导入、优化 ------->Yaml, l模块

    一. yaml模块 用来做配置文件. 需要pip安装该包. 二. ConfigParser模块 用来生成和修改常见配置文件,在python3.x版本中更名为configparser. (什么是配置文件 ...

  10. HashMap<Integer, Bean> 根据Bean的属性进行排序

    转载地址 已知一个HashMap<Integer,User>集合, User有name(String)和age(int)属性.请写一个方法实现对HashMap的排序功能,该方法接收Hash ...