时间标记服务(有问题).txt

来自「nios范例(含源代码)」· 文本 代码 · 共 28 行

TXT
28
字号
#include <stdio.h>
#include "system.h"
#include "alt_types.h"
#include "sys/alt_timestamp.h"    //时间标记服务头文件

void func1(void)
{
  int cnt=10000;
  while(cnt--);
}

int main()
{
  alt_u32 time1,time2;
  if(alt_timestamp_start()<0)//开启时间标记服务
    {
      printf("cant statr timestmp\n");
    }
    
  time1=alt_timestamp();
  func1();
  time2=alt_timestamp();
  printf("func1 need %u\n",(unsigned int)(time2-time1));
  //测系统的频率
  printf("the freq of timer is %u\n",(unsigned int)alt_timestamp_freq());
  return(0);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?