微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > 为什么我的时钟ISR没的响应?

为什么我的时钟ISR没的响应?

时间:10-02 整理:3721RD 点击:
下面是我的程序,用xilinx edk 编写的,主要想法是通过调用一个中断,来输出一个方波,可是不知原因的,却没有调用中断过程。
我把我的TestApp_Memory\source.c文件拷了过来,请高手帮我看看。

#include "xparameters.h"
#include "xcache_l.h"
#include "stdio.h"
#include "xutil.h"
#include "xgpio_l.h"
#include "xtmrctr.h"
#include "xintc.h"
#include "xexception_l.h"
//====================================================
/*********************constants*******************/
#define LED_DELAY3000
#define LED_CHANNEL1
#define PPCGPIOGeneric_GPIO
#define GPIO_REG_BASEADDR0x40000000
#define LED0x28 /* Assumes bit 0 of GPIO is connected to an LED */

#define TMRCTR_DEVICE_IDXPAR_OPB_INTC_0_DEVICE_ID
#define INTC_DEVICE_IDXPAR_OPB_INTC_0_DEVICE_ID
#define TMRCTR_INTERRUPT_IDXPAR_OPB_INTC_0_OPB_TIMER_0_INTERRUPT_INTR
#define RESET_VALUE0xFFFFF000
#define TIMER_COUNTER_00
volatile int TimerExpired;
XIntcInterruptController;
XTmrCtr TimerCounter;

//void XTmrCtr_InterruptHandler(void *CallBackRef, Xuint8 TmrCtrNumber);
void TimerCounterHandler(void *CallBackRef, Xuint8 TmrCtrNumber);
//void TimerCounterHandler(void *CallBackRef);
/****************************************************/
int main (void)
{
XStatus Status;
volatile int Delay;
inti=0;

//XTmrCtr *InstancePtr = (XTmrCtr *)CallBackRef;
XCache_EnableICache(0x80000001);
XCache_EnableDCache(0x80000001);
print("-- Exiting testmemory main() --\r\n");
XGpio_mSetDataDirection(GPIO_REG_BASEADDR, LED_CHANNEL, 0X0);

// initialize the timer
Status = XTmrCtr_Initialize(&TimerCounter, TMRCTR_DEVICE_ID);
if (Status != XST_SUCCESS)
{print("XTmrCtr_Initialize failure\r\n");
return XST_FAILURE;
}
print("XTmrCtr_Initialize successed\r\n");

// selftest
Status = XTmrCtr_SelfTest(&TimerCounter,TIMER_COUNTER_0);
if (Status != XST_SUCCESS)
{print("XTmrCtr_SelfTest failure\r\n");
return XST_FAILURE;
}
print("XTmrCtr_SelfTest successed\r\n");

// initialize the Intc
Status = XIntc_Initialize(&InterruptController, INTC_DEVICE_ID);
if (Status != XST_SUCCESS)
{
print("XIntc_Initialize failure\r\n");
return XST_FAILURE;
}
print("XIntc_Initialize successed\r\n");

//connect the Intr
//Status = XIntc_Connect(&InterruptController, TMRCTR_INTERRUPT_ID,
//(XInterruptHandler)XTmrCtr_InterruptHandler,
//(void *)&TimerCounter);
Status = XIntc_Connect(&InterruptController, TMRCTR_INTERRUPT_ID,
(XInterruptHandler)TimerCounterHandler,
(void *)&TimerCounter);
if (Status != XST_SUCCESS)
{
print("XIntc_Connect failure\r\n");
return XST_FAILURE;
}
print("XIntc_Connect successed\r\n");

// start the Intc
Status = XIntc_Start(&InterruptController, XIN_REAL_MODE);
if (Status != XST_SUCCESS)
{
print("XIntc_Start failure\r\n");
return XST_FAILURE;
}
print("XIntc_Start successed\r\n");

// enable the intc
XIntc_Enable(&InterruptController, INTC_DEVICE_ID);
print("XIntc_Enable successed\r\n");

//Initialize the PPC405 exception table
XExc_Init();
// Register the interrupt controller handler with the exception table
XExc_RegisterHandler(XEXC_ID_NON_CRITICAL_INT,
(XExceptionHandler)XIntc_InterruptHandler,
&InterruptController);
// Enable non-critical exceptions
XExc_mEnableExceptions(XEXC_NON_CRITICAL);
print("XExc routine success\r\n");

//set the handler
XTmrCtr_SetHandler(&TimerCounter, TimerCounterHandler,
&TimerCounter);
// set options
XTmrCtr_SetOptions(&TimerCounter, TIMER_COUNTER_0,
XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION);
//set reset value
XTmrCtr_SetResetValue(&TimerCounter, TIMER_COUNTER_0, RESET_VALUE);
//start the timer
XTmrCtr_Start(&TimerCounter, TIMER_COUNTER_0);
//TimerExpired=XTmrCtr_GetValue(&TimerCounter, TIMER_COUNTER_0);

while(1);


return 0;
}
void TimerCounterHandler(void *CallBackRef, Xuint8 TmrCtrNumber)
//void XTmrCtr_InterruptHandler(void *CallBackRef, Xuint8 TmrCtrNumber)
//void TimerCounterHandler(void *CallBackRef)
{
int Delay;
XGpio_mSetDataReg(GPIO_REG_BASEADDR, LED_CHANNEL, 0x0);
for (Delay = 0; Delay < 300; Delay++);
XGpio_mSetDataReg(GPIO_REG_BASEADDR, LED_CHANNEL, 0x3);
for (Delay = 0; Delay <300; Delay++);
}

路过
^_^

复杂,初学,搞不定。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top