原创 Accessing EPCS from NIOS II

2009-1-19 15:19 2742 5 6 分类: MCU/ 嵌入式
If you are wondering how to access the EPCS from the NIOS II directly, you have come to the right place. I believe you might have tried to read the NIOS II handbook that covers almost 600 pages to find out the answer. Nevertheless, it seems like there is no straight answer to the question in the NIOS II handbook. You might have even tried to look into the?Software Files?mentioned in the chapter named?EPCS Device Controller Core with Avalon Interface, which are?altera_avalon_epcs_controller_flash.c,altera_avalon_epcs_controller_flash.h,?epcs_commands.c?andepcs_commands.h. However, still, none of these files give you much clue how to access the EPCS from the NIOS II processor.
NIOSII_Integrate_EPCS.0.jpg
In fact, the handler that gives you the access to the EPCS device is notalt_flash_epcs_dev?(as you see inaltera_avalon_epcs_controller_flash.h), but?alt_flash_fd, which is the exact same handler that you use to access the common flash device like Spansion and Intel flash device. To my surprise, the NIOS II handbook does not mention about this. Perhaps this is a common sense to everybody else that the Spansion/Intel flash and the SPI Serial Flash should have a same handler, but NOT to a dummy user like me! After asking around, I believe I am not the only one who thinks like this! Therefore, I still see that there is some room for improvement in the next version of NIOS II handbook. Not every NIOS II user is a hardware designer. Not every NIOS II user is a software developer, either. Some NIOS II users like me have to do co-hardware/software design and development at the same time. Sometimes I just feel that the handbook couldn’t link me very well between?the hardware and software. For an example, my earlier frustration could have been resolved if there is a small piece of C code like the following included in the Chapter 3 of the Quartus II Handbook Volume 5 (a.k.a. NIOS II Handbook Volume 3).

////////////////////////////////////////////
// hello_epcs.cpp
// date created: March 30, 2006
// author:?
http://fpgaforum.blogspot.com
////////////////////////////////////////////
#include?<iostream>
#include?"system.h"
#include?"sys/alt_flash.h"
#include?"sys/alt_flash_dev.h"
using namespace?std;

int?main()
{
?? ?alt_flash_fd* my_epcs;
?? ?char?my_data[256];

//check your (EPCS_CONTROLLER_NAME) from system.h
my_epcs = alt_flash_open_dev(EPCS_CONTROLLER_NAME);

if(my_epcs)
{
?? ?cout << "EPCS opened successfully!" << endl;

??//example application, read general data from epcs address 0x70000
int ?ret_code = alt_read_flash(my_epcs, 0x70000, my_data, 256);
if(!ret_code)
{
?? ? ? cout << my_data << endl;
?? ? ?return ?0;
}
else
?? ? ?return?-1;
}
else
{
?? ?cout << "Error! EPCS not opened!" << endl;
?? ?return?-2;
}
}
// The end
/////////////////////////////////////////////////////////

Anyway, I just found out that if you are lucky, you might still be able to find out the code very similar like above from the software example calledmemtest.c?in the?&ltNIOS II Path>\examples\software\memtest?folder. By the way, you can only view the code after installing the NIOS II software tool.




PARTNER CONTENT

文章评论1条评论)

登录后参与讨论

用户240125 2010-1-29 00:33

请问,问什么经过 my_epcs = alt_flash_open_dev(EPCS_CONTROLLER_NAME); 我读出来的my_epcs是0 请楼主多多指教
相关推荐阅读
用户1109524 2009-06-12 14:53
cy7c68013 usb 开发经验(转)
经验1:快速获取资料如果直接从 http://www.cypress.com/  网站进入搜索资料则速度很慢,如果点击如下连接则速度比较快。CY7C68013A 资源下载地址:http://app.c...
用户1109524 2009-05-22 09:23
一个比较重要的驱动函数的讲解(74HC595)
一个比较重要的驱动函数的讲解(74HC595)概述     74HC595是美国国家半导体公司生产的通用移位寄存器芯片。并行输出端具有输出锁存功能。与单片机连接简单方便,只须三个I/O口即可。而且通过...
用户1109524 2009-05-22 08:44
嵌入式程序员应知道的几个基本问题
嵌入式程序员应知道的几个基本问题    预处理器(Preprocessor)   1 . 用预处理指令#define 声明一个常数,用以表明1年中有多少秒(忽略闰年问题)      #define S...
用户1109524 2009-05-20 11:33
Windows CE OAL层的结构与开发
Windows CE OAL层的结构与开发 收藏  Windows CE是微软针对嵌入式领域推出的一款全新的操作系统。之所以说它是一款全新的操作系统,是因为尽管Windows CE的UI非常接近其它的...
用户1109524 2009-05-20 10:39
wince驱动开发学习笔记
因为课题前期调研没做好,用的CPU板卡和数据采集卡来自两个部门。加上买的是裸板,自己定制的OS,技术支持不爱搭理。所以给的AI板卡的驱动一直装不上,自己在郁闷中寻找答案,就扎进了wince驱动的知识库...
用户1109524 2009-05-20 10:32
Windows CE 下I/O操作基础
对外设进行 I/O 操作实际上也就是读写外设的寄存器,而我们通常使用的X86或者ARM处理器在硬件上决定了wince系统启动后,无法直接访问物理地址,因此需要做一些工作来实现I/O操作.<?xm...
EE直播间
更多
我要评论
1
5
关闭 站长推荐上一条 /3 下一条