05-06-2015 02:14 PM
I have instantiated a second xps timer and hooked its interrupt output to the interrupt controller. I would like to use this timer for profiling and a better understanding on how to respond to interrupts generated by custom IP.
When I look in the xparameters.h file I do not see the ID of this timer. The only timer with ID is the system timer.
I am trying to initialize the timer and the interrupt using the following code.
// Timer Setup
static XTmrCtr myTimer;
* Initialize the timer counter so that it's ready to use,
* specify the device ID that is generated in xparameters.h
Status = XTmrCtr_Initialize(&myTimer, DeviceId);
* Enable the interrupt of the timer counter so interrupts will occur
* and use auto reload mode such that the timer counter will reload
* itself automatically and continue repeatedly, without this option
* it would expire once only
XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION);
* Set a reset value for the timer counter such that it will expire
* eariler than letting it roll over from 0, the reset value is loaded
* into the timer counter when it is started
XTmrCtr_SetResetValue((&myTimer, TmrCtrNumber, RESET_VALUE);
* Start the timer counter such that it's incrementing by default,
* then wait for it to timeout a number of times
// Interrupt Handling
register_int_handler( XPAR_XPS_INTC_0_PROFILE_TIMER_INTERRUPT_INTR, my_interrupt_handler, (void *) 0xC3000000);
The problem is that I do not know how to get the ID of the second timer from xparameters.h as it does not exist there.
Also how do I get the TmrCtrNumber?
Is my code correct?
Would appreciate an example of instantiating a second counter with xilkernel.
05-07-2015 02:08 AM
TmcCtrNumber is based off XTC_DEVICE_TIMER_COUNT. This is defined in xtmrctr_l.h
05-07-2015 06:43 AM
Thank you. That takes care of TmcCtrNumber. I got it from the header file and used it the following way
u8 TmrCtrNumber = XTC_DEVICE_TIMER_COUNT - 1;
Not knowing the DeviceID as I used
u16 DeviceId = 1; // just a hack
Please advise is this is the right way as I do not see the ID of the second timer in xparameters.h file.
I used the reset value of
#define RESET_VALUE 100000
for a counter being drivern by 125 MHz clock.
After compiling with these edits the xilkernel was hung and I did not see the call back function being called either.