Hi all,
I want to implement a FIT(fixed interval timer). I created one using XPS and connected the interrupt to the PS. I also implemented a timer/counter and connected that interrupt to the PS.
When writing code in the SDK, I can receive the interrupts from the timer/counter. But not from the FIT.
When looking in the FIT documentation I found the following for zynq implementation "Supported in ISE Design Suite implementations only". Does this mean it can't be done? Although connecting the FIT interrupt to the PS seems fine.
My SDK code looks like this:
/*
* Pl_timer_intr_test.c
*
* Created on: 2012-6-8
* Author: yzhang
*/
#include <stdio.h>
#include "platform.h"
#include "xil_types.h"
#include "xtmrctr.h"
#include "xparameters.h"
#include "xil_io.h"
#include "xil_exception.h"
#include "xscugic.h"
XScuGic InterruptController; /* Instance of the Interrupt Controller */
static XScuGic_Config *GicConfig;/* The configuration parameters of the
controller */
volatile u32 interruptCount = 0;
//void print(char *str);
extern char inbyte(void);
void Timer_InterruptHandler(void *data, u8 TmrCtrNumber) {
txil_printf(" Interrupt %d acknowledged
r ", interruptCount);
txil_printf("r
");
txil_printf("r
");
tXTmrCtr_Stop(data, TmrCtrNumber);
tXTmrCtr_Reset(data, TmrCtrNumber);
tXTmrCtr_Start(data, TmrCtrNumber);
t++interruptCount;
}
void fit250ms_InterruptHandler(void *data) {
txil_printf(" Interrupt fit250ms acknowledged
r ");
txil_printf("r
");
txil_printf("r
");
}
int SetUpInterruptSystem(XScuGic *XScuGicInstancePtr) {
t/*
t * Connect the interrupt controller interrupt handler to the hardware
t * interrupt handling logic in the ARM processor.
t */
tXil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
ttt(Xil_ExceptionHandler) XScuGic_InterruptHandler, XScuGicInstancePtr);
t/*
t * Enable interrupts in the ARM
t */
tXil_ExceptionEnable();
treturn XST_SUCCESS;
}
int ScuGicInterrupt_Init(u16 DeviceId, XTmrCtr *TimerInstancePtr) {
tint Status;
t/*
t * Initialize the interrupt controller driver so that it is ready to
t * use.
t * */
tGicConfig = XScuGic_LookupConfig(DeviceId);
tif (NULL == GicConfig) {
ttreturn XST_FAILURE;
t}
tStatus = XScuGic_CfgInitialize(&InterruptController, GicConfig,
tttGicConfig->CpuBaseAddress);
tif (Status != XST_SUCCESS) {
ttreturn XST_FAILURE;
t}
t/*
t * Setup the Interrupt System
t * */
tStatus = SetUpInterruptSystem(&InterruptController);
tif (Status != XST_SUCCESS) {
ttreturn XST_FAILURE;
t}
t/*
t * Connect a device driver handler that will be called when an
t * interrupt for the device occurs, the device driver handler performs
t * the specific interrupt processing for the device
t */
tStatus = XScuGic_Connect(&InterruptController,
tttXPAR_FABRIC_AXI_TIMER_0_INTERRUPT_INTR,
ttt(Xil_ExceptionHandler) XTmrCtr_InterruptHandler,
ttt(void *) TimerInstancePtr);
tif (Status != XST_SUCCESS) {
ttreturn XST_FAILURE;
t}
ttStatus = XScuGic_Connect(&InterruptController,
ttttXPAR_FABRIC_FIT_TIMER_250MS_INTERRUPT_INTR,
tttt(Xil_ExceptionHandler) fit250ms_InterruptHandler,
tttt(void *) NULL);
ttif (Status != XST_SUCCESS) {
tttreturn XST_FAILURE;
tt}
t/*
t * Enable the interrupt for the device and then cause (simulate) an
t * interrupt so the handlers will be called
t */
ttXScuGic_Enable(&InterruptController, XPAR_FABRIC_AXI_TIMER_0_INTERRUPT_INTR);
ttXScuGic_Enable(&InterruptController, XPAR_FABRIC_FIT_TIMER_250MS_INTERRUPT_INTR);
treturn XST_SUCCESS;
}
int main() {
tXTmrCtr TimerInstancePtr;
tint xStatus;
tinit_platform();
txil_printf("##### Application Starts #####
r");
txil_printf("r
");
txStatus = XTmrCtr_Initialize(&TimerInstancePtr, XPAR_AXI_TIMER_0_DEVICE_ID);
tif (XST_SUCCESS != xStatus)
ttxil_printf("TIMER INIT FAILED
r");
t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
t//Set Timer Handler
t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tXTmrCtr_SetHandler(&TimerInstancePtr, Timer_InterruptHandler,
ttt&TimerInstancePtr);
t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
t//Setting timer Reset Value
t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tXTmrCtr_SetResetValue(&TimerInstancePtr, 0, //Change with generic value
ttt0xf8000000);
t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
t//Setting timer Option (Interrupt Mode And Auto Reload )
t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tXTmrCtr_SetOptions(&TimerInstancePtr, XPAR_AXI_TIMER_0_DEVICE_ID,
ttt(XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION));
t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
t//SCUGIC interrupt controller Intialization
t//Registration of the Timer ISR
t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
txStatus = ScuGicInterrupt_Init(XPAR_PS7_SCUGIC_0_DEVICE_ID,
ttt&TimerInstancePtr);
tif (XST_SUCCESS != xStatus)
ttxil_printf(" :( SCUGIC INIT FAILED
r");
t//Start Timer
tXTmrCtr_Start(&TimerInstancePtr, 0);
txil_printf("timer start
r");
t//Wait For interrupt;
txil_printf("Wait for the Timer interrupt to tigger r
");
txil_printf("########################################r
");
txil_printf(" r
");
twhile (1) {
tt/*if(interruptCount > 20){
tttbreak;
tt}*/
t}
tcleanup_platform();
treturn 0;
}