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.

TMS570LS3137: WCAP instruction clarification

Part Number: TMS570LS3137

Hi there,

I'm a bit confused on configuration and usage of the N2HET WCAP instruction.

Let say, does the following code segment make sense?

L00 CNT     { next=L01, angle_count=OFF, reg=A, comp=EQ, IRQ= OFF, max=0x01FFFFFF, data=0 }
L01 WCAP    { next=L02, reg=A, pin=CC23, irq=ON, event=RISE, hr_lr=HIGH, data=0 }
L02 WCAP    { next=L00, reg=A, pin=CC24, irq=ON, event=RISE, hr_lr=HIGH, data=0 }

On edge detection, what value will be stored to the 25-+bit WCAP data field (DF)? 

Is reg=A (25-bit) the source register to write to WCAP DF, or 0 as specified by "data=0"?

Is reg=S (32-bit) is used, when will happen to the WCAP DF?

Thanks.

  • Hello Chuck,

    1. The data field of WCAP is updated in the loop succeeding the loop in which the edge occurred. DF=Value of regA (rising edge occurs) + 1;
    2. Yes, Reg A is the source
    3. The value of Reg S will be written to DF
  • Hi QJ,

    When the data= x will be used in the WCAP instruction ?

    As in the code, we need to use the HR Data in addition of the 25-bit captured value. Can you let me know how that works as in whether the HR Data shall be added or subtracted from the 25-bit capture value? Where can I find this info in the RM?

    Thank you!
  • Hello Chuck,

    The data=x in WCAP instruction is not used, and is overwritten with the value of the selected register in the next loop after the capture condition occurs.

    If you want to use HR data, please configure hr_lr=0 (HIGH). When the capture condition is true, the HR register value is capture to HR data field.

    For example:

    HETPFR_register = 0x0200 --> lr = 4, hr = 1, ts = 4

    N2HET Program:

    L00 CNT {reg=A, max=01ffffffh}
    L01 WCAP {next=L00, cond_addr=L00, hr_lr=high, reg=A, event= FALL, pin=0, data=0}

    At Pin0 falling edge, the HR counter (2) is captured, this value will be written to HR Data field. The value of Register A (4) in next loop will be written to Data file (25 bits). Since lr=4, only bit 6 and bit 5 of HR field are valid, so bit[6:5]=b10 (2 HR clocks) --> HR field is [6:0] =b1000000 (total 7 bits)

    32-bit data file = (25-bit data << 7) | HR Field (4 << 7) | (b1000000) = b10_0100_0000 = 0x240

  • Thanks QJ for the info,

    QJ Wang said:
    32-bit data file = (25-bit data << 7) | HR Field (4 << 7) | (b1000000) = b10_0100_0000 = 0x240

    Isn't it rather like this?

    32-bit data file = (25-bit data << 7) | HR Field = b10_0100_0000 = 0x240

    Not wanting to argue, but I've a tendency to believe the edge has occurred between A=3 and A=4, so 

    32-bit data file = ((25-bit data-1) << 7) | HR Field = b01_1100_0000 = 0x1C0

    Am I missing something? I understand that it will not make any difference because the count is always relative to any other reading, as long as the formula is used for all counts ...

    Regards.

  • Hi Chuck,

    You are right. That is my typo at midnight.
    32-bit data file = (25-bit data << 7) | HR Field = b10_0100_0000 = 0x240

    If the edge occurs before WCAP execution, 3 is captured to data field. Otherwise, 4 will be captured by next WCAP in next loop.
  • Thanks!

    Just a general question: Is it possible to execute two different code segments independently from the same N2HET (to reduce LR loop time), or I need to use both N2HET1 and N2HET2 for 2 instructions in each?

    Regards.
  • Hello Chuck,

    The instructions executs sequentially, one after the other. After reaching the end, the program rolls back to the first instruction. It is not possible to run two sets of code in parallel in one N2HET module.