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: 
Highlighted
Visitor simon.b
Visitor
2,712 Views
Registered: ‎05-16-2008

Problem with timer CaptureTrig or Capture mode

Hello

 

I'm working on a project on my Spartan3E starter kit, using MicroBlaze.

 

I'm trying got get a timer working in capture mode, but without luck yet. I have a PWM signal input (2nd from the top on the J2 port, LOC B6), which I want my timer to trig on (low-true), and I want to measure the time between 2 falling edges.

 

Here is the info I think is relevant but please ask for more if you need it:

 

.UCF:

Net timer_CaptureTrig0_pin LOC=B6 | IOSTANDARD = LVCMOS33;

 

.MHS:

PORT timer_CaptureTrig0_pin = timer_CaptureTrig0, DIR = I

BEGIN xps_timer

PARAMETER INSTANCE = timer

PARAMETER HW_VER = 1.00.a

PARAMETER C_ONE_TIMER_ONLY = 1

PARAMETER C_TRIG0_ASSERT = 0

PARAMETER C_BASEADDR = 0x83c00000

PARAMETER C_HIGHADDR = 0x83c0ffff

BUS_INTERFACE SPLB = mb_plb

PORT SPLB_Clk = sys_clk_s

PORT CaptureTrig0 = timer_CaptureTrig0

END

 

.C:

#include "xparameters.h"

#include "xgpio.h"

#include "xutil.h"

#include "xtmrctr.h"

int main (void)

{

  xil_printf("\n\r Entering main");  

  int counterReg = 0;

  int tDevId = XPAR_TIMER_DEVICE_ID;

  XTmrCtr timer; TmrCtr_Initialize(&timer ,tDevId);

  XTmrCtr_mSetControlStatusReg(&timer, tDevId, XTC_CSR_EXT_CAPTURE_MASK | XTC_CSR_CAPTURE_MODE_MASK | XTC_CSR_AUTO_RELOAD_MASK |     XTC_CSR_ENABLE_ALL_MASK);

  while (1)

  {

    counterReg = XTmrCtr_mGetTimerCounterReg(&timer, tDevId);

    if(XTmrCtr_mHasEventOccurred(&timer, tDevId))

    {

      xil_printf("\n\r mHasEventOccurred");

    }

    if(counterReg > 0)

    {

      xil_printf("\n\r CounterReg > 0");

      xil_printf("\n\r TimerCounterReg is: %d",counterReg);

    }

  }

}

 

The only output I get on my hyperterminal is:

Entering main

 

I think my problem lies within the TCSR (Timer Control Status Register), and I tried a couple of different MASK setups but nothing works. I also tried the XTmrCtr_SetOptions() instead of XTmrCtr_mSetControlStatusReg() with different setups. I can’t figure out what the difference is between XTmrCtr_SetOptions() and XTmrCtr_mSetControlStatusReg. But I have tried some debugging and have come to the conclusion that XTmrCtr_SetOptions() does not affect the TCSR, which is the one I think I need to setup the right way. The only thing I can get running is, if I start the timer manually with XTmrCtr_Start() and then use XTmrCtr_GetValue() function to get the current value of the counter, the counter just counts up until it reaches the end at 32bit and then stop (it’s about 1½min.). So I know that something is working.

 

So again I can’t get the CaptureTrig0 working. Hope someone out there can help me.

 

EDIT: I guess this post should have been in "EDK and Platform Studio" sorry about that.

Message Edited by simon.b on 03-15-2009 11:43 AM
Message Edited by simon.b on 03-15-2009 11:55 AM
0 Kudos