TMS570LS0914: Facing issue with Duty and period reading with HET instruction set

Part Number: TMS570LS0914

  1. Pin Configured : N2HET[18]
  2. Reading PWM duty and period through HET instruction set

    void capGetSignal(hetRAMBASE_t * hetRAM, uint32 cap, hetSIGNAL_t *signal)
    {
        uint32    pwmDuty   = (hetRAM->Instruction[(cap << 1U) + 25U].Data) >> 7U;
        uint32    pwmPeriod = (hetRAM->Instruction[(cap << 1U) + 26U].Data) >> 7U;

        signal->duty   = (pwmDuty * 100U) / pwmPeriod;

        if( hetRAM == hetRAM1)
        {
            signal->period = ((float64)pwmPeriod * 1066.667F) / 1000.0F;
        }
        else
        {
            signal->period = ((float64)pwmPeriod * 1066.667F) / 1000.0F;
        }
    }

  3. It is reading the correct live value
  4. But it is not able to read the zero/100 duty cycle 
  5. if CP is OFF it is still holding the previous value of duty and period
  6. Instruction set is provided here
  7.    /* PCNT: Capture Duty 0
        *         - Instruction                  = 25
        *         - Next instruction             = 26
        *         - Conditional next instruction = na
        *         - Interrupt                    = na
        *         - Pin                          = 0
        */
        {
            /* Program */
            0x00034E00U | (uint32)((uint32)0U << 6U)  | (uint32)(0U),
            /* Control */
            0x00000000U,
            /* Data */
            0x00000000U,
            /* Reserved */
            0x00000000U
        },
        /* PCNT: Capture Period 0
        *         - Instruction                  = 26
        *         - Next instruction             = 27
        *         - Conditional next instruction = na
        *         - Interrupt                    = na
        *         - Pin                          = 0  + 1
        */
        {
            /* Program */
            0x00036E80U | (uint32)((uint32)0U << 6U)  | (uint32)((0U) + 1U),
            /* Control */
            0x00000000U,
            /* Data */
            0x00000000U,
            /* Reserved */
            0x00000000U
        },

 

  • Usha,

    Thanks for reaching out to the E2E.  I need to get this re-assigned to the correct engineer in the team.  Please give us another day to respond to your question.

    Best,

    Matthew

  • Hi Usha Kumari,

    We have one internal AI which can analyze all the relevant documents of this device, i got couple of suggestions from it. So, i suggesting you refer these suggestions once and if this is not helpful then i will try to debug further on your issue.

    Root Cause Analysis

    The issue appears to be in the capture mechanism of the N2HET module. Looking at your instruction set:

    1. Instruction 25 is a PCNT instruction configured to capture duty cycle
    2. Instruction 26 is a PCNT instruction configured to capture period

    The PCNT instructions are designed to measure active pulses. When:

    • Duty cycle is 0%: There are no rising edges to trigger the capture
    • Duty cycle is 100%: There are no falling edges to trigger the capture
    • Signal is off: No transitions occur to update the capture values

    Recommended Solutions

    1. Implement a Timeout Detection Mechanism

    void capGetSignal(hetRAMBASE_t* hetRAM, uint32 cap, hetSIGNAL_t* signal)  
    {  
        static uint32 lastPwmData = 0;
        static uint32 noUpdateCounter = 0;
        
        uint32 currentPwmData = hetRAM->Instruction[(cap << 1U) + 25U].Data;
        uint32 pwmDuty = currentPwmData >> 7U;  
        uint32 pwmPeriod = (hetRAM->Instruction[(cap << 1U) + 26U].Data) >> 7U;
        
        // Check if data has been updated
        if (currentPwmData == lastPwmData) {
            noUpdateCounter++;
            if (noUpdateCounter > TIMEOUT_THRESHOLD) {
                // No updates for too long - assume signal is off or at 0/100% duty
                signal->duty = 0; // Or determine if it should be 100 based on pin state
                signal->period = 0;
                return;
            }
        } else {
            noUpdateCounter = 0;
            lastPwmData = currentPwmData;
        }
        
        signal->duty = (pwmDuty * 100U) / pwmPeriod;
        
        if (hetRAM == hetRAM1) {  
            signal->period = ((float64)pwmPeriod * 1066.667F) / 1000.0F;  
        } else {  
            signal->period = ((float64)pwmPeriod * 1066.667F) / 1000.0F;  
        }  
    }

    2. Use Additional HET Instructions for Edge Detection

    Modify your HET program to include edge detection instructions that can identify when the signal is static at high or low levels.

    3. Add Pin State Monitoring

    void capGetSignal(hetRAMBASE_t* hetRAM, uint32 cap, hetSIGNAL_t* signal)  
    {  
        uint32 pwmDuty = (hetRAM->Instruction[(cap << 1U) + 25U].Data) >> 7U;  
        uint32 pwmPeriod = (hetRAM->Instruction[(cap << 1U) + 26U].Data) >> 7U;
        
        // Check pin state directly
        uint32 pinState = (gioGetBit(hetPORT1, cap) == 1);
        
        // If period hasn't changed for X cycles and pin is consistently high/low
        if (isSignalStatic(pwmPeriod)) {
            signal->duty = pinState ? 100 : 0;
            signal->period = 0;  // Or maintain last valid period
            return;
        }
        
        signal->duty = (pwmDuty * 100U) / pwmPeriod;
        
        if (hetRAM == hetRAM1) {  
            signal->period = ((float64)pwmPeriod * 1066.667F) / 1000.0F;  
        } else {  
            signal->period = ((float64)pwmPeriod * 1066.667F) / 1000.0F;  
        }  
    }

    4. Use a Different Capture Configuration

    Consider modifying your HET instructions to use edge-triggered interrupts that can detect both the presence and absence of transitions within an expected timeframe.

    --
    Thanks & regards,
    Jagadish.