0

在我的项目中,我在 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();
4

1 回答 1

1
  1. 在项目 BSP(板支持文件)中配置时间戳计时器
  2. 生成BSP(右键项目并生成)
  3. 注册ISR如下

     retVal = alt_ic_isr_register(HIGH_RES_TIMER_IRQ_INTERRUPT_CONTROLLER_ID,
                              HIGH_RES_TIMER_IRQ,
                              handle_timer_interrupts,
                              timer_ptr, 0x0);
    

那么它应该可以工作,同样必须存在于文档 http://www.altera.com/support/ip/processors/nios2/ips-nios2_support.html之一

于 2014-07-22T10:45:14.257 回答