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 can I measure clock frequency of an external device?

Part Number: TMS570LS3137

Hello everybody,

I want to read the clock frequency of a external device. Before do that, I generated a simple pwm signal(used pin 10) and read(used pin30) them with use  "capGetSignal(nhetRAM,cap)" function. It works, there is no problem. But now I want to measure clock frequency of external device. The device generates 1MHZ clock frequency.

Do you have a suggestion ?

  • There are at least a couple choices:
    1) Connect the external signal as input to a HET channel and then use a HET program to measure the period of this input signal.
    2) Connect the external signal an input to the N2HET1[31] pin, and then use either a HET program or the dual-clock comparator (or both) to measure the input signal frequency.

    Regards,
    Sunil
  • Hi Sunil,
    Thanks for answer. But I have already tried this way. I used "capGetSignal(nhetRAM,cap)" function but when I try to measure 1Mhz frequency, I could not get actual period and duty values. Do you have any idea about this problem?
  • Hi,

    There are constraints on the input signal frequency and duty cycle depending on the configuration of the high-resolution and loop-resolution periods. These are specified in the datasheet in the "Input Timing Requirements" table in the N2HET specifications section.

    Does your configuration of HR and LR periods allow you to measure a 1MHz signal?
  • Hi,

    Yes you are exactly right. I guess our configuration does not allow to measure true period and duty values. I had generated  20 kHz pwm signal with %50 duty cycle and I observe same freq and duty cycle values when i was debugging. Then,  I generated same signal with using external signal generator and I did not observe true frequency value.

    My Experimental Results

    generated from TMS                        ----> period : 100us          duty: %23

    read via TMS (debug mode)          ----> period : 99.2us         duty:%23            

    read via oscilloscope                       -----> period : 1.625ms    duty:%23

    generated from signal generator ----> period: 100us          duty:%61

    read via TMS (debug mode)          ----> period : 5.599us       duty:%42            

    read via oscilloscope                       -----> period : 100us          duty:%61

    generated from signal generator ----> period: 1us              duty:%50                we want to measuere this value on project.

    read via TMS (debug mode)          ----> period :  unstable   duty:%0                  

    read via oscilloscope                       -----> period : 1us             duty:%50

    Note : HET2 configuration;

  • Hi again,

    I read the documentation about signal measurement limitations(section 6.2) and I saw some limitation as below;

    ->Min Period - 1 x 1LRP                    => 1422.22ns

    ->Max Period- 0x01FFFFFF x 1LRP => 47721851 us

    So,  according to this limitations I can not measure 1MHz frequency, Am I right?

    However, As I read the other documentation (NHET#54) there is a solution like this; 

    Connect the input pulse to be measured on two nHET channels using the high resolution share feature. Then use two WCAP instructions, one to measure the falling edge, the second to measure the rising edge. Use the CPU to calculate the time difference. In this workaround the period of the input signal must be two loop resolutions or longer.

    As a result, could you please tell me "How to set up WCAP instruction ?"

  • Hello,

    Even with the suggested workaround, the input signal period must be at least 2 x LRP. So this workaround will not work for you to measure a 1MHz input signal.

    Regards,
    Sunil
  • Thank you so much.