软件开发

  1. 首先,在硬件工程文件夹里面新建一个software的文件夹用于放置软件部分;打开toolsàNios II 11.0 Software Build Tools for Eclipse,需要进行Workspace Launcher(工作空间)路径的设置,需要注意的是路径中不要含有空格等,然后单击OK即可。

  1. 新建工程。单击File -> New -> Nios II Application and BSP from Template,弹出Nios II Application and BSP from Template对话框。先选择对应的SOPC系统,单击SOPC Information File name后面的浏览按钮,选择之前硬件部分做好的软核文件,后缀名为.sopcinfo,这里一定要注意,选择的文件一定要对应起来,否则会因为软硬不匹配导致系统失败。这里选择的lab6_seg.sopcinfo,然后系统会自动读取CPU name,不用再进行设置,下面填写Project name,这里填写为lab6_seg,工程模板(Project template)使用默认的即可。然后单击Finish完成即可。这时候会在左侧的Project Explorer中生成两个工程文件。

代码设计具体看源工程

  1. 右击工程,选择Nios II -> BSP Editor,进入Nios II BSP Editor配置界面。主要在main选项卡下hall中进行配置。然后单击Generate,生成BSP库。生成完成后,单击Exit退出即可。

  1. 编译工程。右击选择Build Project。第一次编译的话,时间也会比较常,耐心等待一下。
  2. 编译完成后,先将.sof文件下载到FPGA;
  1. 右击工程,选择Run As -> Nios II Hardware,弹出Run Configurations对话框,默认Project选项卡中Project name和Project ELF file name应该都是有内容的,没有的选一下。然后进入Target Connection选项卡,Connections中如果没有东西的话,单击右侧的Refresh Connection来查找下载器,查找后单击System ID Prroperties…,进行系统ID检测,检查是否是之前设置的ID号,无误后点击Apply,然后再点击Run,这是程序会被自动下载,最终在Nios II Console选项卡中会显示下载完成后程序运行的结果。

  1. 运行结果,板子上的数码管进行计数显示。

实验代码

/*

* "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 "system.h"

#include "altera_avalon_pio_regs.h"

#include "altera_avalon_timer_regs.h"

#include "alt_types.h"

#include "sys/alt_irq.h"

#include <stdio.h>

#include <unistd.h>

#include <io.h>

#include <string.h>

/********************************

Variables

********************************/

// 数码管显示字符对应的 16 进制数

]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,

0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};// 0-F

};

]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf};

;

/********************************

Functions

********************************/

void init_timer(void);

/*

*================================functions================================

Name: main

Description:

*=========================================================================

*/

int main(void)

{

;

];

;

init_timer();

){

sprintf(buf,"%06u",j++);

;i++){

-i]-'0';

}

);

}

;

}

void ISR_handle_timer(void*context)

{

IOWR_ALTERA_AVALON_PIO_DATA(SEG_WEI_BASE,0xff);

IOWR_ALTERA_AVALON_PIO_DATA(SEG_WEI_BASE, bittab[cnt]);

IOWR_ALTERA_AVALON_PIO_DATA(SEG_DUAN_BASE, segtab[led_buffer[cnt]]);//

cnt++;

)

;

IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE,0x00);// 清除中断标志寄存器

}

void init_timer(void)

{

IOWR_ALTERA_AVALON_TIMER_STATUS( TIMER_BASE,0x00);// 清除中断标志寄存器

);// 设置定时周期 1s

);

IOWR_ALTERA_AVALON_TIMER_CONTROL( TIMER_BASE,0x07);// 使能中断

alt_ic_isr_register( TIMER_IRQ_INTERRUPT_CONTROLLER_ID, TIMER_IRQ,

ISR_handle_timer,NULL,0x0);// 注册中断

}

每日推送不同科技解读,原创深耕解读当下科技,敬请关注微信公众号“科乎”。

最新文章

  1. MCMC 、抽样算法与软件实现
  2. jquery获取关于宽度和高度的尺寸问题
  3. Android开发学习之路-自定义ListView(继承BaseAdapter)
  4. 硅谷新闻1--引导界面GuideActivity
  5. Android开发-API指南-设备兼容性
  6. oracle函数和存储过程示例
  7. [置顶] 文件和目录(一)--unix环境高级编程
  8. 【SSH进阶之路】一步步重构容器实现Spring框架——彻底封装,实现简单灵活的Spring框架(十一)
  9. datatable1.9 与datatable1.10以数据差异
  10. php sql uuid 32位
  11. beta冲刺7
  12. css 溢出overflow
  13. 使用CI遇到的问题报错:Call to undefined function base_url()
  14. 瞅瞅!!免费看VIP视频的技巧
  15. 设置sqlplus不显示除查询结果外的信息
  16. Win10系列:JavaScript 模板绑定
  17. .NetCore中的程序通过Docker在CentOS中部署
  18. zoj 1649
  19. MySQL load数据的时候自动更新时间
  20. Codeforces Round #298 (Div. 2) D. Handshakes 构造

热门文章

  1. 九、Android学习第八天——广播机制与WIFI网络操作(转)
  2. Windows Azure文件共享服务--File Service
  3. linux下yum命令出现Loaded plugins: fastestmirror
  4. [书目20160526]Brain Rules 让大脑自由:释放天赋的12条定律
  5. NYOJ-取石子
  6. NOIP2000单词接龙[DFS]
  7. 第10章 同步设备I/O和异步设备I/O(3)_接收I/O请求完成通知的4种方法
  8. 第15章 设备无关位图_15.2 显示和打印DIB
  9. 渗透中Necat的另类用法
  10. poj1573 Robot Motion