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.

[RM57L Launchpad] How to use ECAP to measure PWM generated by HET?

Other Parts Discussed in Thread: RM57L843, HALCOGEN

Hi everyone,

With the help of the community, I've completed a simple example: Use ECAP to measure PWM generated by ETPWM (EPWM, are they identical?).


Now I'd like to use ECAP to measure PWM generated by HET module.

Is that possible?

Thanks in advance!

Best regards,

Honig

  • Honig,

    Yes, sure. The PWM signal generated by the HET module needs to meet the input timing constraints of the eCAP module. These constraints are specified in the RM57L datasheet.

    Regards,
    Sunil
  • Hello Honig,
    Not sure what your intended application is. If you are trying to create some type of selftest where you would generate a PWM using NHET and the eCAP to measure it, you might try to use the NHET1[15] and ECAP1 pair. These two signals are connected to the same I/O buffer. It is possible to generate a PWM using NHET1 on NHET1[15] and measure on eCAP1 without any external connection.
  • Hi Charles,

    Thanks for your help! The RM57L Launchpad doesn't have ball N1 on the board (c.f. this post). Do you mean that I am still able to use Ball N1 "without connecting wires"?

    Best regards,

    Honig

  • Hi Sunil,

    Thank you! I'll have a look at the section "input timing" in the datasheet of RM57L843 (SPNS215A –FEBRUARY 2014 –REVISED MAY 2014).

    Do you mean?
    1. (N2HET) Section 6.6.3 "Input Timing Specifications"
    2. (eCAP) Section 6.2.4 "Enhanced Capture Module Timings"

    Thanks in advance!

    Best regards,
    Honig
  • Hi Sunil,

    I tried to use eCAP to measure HET generated PWM and the code "HL_sys_main.c" is the following:

    #include "HL_sys_common.h"
    
    /* USER CODE BEGIN (1) */
    
    #include <stdio.h>
    #include "HL_system.h"
    #include "HL_het.h"
    #include "HL_etpwm.h"
    #include "HL_ecap.h"
    #include "HL_esm.h"
    
    /* USER CODE END */
    
    /** @fn void main(void)
    *   @brief Application main function
    *   @note This function is empty by default.
    *
    *   This function is called after startup.
    *   The user can use this function to implement the application.
    */
    
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    
    	/* Enable interrupt */
    	_enable_interrupt_(); //_enable_IRQ(); 
            //_enable_IRQ_interrupt_();
    
    	hetInit();
    	etpwmInit();
    	ecapInit();
    
    	/* ... run forever */
    	while(1);
    
    /* USER CODE END */
    }
    
    /* USER CODE BEGIN (4) */
    
    /* ECP notification */
    void ecapNotification(ecapBASE_t *ecap, uint16 flags)
    {
    	uint32 cap1, cap2, cap3;
    	float64 duty, period;
    
    	cap1 = ecapGetCAP1(ecapREG2);
    	cap2 = ecapGetCAP2(ecapREG2);
    	cap3 = ecapGetCAP3(ecapREG2);
    
    	duty   = (cap2 - cap1) * 1000 / VCLK4_FREQ; //VCLK4_FREQ?
    	period = (cap3 - cap1) * 1000 / VCLK4_FREQ;
    
    	/* nanosec. to milisec. */
    	duty *= 1.0/1000000;
    	period *= 1.0/1000000;
    
    	printf("Duty = %fms\n", duty);
    	printf("Period = %fms\n\n", period);
    
    }


    Compile and obtain following errors:

    Description    Resource    Path    Location    Type
    #138 expression must be a modifiable lvalue    HL_sys_main.c    /etpwmServo_RM57L/source    line 153    C/C++ Problem
    #138 expression must be a modifiable lvalue    HL_sys_main.c    /etpwmServo_RM57L/source    line 154    C/C++ Problem
    #138 expression must be a modifiable lvalue    HL_sys_main.c    /etpwmServo_RM57L/source    line 155    C/C++ Problem
    #41 expected an identifier    HL_sys_main.c    /etpwmServo_RM57L/source    line 150    C/C++ Problem

    When

    #include "HL_het.h"
    hetInit();
    

    are commented out, all errors disappear. Is the configuration of HET1 or eCAP via HALCoGen not correct?


    Thanks in advance!

    Best regards,

    Honig

  • Hi Honig,

      It is correct that N1 is not brought out to the LaunchPad connector but the I/O buffer is still there in the device. You can use N1 but you won't be able to observe it on the scope. The application will be limited to what I described by using the ECAP1 to measure PWM generated on NHET1[15].

  • Hi Charles,

    It sounds pretty good that ECAP1 can measure PWM generated on NHET1[15] without connecting a wire. But under PINMUX tab, there could be a conflict on ball N1 between N2HET1[15] and ECAP1. How to resolve this conflict? Should I disable ECAP1 or the other?

    Best regards,

    Honig

  • Hi Honig,

      Actually you don't need to select any things for N1 in HalCoGen. N2HET1[15] is the default signal for N1. So when you drive a PWM, the signal will come back via the input buffer and get broadcasted back to N2HET1[15], MIBSPICS[4], N2HET2[22] and ECAP1. In the N2HET1 module make sure you enable pin15 for output in the DIR register and drive your PWM onto this pin. You can even use N2HET2[22] to measure the PWM if you want to.