UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor imran1
Visitor
7,845 Views
Registered: ‎07-24-2013

Second Timer with Xilkernel

Jump to solution

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
*/
XTmrCtr_SetOptions((&myTimer, TmrCtrNumber,
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
*/
XTmrCtr_Start((&myTimer, TmrCtrNumber);

// Interrupt Handling
register_int_handler( XPAR_XPS_INTC_0_PROFILE_TIMER_INTERRUPT_INTR, my_interrupt_handler, (void *) 0xC3000000);

enable_interrupt(XPAR_XPS_INTC_0_PROFILE_TIMER_INTERRUPT_INTR);

 

//******************************************

 

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.

 

Thanks.

0 Kudos
1 Solution

Accepted Solutions
Visitor imran1
Visitor
14,217 Views
Registered: ‎07-24-2013

Re: Second Timer with Xilkernel

Jump to solution

Figured out the problem. I had not connected the driver to the second timer in the kil kenrel BSP.

0 Kudos
3 Replies
Xilinx Employee
Xilinx Employee
7,818 Views
Registered: ‎08-02-2007

Re: Second Timer with Xilkernel

Jump to solution

hi,

 

TmcCtrNumber is based off XTC_DEVICE_TIMER_COUNT.  This is defined in xtmrctr_l.h

 

--hem

 

 

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Visitor imran1
Visitor
7,801 Views
Registered: ‎07-24-2013

Re: Second Timer with Xilkernel

Jump to solution

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.

0 Kudos
Visitor imran1
Visitor
14,218 Views
Registered: ‎07-24-2013

Re: Second Timer with Xilkernel

Jump to solution

Figured out the problem. I had not connected the driver to the second timer in the kil kenrel BSP.

0 Kudos