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.

TMS570LC4357: Conflict issue b/w even and odd HET PWM Capturing pins

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN,

Hii Team/Jagadish,

I want a configuration details for to make it work for capturing pwm for both het pairs , which are available in het1 and het2. 

My issues which i faced.
1)Im not able capture the pwm from N+1 pin , when HR share is enabled
2)Im not able to capture the pwm from any pin , if HR share is disabled
3)Im not able to capture the pwm from N+1 pin, if N pin assigned to other purpose, o/p pin or pwm o/p pin. How to resolve this?
3)Im not able to capture the pwm from N pin using capture configuration, and edge based interrupt +RTI based configuration from N+1 pin, at the same time, o/p is refelcting on other another.

please provide the solutions for the above queries as soon as possible. Thank You.

Regards,
Sandeep Kalakota

  • Hi Sandeep,

    Apologies for the delayed response.

    HALCoGen, capturing code is designed in such way that, duty cycle capturing is on Nth pin then corresponding period capture is on N+1 pin. Please refer below picture once.

    So, if you want to capture single signal duty cycle and period then you need to do any of the following things:

    1. You can disable HR share and can feed same signal externally between two pins. That is at both N and N+1 pins.

    2. You can enable HR share and can feed only at N, so same will get feed to N+1 structure and will be helpful to calculate both duty cycle and period of a signal.

    So, basically two pins required for capturing. If you want to do capturing of duty cycle and period using only one pin(N) and you want to use other pin(N+1) for other purpose (capturing other signal) then you need to modify HALCoGen generated code manually.

    something like below:

    If i did like above, then i can use 3 and 5 for other capturing, because here capturing of both duty and period are happening on same pin that is N.

    Remember, if you do any manual changes like above in HALCoGen generated code then if you regenerated the code then it will overwrite your changes.

    --
    Thanks & regards,
    Jagadish.

  • Hii jagadish, 
    I have done the above changes and seen the results, but still the conflict and reflection of results on both the pins is seen.
    What im trying to do is, with N pin im trying to capture the pwm using hetcapture and N+1 im trying to capture pwm using edge interrupts. This is not working as expected, with HR share enable and HR share disable.

    give me the proper solution to capture pwm indivudually for HET capture pairs pins, without any conflicts , it should be able to capture independently

  • Hi Sandeep,

    Try below suggestion from our internal AI tool, if this doesn't help you then i will try to recreate an example at my end.

    # Solution for Independent PWM Capture on HET Pin Pairs (TMS570LC4357)

    ## Problem Analysis
    You're experiencing conflicts when trying to capture PWM independently on adjacent HET pins (N and N+1) using different methods simultaneously. This is due to the HET architecture's shared resources between pin pairs.

    ## Root Cause
    - **HET pins are paired** (0-1, 2-3, 4-5, etc.)
    - **HR (High Resolution) share logic affects both capture methods**
    - **Instruction RAM conflicts** when both pins try to capture simultaneously
    - **Time base sharing** between paired pins

    ## **PROPER SOLUTION: Use Non-Adjacent Pins**

    ### White check mark Recommended Approach

    ```c
    /* Use NON-ADJACENT HET pins for independent capture */

    // Pin Configuration - Use pins that are NOT paired
    #define HET_CAPTURE_PIN_A 0 // For hetCapture
    #define HET_CAPTURE_PIN_B 2 // For Edge Interrupt (NOT pin 1)
    // OR
    #define HET_CAPTURE_PIN_A 4 // For hetCapture
    #define HET_CAPTURE_PIN_B 6 // For Edge Interrupt (NOT pin 5)

    /* Initialize HET */
    void PWM_Capture_Init(void)
    {
    hetInit();

    /* Configure Pin A for hetCapture (e.g., Pin 0) */
    // Setup capture instruction in HET RAM
    hetREG1->PINS = (1 << HET_CAPTURE_PIN_A);

    /* Configure Pin B for Edge Interrupt (e.g., Pin 2) */
    gioInit();
    gioEnableNotification(hetREG1, (1 << HET_CAPTURE_PIN_B));

    // Disable HR share for both pins
    hetREG1->HRSHARE = 0x00000000;
    }
    ```

    ---

    ## **Alternative Solution: If You MUST Use Adjacent Pins**

    ### Configuration for Adjacent Pins (N and N+1)

    ```c
    /* Special configuration for adjacent pins */

    void Adjacent_Pin_Capture_Init(void)
    {
    hetInit();

    /* Method 1: Use BOTH with hetCapture API only */
    // Configure capture for Pin N
    hetCAPTURE_Config_t capConfig_N = {
    .pin = 0, // Pin N
    .capture_mode = hetCAPTURE_RISING_EDGE,
    .capture_type = hetCAPTURE_PERIOD_MODE
    };

    // Configure capture for Pin N+1
    hetCAPTURE_Config_t capConfig_N1 = {
    .pin = 1, // Pin N+1
    .capture_mode = hetCAPTURE_RISING_EDGE,
    .capture_type = hetCAPTURE_PERIOD_MODE
    };

    /* CRITICAL: Configure HR Share properly */
    // Option 1: Disable HR share completely
    hetREG1->HRSHARE = 0x00000000;

    /* Use separate instruction slots in HET RAM */
    // Ensure instructions are at least 4 slots apart
    // Configure in HET program (HET Assembly)
    }
    ```

    ---

    ## **Best Practice Implementation**

    ### Complete Working Example

    ```c
    #include "het.h"
    #include "gio.h"
    #include "sys_common.h"

    /* Pin Definitions - Non-adjacent pins */
    #define PWM_HETCAP_PIN 0 // HET[0] for hetCapture
    #define PWM_EDGE_INT_PIN 2 // HET[2] for Edge Interrupt

    /* Capture variables */
    volatile uint32_t hetcap_period = 0;
    volatile uint32_t hetcap_duty = 0;
    volatile uint32_t edge_timestamp[2] = {0};
    volatile uint8_t edge_index = 0;

    /* HET Capture Initialization */
    void HET_Capture_Init(void)
    {
    hetInit();

    /* Configure HET[0] for Capture using HET instructions */
    // This should be done in HET program

    /* Disable HR sharing to prevent conflicts */
    hetREG1->HRSHARE = 0x00000000;

    /* Set pin direction as input */
    hetREG1->DIR &= ~(1 << PWM_HETCAP_PIN);

    /* Enable HET */
    hetREG1->GCR = 0x01000001;
    }

    /* Edge Interrupt Initialization */
    void Edge_Interrupt_Init(void)
    {
    gioInit();

    /* Configure HET[2] as GIO for edge interrupt */
    hetREG1->DIR &= ~(1 << PWM_EDGE_INT_PIN); // Input

    /* Enable interrupt on both edges */
    gioEnableNotification(hetPORT1, (1 << PWM_EDGE_INT_PIN));
    gioNotification(hetPORT1, (1 << PWM_EDGE_INT_PIN));

    /* Configure for both edges */
    hetREG1->INTPOL &= ~(1 << PWM_EDGE_INT_PIN); // Both edges
    }

    /* HET Capture ISR or Polling */
    void Get_HET_Capture_Data(void)
    {
    // Read capture data from HET RAM
    // Implementation depends on your HET program
    hetcap_period = hetRAM1->Instruction[CAP_INST_NUM].Data;
    }

    /* Edge Interrupt ISR */
    void gioNotification(gioPORT_t *port, uint32 bit)
    {
    if(port == hetPORT1 && (bit & (1 << PWM_EDGE_INT_PIN)))
    {
    /* Read current time */
    edge_timestamp[edge_index] = hetREG1->CNT;
    edge_index = (edge_index + 1) % 2;

    /* Calculate period if needed */
    if(edge_index == 0)
    {
    uint32_t period = edge_timestamp[1] - edge_timestamp[0];
    // Process period
    }
    }
    }

    /* Main function */
    void main(void)
    {
    _enable_IRQ();

    HET_Capture_Init();
    Edge_Interrupt_Init();

    while(1)
    {
    Get_HET_Capture_Data();

    // Process both captures independently
    // hetcap_period and edge_timestamp are independent
    }
    }
    ```

    ---

    ## **HET Program Configuration (HET Assembly)**

    ```assembly
    ; HET Program for Pin 0 Capture
    ; Ensure proper instruction spacing

    CAP_0: CAP
    {
    next_program_address = NEXT_INST;
    pin = 0;
    capture_condition = RISING;
    capture_mode = PERIOD;
    interrupt_enable = ON;
    }

    ; Leave gap between instructions for pin pairs
    NOP { next_program_address = NOP2; }
    NOP2 { next_program_address = NOP3; }
    NOP3 { next_program_address = NEXT_SECTION; }

    NEXT_SECTION:
    ; Continue with other instructions
    ```

    ---

    ## **Critical Configuration Checklist**

    ```c
    /* Apply these settings for conflict-free operation */

    void Apply_Critical_Settings(void)
    {
    /* 1. Disable HR Share */
    hetREG1->HRSHARE = 0x00000000;

    /* 2. Configure pins as inputs */
    hetREG1->DIR &= ~((1 << PWM_HETCAP_PIN) | (1 << PWM_EDGE_INT_PIN));

    /* 3. Disable pull control if not needed */
    hetREG1->PULDIS |= ((1 << PWM_HETCAP_PIN) | (1 << PWM_EDGE_INT_PIN));

    /* 4. Set proper pin muxing */
    hetREG1->FUN &= ~(1 << PWM_EDGE_INT_PIN); // GIO mode for edge int pin
    hetREG1->FUN |= (1 << PWM_HETCAP_PIN); // HET mode for capture pin

    /* 5. Clear any pending interrupts */
    hetREG1->FLG = 0xFFFFFFFF;
    gioREG->FLG = 0xFF;
    }
    ```

    ---

    ## **Summary**

    ### White check mark **RECOMMENDED SOLUTION:**
    1. **Use non-adjacent HET pins** (0 & 2, 4 & 6, etc.)
    2. **Disable HRSHARE** completely
    3. **Configure pin functions correctly** (HET vs GIO)
    4. **Use separate time bases** if possible

    ### Warning️ **If Adjacent Pins Required:**
    1. Use **both pins with hetCapture only** (not mixed methods)
    2. Ensure **HET instruction spacing** (4+ slots apart)
    3. **Disable HR sharing**
    4. Consider **hardware limitations** - may not work as expected

    **The conflict occurs because paired pins share hardware resources. Using non-adjacent pins completely eliminates this issue.**

    --
    Thanks & regards,
    Jagadish.