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.

RM48L952ZWT NHET Pulse Capturing

Other Parts Discussed in Thread: RM48L952, HALCOGEN

Hello. We are using the RM48L952 ZWT.  If we want to configure NHET for pulse capture, is there a code example of what functions to use? i.e., in het.c we only found the pwmStart,etc.

Thank you

  • Tammy,

    The blackbox HET code includes pulse period & duty cycle measurements. You can look at those for an example.
    The instruction to study is called PCNT - if you want to measure time.

    Outside the blackbox driver world:
    If you want to count pulses or edges, you can look at ECNT.
    If you want to timestamp - then you can use WCAP.
  • Hi. Thank you. Your wrote "blackbox HET code includes pulse period & duty cycle measurements". which functions do you mean that are autogenerated via HalCoGen (function names)?
  • Hi Tammy,

    This is the API function to read the capture value (period, duty).

    /** @fn void capGetSignal(hetRAMBASE_t * hetRAM, uint32 cap, hetSIGNAL_t signal)
    *   @brief Get capture signal
    *   @param[in] hetRAM Pointer to HET RAM:
    *              - hetRAM1: HET1 RAM pointer
    *              - hetRAM2: HET2 RAM pointer
    *   @param[in] cap captured signal:
    *              - cap0: Captured signal 0
    *              - cap1: Captured signal 1
    *              - cap2: Captured signal 2
    *              - cap3: Captured signal 3
    *              - cap4: Captured signal 4
    *              - cap5: Captured signal 5
    *              - cap6: Captured signal 6
    *              - cap7: Captured signal 7
    *   @param[in] signal signal
    *              - duty cycle in %.
    *              - period period in us.
    *
    *   Gets current signal of the given capture signal.
    */
    /* SourceId : HET_SourceId_013 */
    /* DesignId : HET_DesignId_013 */
    /* Requirements : HL_SR377 */
    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 * 853.333F) / 1000.0F;
        }
        else
        {
            signal->period = ((float64)pwmPeriod * 853.333F) / 1000.0F;
        }
    }

  • Hi Tammy,

    Just checking if this answered your question.
  • Hi Thank you. We are working on using this function in some test code with the board. As soon as I have feedback (I hope it is an Ok), I will let you know. Thank you again.
  • Hi Anthony. Thank you. Is there something special we have to do to get HalCoGen HET tab to autogenerate the capGetSignal(hetRAMBASE_t * hetRAM, uint32 cap, hetSIGNAL_t signal) function? HalCoGen is not generating this function (uit doesn't exist in our source HalCoGen driver code generated by HalCoGen. Thank you again.

  • Tammy,

    As far as I know all you need to do is have the HET driver enabled and select the blackbox driver in the HET tab.

    The function should be output into the file het.c.

  • Hi. Thank you. We did that (because we have PWM working on some pins, and that was Ok), and 3 other pins as Pulse Capture. But when we do a generate code. The declaration of this function is in the header (.h) file, but no function code in .c. How can we get HalCoGen to autogenerate this function? Is there an additional step in HalCoGen to get the Pulse Capture functions?
  • Tammy,

    That's interesting. You can see the #if statements in the template file and I don't *see* one that controls the capture function generation except disabling the blackbox driver. But that also wraps the PWM functions.

    Would it be possible for you to upload your het.c file so we can take a look?
  • Hi Anthony. Thank you. See attached het.c file.  Thank you again. Here it is:  1680.het.c

  • Hi. Thank you. I found the function after editing. I will let my colleagues know. Never mind. :-)
  • Hi. One More question, thank you again.

    We started testing. In the capGetSignal, what happens if pwmPeriod comes back as "0"? Then it is a divide by 0 issue (triggers an arm exception). It crashed because there was no signal to capture on one terminal. Is there aw way aro7und this, or should we just do a version of the same function to check pwmPeriod so line 29 signal->duty = (pwmDuty * 100U) / pwmPeriod; does not result in an exception if pwmPeriod = 0?
  • H Anthony. Disregard the last question. We have it Ok now. Thank you again.