Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 如何在NIOSII中使用定时器中断_C_Timer_Interrupt_Nios - Fatal编程技术网

C 如何在NIOSII中使用定时器中断

C 如何在NIOSII中使用定时器中断,c,timer,interrupt,nios,C,Timer,Interrupt,Nios,在我的项目中,我在Quartus的Qsys设计中使用了一个简单的周期性中断。下面我需要做一个计数器,可以从用户定义的值(以秒为单位)计数,但我不确定如何开始编写代码。我已经在线阅读了Atera手册,了解如何开始,但我仍然有点困惑。以下是我到目前为止的情况 //***************************************************************************** //****************************************

在我的项目中,我在Quartus的Qsys设计中使用了一个简单的周期性中断。下面我需要做一个计数器,可以从用户定义的值(以秒为单位)计数,但我不确定如何开始编写代码。我已经在线阅读了Atera手册,了解如何开始,但我仍然有点困惑。以下是我到目前为止的情况

//*****************************************************************************
//*****************************************************************************
#include "nios_std_types.h"
#include "system.h"
#include <stdio.h>
#include "sys/alt_stdio.h"

//*****************************************************************************
//                  Define symbolic constants
//*****************************************************************************
// define the PIO register offsets
#define TIMER_START_OFFSET 2
#define TIMER_CNTRL_MASK //Not sure what to write yet.


//*****************************************************************************
//                            Define private data
//*****************************************************************************
uint32 *timer_ptr = (uint32 *)TIMER_0_BASE;




//*****************************************************************************
//                             private functions
//*****************************************************************************

void Timer_StartTimer();
void Timer_StopTimer();
void Timer_SetTimeLimit();
//*****************************************************************************
//*****************************************************************************
#包括“nios_标准_类型.h”
#包括“system.h”
#包括
#包括“sys/alt\u stdio.h”
//*****************************************************************************
//定义符号常量
//*****************************************************************************
//定义PIO寄存器偏移量
#定义计时器\u开始\u偏移量2
#定义计时器\u CNTRL\u掩码//还不确定要写什么。
//*****************************************************************************
//定义私有数据
//*****************************************************************************
uint32*计时器\u ptr=(uint32*)计时器\u 0\u基数;
//*****************************************************************************
//私人职能
//*****************************************************************************
void Timer_StartTimer();
void Timer_StopTimer();
无效计时器_SetTimeLimit();
  • 在项目BSP(板支持文件)中配置时间戳计时器
  • 生成BSP(右键单击项目并生成)
  • 按以下方式注册ISR

     retVal = alt_ic_isr_register(HIGH_RES_TIMER_IRQ_INTERRUPT_CONTROLLER_ID,
                              HIGH_RES_TIMER_IRQ,
                              handle_timer_interrupts,
                              timer_ptr, 0x0);
    
  • 然后它应该工作,同样的必须出现在一个文件中