阅读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. 用Synoptic Panel自定义基于图形的可视化控件--制作一张剧场售票统计报表

    数据可视化的一大特点就是能给报表使用者带来感官上的享受.不再是枯燥的数字,而变成一个一个亮丽的图形.之前业界大神公布过一个统计Car Accidents的报表,这个Power BI Report的特点 ...

  2. PHP中PSR-[0-4]规范(转)

    PHP中PSR-[0-4]规范 更好排版:https://www.zybuluo.com/phper/note/65033 PHP是世界上最伟大的语言,这一点是毋庸置疑的吧.哈哈哈哈哈哈 .这个霸气的 ...

  3. 【图像基础】图像不变性特征HU矩和Zernike矩

    参考 1. 图像不变性特征: 2. matlab实现: 3. HU矩和Zernike矩: 完

  4. Linux按照时间顺序列出文件

    按照递增时间顺序列出所有文件 ls -ltr -l表示列出长串数据,-t表示按照时间顺序,-r表示将排序的结果反向输出 按照时间递减的顺序列出所有文件 ls -lt

  5. [LeetCode&Python] Problem 543. Diameter of Binary Tree

    Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a b ...

  6. 关于js的面相对象

    http://www.ruanyifeng.com/blog/2010/05/object-oriented_javascript_encapsulation.html

  7. 51Nod 1135:元根(数论)

    1135 原根  基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题  收藏  关注 设m是正整数,a是整数,若a模m的阶等于φ(m),则称a为模m的一个原根.(其中φ(m) ...

  8. POJ 2456: Aggressive cows(二分,贪心)

    Aggressive cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20485   Accepted: 9719 ...

  9. 矩阵快速幂(以HDU1757为例)

    对于数据量大的求余运算,在有递推式的情况下,可以构造矩阵求解. A - A Simple Math Problem Lele now is thinking about a simple functi ...

  10. java-常见修饰符汇总

    1.修饰符: - 权限修饰符:private,默认的,protected,public - 状态修饰符:static,final - 抽象修饰符:abstract 2.类: - 权限修饰符:默认修饰符 ...