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:NHET & cap

Other Parts Discussed in Thread: TMS570LS3137, HALCOGEN

零件编号: TMS570LS3137

Dear team,

My customer is using TMS570LS3137. I do not have this device,please help me to test his configuration.

The customer wants to realize the pulse catching function through the NHET of TMS570LS3137. He used HALCoGen to configure the pin crossbar switch, edge and cap functions, as follows:

1. The signal source is generated using the PWM module, using the 2-pin output, and returning to the 0 pin through the external loop;

2. Pin 0 is configured as an NHET pin and is an input pin, and pin 2 is an NHET pin and an input pin;

Test Results:
The signal generated by the PWM module is normal. The signal drives an indicator, the flashing frequency of the light is correct, but the capture module uses the edgeGetCounter and/or capGetSignal functions to capture pulses, the number of pulses, period and duty cycle are both 0.

Please help.

7002.HAL config.docx

  • Hi Susan,

    Please ask your customer to use the default N2HET1 settings first, to check if they can get correct edge counter, dutycycle, and period.

    The default PWM pins are: N2HET1_8/10/12/14/16/17/18/10

    The default Edge pins are: 9, 11, 13, 15, 20, 21, 22, 23

    The default CAP pins: 0, 2, 4, 6, 24, 26, 28, 30            ----> HR shared is required. Please don't use pin 1, 3, 5, 7, 27, 29, 31 for PWM, Edge etc.

    Your customer Use:

    1. PWM pins: 13, 2, 14, 15, 16                       --- Pin 2 is output here

    2. Edge pins: 0, 11, 13, 15, 20, 21, 22

    3. CAP pins: 5, 2, 4, 6, 7, 2, 4                         -- pin 2 is configured as input here. Doesn't need HR share requirement

    Th pins for CAP should be Even number 2n (0, 2, 4, 6), and the HR structure of pins 2n+1 (1, 3, 5, 7...) are also used for CAP, so 2n+1 pins should not be used for other N2HET functions (PWM, Edge, etc). 

  • Thanks for your reply!

    But still with no luck. The customer has been using the N2HET2 module. According to the default configuration, the duty and period that are still captured are both 0.

    Please see the following doc to get the configuration.

    8508.HAL config(new).docx.

  • Hi Susan,

    1. For CAP channels 0/4, 1/5, 2/6, 3/7 use the same pin: 0, 2, 4, 6. Please use different NHET pins for CAP channel 4, 5, 6, 7.

    2. Most NHET2 pins are multiplexed with other modules (MibSPI, GIO, etc), please configure those pins for NHET through PINMUX

    3. From your attached doc, the PWM channels are not enabled, so no input signal to CAP input pin.

  • Thanks!

    The N2HET part is configured according to the HAL default configuration, the pin assignments are all used by default. PINMUX is also configured.

    The reason why the PWM is not configured but use the default configuration is because they want to avoid the interference of the PWM module and the CAP module.

    An external signal source is used to directly inject into the corresponding pin of CAP0. Still not working, change it back to normal IO function, read IO level is OK.

    Do we have any example code?

  • Hi Susan,

    I remember they loop the PWM output to CAP input. If you use external signal source, they don't have to enable PWM (pin 8, 10,..).

    I don't have example code, but I did this kind of test several times, and never saw this kind of issue.

  • Hi Susan,

    Two more things to check:

    1. HET2 is enabled or not

    2. VIM channel 63 and 73 are enabled or not (for HET2 interrupt). If they read data from NHET instruction in interrupt mode, interrupt should be enabled.

  • Hi QJ,

    Thanks for your reply.

    1.HET2 is enabled.HALCoGen project can  be  seen in attachment.

    2.We read data from NHET instruction in main loop,every 100ms ,use these program.

    capGetSignal(hetRAM2, cap0, &testCapSigCh0);

    printf("\r\nsig ch0=%d,%f",(testCapSigCh0.duty),(testCapSigCh0.period));

    we got result as ,sig ch0=0,0.000000

    3.Several days ago,we used loop PWM to Capture as test method,but failed.

      Now we used the external  signal, which can be captured by same pin (HET2 pin0) but working in GPIO mode.

     Although the signal is provably right,we got the same failed result,sig ch0=0,0.000000.

    please helps,Thanks.

    1447.HALCoGen.zip

  • Hi QJ,

    David David2 is the customer I mentioned earlier. Please help.

  • Hello,

    Please change LRPFC (hetREG2->PFR[10:8]) to 0x06 or 0x7.

    In your code, LRPFC = 4 which means there are 16 lots., but here are 57 instructions used for PWM/CAP/Edge etc.The longest path through an N2HET program must be completed within the loop resolution clock (LRP). 

  • Hi Qj,

    According the way above,we changed  the code generated by  HALCoGen ,so pleased that got the right Duty value.
    Unfortunately, Period value was still incorrect (a wrong figure ,is not zero).

    Do you have other suggestion?

    Thanks.

  • What is the difference between the measured period and the correct period? 

    If the frequency is 1khz, the period should be 1ms, what is the measured period? 

    What does  "incorrect (a wrong figure ,is not zero)" mean?

  • Hi,QJ

    I had try the way as followed URL,but problem(wrong period value) was still occurred.

    Thanks.

  • Hello,

    You said you got correct duty cycle. Did you make any NHET code modification to get correct duty cycle as described in the post from e2echina.ti.com?

  • In HALCoGen generated code, the counter type of "FALL2RISE" is used for duty-cycle measurement, and "FALL2FALL" is used for period measurement. As described in post from e2echina, you can use counter type of "RISE2FALL" and "RISE2RISE" for measuring duty-cycle and period as well.

    As default, the hr-lr is cleared, which means the high resolution mode is used for this PCNT instruction on pin 0 (0, 2, 4, 6,...). All five HR instructions (PCNT, WCAP, ECMP, MCMP, and PWCNT) have a dedicated hr_lr bit (high resolution/low resolution; program field bit 8) allowing operation either in HR mode or in standard resolution mode by ignoring the HR field. There is one architecture restriction on N2HET program: Only one instruction (using high resolution) is allowed per high resolution pin. This means if you use high resolution for duty-cycle on pin 0, and you can not use high resolution for period on pin 0. Thanks for the HR Share feature which allows two HR structures to share the same pin for input capture.

    In the NHET code generated by HALCOGen, the instruction #25 is for duty-cycle using pin 0 HR structure on pin 0, and the instruction #26 is for period using the pin 1 HR structure for capturing signal on pin 0. The HR share is enabled for Pin 0 and Pin 1 on HALCOGen N2HET1-->Pin 0~7 configuration page: