nios ii小实验——timer

简介: nios ii小实验——timer

timer是软核里的计时器。

1.添加nios ii系统

加入nios ii processor, ram, jtag, timer,,注意连线。图例中pio,spi都不用添加。

cdedac66b326403cd679613448e4fa45_SouthEast.png

2.实例化qsys
module work(
  CLOCK_50
  ,KEY
  );
input CLOCK_50;
input [3:0] KEY;
wire clk, rst;
assign clk = CLOCK_50;
assign rst = KEY[3];
nios_II u0 (
        .clk_clk        (clk),
        .reset_reset_n  (rst)
    );   
endmodule


3.Eclipse

可见 http://blog.csdn.net/moon9999/article/details/69938526

在软核中写入如下代码

#include <stdio.h>
#include "stdlib.h"
#include "system.h"
#include "sys/alt_timestamp.h"
#include "alt_types.h"
void func1(void)
{
    int cnt=1000;
    while(cnt--);
}
void func2(void)
{
    int cnt=2000;
    while(cnt--);
}
int main()
{
  printf("step 1 is ok\n");
  alt_timestamp_start();
  alt_u32 time1, time2,time3;
  time1=alt_timestamp();
  printf("time is %ld\n",time1);
  func1();
  time2=alt_timestamp();
  printf("time is %ld\n",time2);
  func2();
  time3=alt_timestamp();
  printf("time is %ld\n",time3);
  printf("系统时钟频率是 %ld Hz\n", alt_timestamp_freq());
  return 0;
}

函数的作用:

alt_timestamp_start():开启计时器

alt_timestamp():戳取时间点

alt_timestamp_freq():获取系统频率

注意修改bsp

4ce2bdc4d53cc20e8c4cf66513f14818_SouthEast.png

4.运行程序

运行结果如下

567e224d7d0759d387cdeecb3f05ea33_SouthEast.png






相关文章
|
Android开发 异构计算
nios ii FIFO读取FPGA数据交互实验1
nios ii FIFO读取FPGA数据交互实验1
243 0
nios ii FIFO读取FPGA数据交互实验1
|
Android开发 C++ 芯片
nios ii小实验——第一个demo指导书
nios ii小实验——第一个demo指导书
166 0
nios ii小实验——第一个demo指导书
|
异构计算
nios ii小实验——SDRAM读写
nios ii小实验——SDRAM读写
214 0
nios ii小实验——SDRAM读写
|
2月前
STM32Cubmx FreeRTOS Timer
STM32Cubmx FreeRTOS Timer
39 10
|
2月前
STM32Cubemx FreeRTOS Event
STM32Cubemx FreeRTOS Event
32 11
|
2月前
stm32f407探索者开发板(二十三)——定时器中断实验
stm32f407探索者开发板(二十三)——定时器中断实验
|
11月前
|
调度 开发者
【Freertos基础入门】2个Freertos的Delay函数
【Freertos基础入门】2个Freertos的Delay函数
576 1
|
12月前
|
数据可视化 Linux 调度
译 | Linux perf_events Off-CPU Time Flame Graph
译 | Linux perf_events Off-CPU Time Flame Graph
89 0
|
Linux
Linux perf 火焰图
Linux perf 火焰图
230 0
|
IDE 编译器 开发工具
【NXP】LPC55S69-RT-Thread Micropython移植日志
【NXP】LPC55S69-RT-Thread Micropython移植日志
163 0