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,

As per document (Technical reference manual) for PCNT instruction,
-"When the overflow count (all 1’s in the counter value) is reached, PCNT stops counting until the next reset edge is detected."

Can you please provide us more details or probably an example on how to reset the periodic counter? 

We could see that once periodic counter reaches overflow condition, PCNT instruction stops counting further.

A quick response is highly appreciated.

Please find the below use case scenario:
1. We sampling pulse counts using PCNT instruction from pin 0 and pin 1.
2. Pin 0 is connected with signal source and pin 1 is not connected to any signal source.
3. Pulse counts are incremented (in PCNT instruction) for both PCNT instructions (one for pin 0 and one for pin 1).
    Note: Not sure why PCNT instruction sampling pulse count for pin 1 also increments in this case?
4. So, for PCNT instruction sampling pulses for pin 1 reaches to all F's, pulse counts for both pins 0 and 1 are giving zero even though valid signal is present in pin 0.
    Is it expected behaviour and further way forward for this issue?

Regards,
M.Sreenivasan.

  • Hi Sreenivasan,

    The reset edge for the PCNT counter is defined by the type of measurement it is performing. For example: if you have configured the PCNT to measure pulse-width such that you start measuring from a rising edge until the next falling edge (RISE2FALL), and if the counter overflows before the falling edge occurs, then the next rising edge is used as the reset edge.

    Some comments on your use case:
    1. We sampling pulse counts using PCNT instruction from pin 0 and pin 1.

    >> What measurements are you doing using PCNT on pins 0 and 1?

    2. Pin 0 is connected with signal source and pin 1 is not connected to any signal source.

    >> Is pin 1 floating or tied to high/low?

    3. Pulse counts are incremented (in PCNT instruction) for both PCNT instructions (one for pin 0 and one for pin 1).
    Note: Not sure why PCNT instruction sampling pulse count for pin 1 also increments in this case?

    >> What measurements are you making on pins 0 and 1? The choices for PCNT are FALL2RISE, RISE2FALL, FALL2FALL and RISE2RISE.

    4. So, for PCNT instruction sampling pulses for pin 1 reaches to all F's, pulse counts for both pins 0 and 1 are giving zero even though valid signal is present in pin 0.
    Is it expected behaviour and further way forward for this issue?

    Regards,
    Sunil
  • Hi Sunil,

    We are measuring for RISE2RISE.

    1. We sampling pulse counts using PCNT instruction from pin 0 and pin 1.

    >> What measurements are you doing using PCNT on pins 0 and 1?
    ===> capturing the pulse counts , for the given input signal on pins 1 and 0.
    2. Pin 0 is connected with signal source and pin 1 is not connected to any signal source.

    >> Is pin 1 floating or tied to high/low?
    ==> pin 1 is not connected to any input signal. so, it has the default configuration.

    3. Pulse counts are incremented (in PCNT instruction) for both PCNT instructions (one for pin 0 and one for pin 1).
    Note: Not sure why PCNT instruction sampling pulse count for pin 1 also increments in this case?

    >> What measurements are you making on pins 0 and 1? The choices for PCNT are FALL2RISE, RISE2FALL, FALL2FALL and RISE2RISE.
    ==> We are using Rise2Rise.

    Regards,
    M.Sreenivasan.
  • Hi Again,

    If we don't give input to pin 1, still PCNT instruction will be executed and pulse period count is incremented. This is what we noticed the behaviour. So, if no input is given and period count is incrementing, how can we ensure reset will happen on pin 1 if there is no input is given?
    Since, it is affecting PCNT instruction for pin 0 where a valid input is given.

    Regards,
    M.Sreenivasan.
  • Hi Sreenivasan,

    Do you have HR-sharing turned ON for channels 0 and 1? This allows the input on channel 0 to be "piped" to the high-resolution timer structures for channels 0 and 1 simultaneously. This is the way to be able to measure duty cycle and period for a given input signal using two separate PCNT instructions on two separate adjacent timer channels. The pin 1 is available for general-purpose I/O in this case.

    Regards,
    Sunil
  • Hi Sunil,

    Think, we are not sharing it. Please see below instruction which we are using it.

    L00: PCNT { hr_lr=HIGH,next=L01,type=RISE2RISE,pin=0};

    Regards,
    M.Sreenivasan.
  • Hi Sunil,

    Question: Do we have a way to detect a signal connected to any N2HET pins?
    One way we tried for this is, control flag is set in PCNT instruction, so that after reading of the Data in PCNT instruction by CPU, the data value will be cleared and if there is no signal connected to that pin (mentioned in PCNT instruction), data value will not be incremented.
    But, it has some problems as mentioned below:

    Let me explain the scenario of test case which we are testing:
    L00: PCNT { hr_lr=HIGH,control_flag=ON,next=L01,type=RISE2RISE,pin=0};
    ...
    L10:: PCNT { hr_lr=HIGH,control_flag=ON,next=L11,type=RISE2RISE,pin=1};

    So, if we give input signal on pin 0, the periodic count in PCNT control word value will vary, but not in L10 instruction as there is no input signal given to pin 1. So, here whenever L10 gets executed, periodic count in PCNT control word is incrementing continuously.
    Question: Why in L10 instruction, periodic count should increment, even though no signal is given in pin 1.

    After sometime, in L10 instruction, periodic count in PCNT instruction reaches to all 1's, then the PCNT instruction in L00 behaves bit wierdly and Most of the times we get Data value 0 in L00 instruction.

    We would request to have a call to discuss on this issue. Can you please send us the meeting invitation?

    Regards,
    M.Sreenivasan.
  • Hi Sreenivasan,

    If pin 1 is floating, it could float past the threshold to be seen as a low-to-high transition which triggers the PCNT in L10. This counter will increment every loop until it sees a "stop capture" event which would be another rising edge (as you are choosing RISE2RISE).

    Can you tie pin 1 to ground if you don't plan on using it for valid input (or just as an experiment to resolve this issue)?

    Regards,
    Sunil