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: How to reset overflow of periodic count in PCNT instruction

Part Number: TMS570LS3137

Hi Team,

We are using Hercules TMS570LS3137 controller with CCS8.0. We are using the HET module for below functionality.
Configure PCNT instruction for reading the pulse counts and read the pulse count values for certain number of events.

Now, if we implement the above functionality for multiple HET pins, we are seeing abnormal behavior when following conditions happen:

1. Our primary requirement is that when no input signal is given to HET pins, the pulse count values should be read as 0. So, for this, we enabled control feature.
2. When we remove input on one of the HET pin (say 0) and given valid input for other HET pin (say 1), and wait until control field value for PCNT instruction on pin 0 reaches to all 1's.
3. Now, reading pulse count value from pin 1 is not a valid one.

Can you please let me know the reason for this behavior and is there any errata and work around for this issue?

Regards,
M.Sreenivasan.

  • Hi Sreenivasan,

    Can you please upload your HET program that includes the counter setup and the two PCNT instructions that you are executing on pin0 and pin1?

    When you say "no input signal is given" to an HET pin, is that pin floating or is it grounded?

    Regards,
    Sunil
  • Hi Sunil,

    The pins are not floating.

    Regards,
    M.Sreenivasan.

  • Hello M.Sreenivasan.

    The PCNT instruction is used to measure the high/low pulse time or period of the input. The control field [24:0] is to store the number of resolution loop rather the input pulse.

    ECNT is the instruction to count the pulse.
  • Hi Wang,

    PCNT instruction is used for measuring pulse period and pulse counts and ECNT instruction is for measuring the events count, ie., based on the given input signal, PCNT instruction can measure the pulse counts could it be based on high to high or low to high etc and ECNT instruction is used for measuring how many high to high or low to high events has occured.

    Regards,
    M.Sreenivasan.
  • Hi Wang,

    Any updates on this?

    Regards,
    M.Sreenivasan.
  • Hello M.Sreenivasan.

    PCNT captures the counter value [C24:C0] into the period/pulse count field [D31:D7] on the selected edge. The counter is incremented each N2HET loop even if the input signal is flat (no edges). After 2^24 NHET loop resolution clock cycle, the counter reaches overflow, and PCNT stops counting until the next reset edge (rising edge or falling edge based on the counter type) is detected.

    On your pin which has valid input, if the counter type for pin1 is rise2fall, when rising edge is detected, the counter value is cleared to zero, when the falling edge is detected, the counter value is captured and saved in data field [D31:D7].

    I still suggest to use ECNT rather than using PCNT to measure the pulse count.
  • Hi Wang,
    As per manual (snpu499c.pdf), ECNT does the following (when the event occurs, the immediate Data field is incremented by 1):

    If (event occurs)
    {
    If (Register A or B Selected) {
    Selected register = Immediate Data Field + 1;
    }
    If (Register R, S or T Selected)
    {
    Selected register[31:7] = Immediate Data Field + 1;
    Selected register[6:0] = 0;
    }
    Immediate Data Field = Immediate Data Field + 1;
    If (Interrupt Enable == 1) HETFLG[n] = 1; /* n depends on address */
    If ([C28:C27] == 01) Generate request on line [P25:P23];
    If ([C28:C27] == 11) Generate quiet request on line [P25:P23];
    Jump to Conditional Address;
    }
    else
    {
    Jump to Next Program Address;
    }

    But, for measuring the pulse count period, we have to use PCNT instruction.

    Regards,
    M.Sreenivasan.
  • Hello Sreenivasan,

    In your code, the L02 (ECNT) measures the both the rising edge and the falling edge. The data field of this instruction will be incremented by 1 at rising edge, and will be incremented by 1 at falling edge as well. The L02 is executed when the event (rising edge OR falling edge) occurs, so the data field in L03 (ADD) is not the correct accumulative value for L00 (PCNT). L04 is the copy of L02, so the data field of L04 is not correct either.
    ________ _________ _________
    | | | | | |
    1 2 3 4 5 6
    | | | | | |
    ----------- ------------------- ----------------- ---------

    For the input signal as above diagram, the Period (L00) is the number of resolution loop between edge 1 and edge 3, assume it is 3. The data field of L01 (ECNT) is 6 after edge 6.

    The data field in your L02 is not 6 but something else.

    If you use the rising edge for ECNT, the data field of ECNT will be the pulse count. After falling edge 6, the data of ECNT = 3.

    The data field in L02 is also correct, it is 6.
  • Hi Wang,

    Can you please let us know the procedure for testing the same on simulator environment.
    Please let us know if you are able to reproduce the issue on real target?

    Regards,
    M.Sreenivasan.
  • Hello Sreenivasan,

    I haven't got chance to do test on the real target.

    Please download the HET IDE:
    http://www.ti.com/tool/HET_IDE

    This is the user guide:
    www.ti.com/.../spnu483a.pdf

    I will send you my program used in HET IDE simulation.
  • Thanks Wang.

    We will test it. Please let me know if you are able to reproduce the issue on real target? Can you please expedite on it.

    Regards,
    M.Sreenivasan.
  • Hi Wang,

    Any updates on this? Can you please share your observations on real target?

    Regards,
    M.Sreenivasan.
  • Hi Wang,

    Can you please let me know if you have any updates?

    Also, as mentioned in previous comments, please do share your test code

    Regards,
    M.SReenivasan.

  • Hi Wang,

    Any updates on this?

    Regards,
    M.Sreenivasan.
  • After evaluating this use case again, I still suggest to use ECNT instead of PCNT to measure the event of the input signal. The ECNT can detect event of fall/rise/both/high/low of the input signals.
  • Hi Wang,

    Based on ECNT condition, we need pulse counts measured from PCNT for further processing. Can you confirm on reproducing the problem in your lab?

    Regards,
    M.Sreenivasan.
  • Hello,

    I am sorry for late response. you can use ECNT to count the pulse, and PCNT to measure the period or pulse width. Since the counter in PCNT increases every loop resolution, it will reach to overflow quickly if there is no input or the input is a constant value.