This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

WCAP instruction is read only once

Hi,

I want to store the time stamp on the rising edge of a signal using WCAP.

When I read the first rising edge, it is ok, but the time stamp on the next is not read by WCAP, I mean, the value in hr_data is not updated after having read once.

Thank you beforehand

  • Brice,

    Something must be wrong, because the WCAP will continue to capture edges.  
    What makes you say the WCAP didn't catch the next rising edge?  Are you missing an interrupt, or do you actually see that the data field in the WCAP instruction has not changed?

  • Hi Anthony,

    thank you for your reply,

    In my example, I have 2 signals : 1 clock (on pin 1) and 1 generated pulse (pin 6) with SHF instruction which data value  = 0x0100

    On the clock I intended to set a WCAP instruction to read the time stamp (hr_lr is HIGH) on every rising edge.

    on pin 6 I set a WCAP to monitor the first rising edge.

    Aim : compute the difference of timestamp between the last clock rising and the first rising edge on pin 6

    what I observe is that the rising edge are well detected and the conditional address is well executed, but the data field and the hr_data field of both instruction stays at 0

    the hr_lr is set on both instructions. So I don't figure out why I have got no thing

     

     

  • Brice,

    - What register are you capturing in the WCAP and can you be certain that this register isn't zero?
    -  Are you by any chance running WCAP with CONTROL=ON?

     

  • no control is off

    I am using the register R for the clock and S for the signal pin6

    *** instruction for clock

    TimeStampClock    WCAP { next=DetectStartBit,hr_lr=HIGH,cond_addr=COPYRISETIME,pin=CLOCKPIN,event=RISE,reg=S,data=0,hr_data=0};

    *** instruction for pin6

    DetectStartBit     WCAP { next=InitState,hr_lr=HIGH,cond_addr=loadTtClkPulse,pin=RXPIN,event=RISE,reg=R,data=0,hr_data=0};

  • in previous answer I inverted the register, but I am using this both R and S register for the WCAP.

  • Brice,

    Normally what you would do is this:

    a) have a single counter, such as

    CNT {reg=T, max=...., data=0}

    WCAP {...  reg=T}  for your clock pin

    WCAP{... reg=T}  for your data pin

    In other words, you are telling the WCAP instruction to capture the value of a counter whenever the edge on your pin matches the WCAP condition.  The register in the WCAP instruction is the register that holds the counter value....

    Here is the psuedo code, the 'arrow' shows the capture that happens, the register you selected gets put into the immediate data field of WCAP whenever the condition matches.

    Since you want to do a delta-time measurement from one pin event to the next, I don't know why the two registers in the PCNT would be different.   You'd normally have them be the same so that the same counter timebase is used.  Otherwise if you have different counter time-bases, a skew between the two timebases would show up in the delta-time result.

    Did you have CNT or similiarly incrementing instructions for the R, S, registers to implement the counters needed by WCAP?

     

  • Anthony,

    my problem is that I want to sample on the high resolution clock of the het. If I use a counter basd on loop resolution and my first pulse on pin 6 occured in the midle of one Loop resolution I would get only get a big approximation of it

    should I use so the PCNT counter ..?

  • The PCNT is not the one.

    If you have an idea on how to implement that, that would be great.

    thks

  • Brice,

    Since you want the delta-time between the edge on one pin and edge on another pin, PCNT will be difficult to use.   WCAP is what you want I think.

    WCAP supports Hi-Res.  But be aware that there is an errata on the WCAP hi-res capture on some silicon revisions.

    For example, if you check the 31xx/21xx errata for revision B silicon -  lit # SPNZ193 you'll see this issue documented.   Revision C silicon has the errata removed (lit # SPNZ195).    Just be sure to check the errata for the silicon that you are actually using for any issue w. WCAP.

     

  • Hi Anthony,

     

    Could you tell me how you do that actually ?

    I made one try with a signal received on pin 6 and shifted of 130 ns from my clock on pin 0 

    my clock is synchronised with the LRP,

    - the hr_data of WCAP on  the clock is 0

    - and, the hr_data on this signal is 7,

    my high resolution period is 27 ns 

    7 x 27 = 189 ns

     

    regards,

     

  • Brice,

    Hard to say without seeing all the details.  Seems like your math is ok, and you might expect a value of 4 to 5 instead of 7.

    Are you actually using the WCAP to measure the clock and getting the hrp value of 0?  Or are you assuming it would read 0 because it's driven at loop resolution.   If the latter, there might be a delay due to synchronization - I'd need to experiment with the hardware to check this but the 2 cycles seems about right for a synchronizer.  If you're not subtracting the actual result of 2 WCAP instructions - this small error might creep in.

    If you are subtracting the 2 WCAP then please post your HET code if possible to I can look into it;  along with how the HET is configured (clock prescalers especially).

     

  • Hi Anthony,

    yes at least my math is good.

    I can't post my code, but the portion of code implemente the following :

     VCLK2 = 110 MHz, hr = 3, lr = 128,

    the clock period is 2 LRP, (counter 0 to 1 )

    I used WCAP to monitor the rising edge on clock and on the red signal, with hr_lr = high  

  • Brice,

    It is not clear to me how you evaluate the data for the WCAP instructions. In order to see the behavior correctly, you will need to monitor the data without interrupting the operation of NHET. A method we used very often in testing is to enable HTU transfer for the instruction we want to monitor and evaluate the data saved in CPU RAM. I would suggest the following.

    (1) Set up two buffers in CPU RAM to save NHET data.

    (2) Enable HTU transfer for the two WCAP instructions so that the time stamp of the rising edges will be transferred to CPU RAM.

    (3) Evaluate the data in CPU RAM.

    I am attaching a CCS project as an example. It uses WCAP instruction on two NHET pins to measure the pulse width. HTU is used to pass data from NHET RAM to CPU RAM for evaluation. This test runs from RAM.You can use it as a reference.

    2352.NHET_WCAP_SMALL_PULSE.zip

    Thanks and regards,

    Zhaohong

  • Brice,

    What version of silicon do you have?  There is an errata regarding the accuracy of WCAP when the event occurs at the loop boundary - see http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=spnz193c&fileType=pdf  errata item NHET#52.   This is corrected on the revision C silicon (http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=spnz195b&fileType=pdf)

    It's not 100% clear to me how this errata would be behind your results being off by a few counts, but you do seem to have the conditions for the errata setup correctly with one of the WCAP on a signal that transitions right at the loop res. boundary.

     

  • Hi Anthony,

    I am using the XRM48 L952ZWTT

    do you see the same issue with this one ?

  • Hi Brice,

    The silicon revision is on the next line of text, third character.

    See http://e2e.ti.com/support/microcontrollers/hercules/w/design_notes/2543.how-to-identify-the-die-revision-for-rm4xx-products.aspx    For a diagram showing where to read it.

    If it's 'C' then the WCAP issue is fixed, otherwise it's there.

     

  • Thank you for your answer,

    before I close this discussion, could you tell me if there is a way to copy the hr_lr value of the WCAP and paste it into the  hr_lr field of another instruction ? 

  • Brice,

    It wasn't really intended for this purpose, but the REMP src1, rdest operands of the ADC/ADD/... instruction read/write bits P[8:0] of a remote instruction.   The intent of adding this capability was to change the remote field of certain instructions, but the hr_lr bit happens to be P[8] of the WCAP so it should be able to be read/written this way.

    What did you have in mind though for reading/writing the hr_lr bit?

     

  • Hi Anthony,

    tks, I will try that in few minutes

    bascally instead of using an interrupt to read the value of the hr_lr field within the WCAP and in software modify the field of  another instruction to this value, I would like to read and write directly in the HET program, so I avoid some CPU load.

    is there a contre-indication to do that, as you said the purpose of ADC/ADD wasn't intended for this purpose ?   

    tks

    Brice

     

  • Brice,

    Nothing I know about that's 'wrong' with this scenario, just not sure if it was verified as this wasn't the intent of adding the operand. 

    Are you trying to get around the limitation of 'one hr_lr' instruction per pin/per loop by changing the hr_lr field on the fly?

    If so, two things to note:

       1) if you execute the WCAP with hr_lr = high, and then in the same loop after executing it change hr_lr=low of that instruction,  set hr_lr=high of a new instruction, and then finally execute that new instruciton,  where WCAP and the new instruciton operate on the same pin - all within one loop resolution period - this wouldn't get around the restriction.  Once you execute the first hr_lr = HIGH on a pin that uses the pin's hi-res structure for that entire loop.

      2) if this is what you're trying to do, you might have an easier time selecting which instruction to execute in hr_lr=HIGH in any given loop by branching around the instructions, rather than changing the program field on the fly.