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 Input Multiplexing

Other Parts Discussed in Thread: HALCOGEN

Dear Community,

I have a question regarding Input Multiplexing of  RM57L LaunchPad.

I want to follow a built-in tutorial in HALCoGen -- example_etpwm_ecap.c

"This is an example which describes the steps to configure ETPWM for generating PWM signal and ECAP to capture the same and calculate its frequency and duty cycle,Here ETPWM1A pin is configured to generate a PWM wave and is fed to ECAP1 pin"

I could not find the ball N1 for eCAP1 input on the LaunchPad...

Thanks in advance!

Best regards,

Honig

  • Hi Honig,

    Not sure if you found where ball N1 goes or not - so just in case.

    You can search the schematic (PDF) for N1 and you'll find after several clicks this:

    The last item is the location of the next reference in the schematic to this signal. (12.4B means sheet 12, column 4 row B) - I marked the area below so you can see what it refers to.  Anyway within this grid it's easy to find the ECAP1 pin.   But it goes to the DP8360 phy which is great if you want to capture a timestamp from ethernet with the ECAP but not so great if you want to drive a signal in.   The next ref is back to the original sheet with the BGA so this signal is only going to the phy.

    Sorry about that I think the HalCoGen example was originally written for HDK and we didn't consider it when selecting ECAP1 for the PHY on the launchpad.


    Only thing I can suggest is that there are 6 ECAP modules on the device, and hopefuly with the help of HalCoGen it's easy enough for you to pick a different ECAP module.

    Maybe you can try using ECAP2 or 3 which are on the booster pack header J2 instead?

    You'll need to make a few changes when you do the example - first instead of passing the pointer to ECAP1 (ecapREG1) to the APIs change to the ECAP you are using like ecapREG2 if using ECAP2.

    Then in the GUI of course you would configure ECAP2 instead of ECAP1, and when you setup the VIM you would look for the interrupt channel from ECAP2 instead of ECAP1.  Also you have to adapt the pinmux and the interrupt callback appropriately.   But hopefully this is mostly self explanatory through the GUI and if you get stuck pls. post here. 

    Also when you're done if you want to share your adapted launchpad project back to the community that would be very appreciated.

  • Hi Anthony,

    Thank you for the timely and detailed explanation!

    Yes, I will use eCAP2 or another instead. I found the N1 ball in that schematics file "L A U N C H X L 2 _ 5 7 0 L C 4 3 _ R M 5 7 L" but not on the LaunchPad. Is the schematics file specified for HDK?

    Thank you once again!

    Best regards,
    Honig
  • Hi Anthony,

    I have following questions regarding to the same example:

    1. Under "PINMUX" tab after checking boxes "ETPWM" and "ECAP", ball A4 has a conflict. I removed ETPWM1SYNCI (synchronization of PWM to another input signal?), since the generated PWM in this tutorial should be considered as output. Must the synchronization of PWM signal refer to an external PWM signal or signals of other forms of waves? And since TBCLK sync (interal synchronization?) is enabled, ETPWM1SYNCI and ETPWM1SYNCO can both be disconnected?

    2. Under "ETPWM1" tab in Clock Configuration, VCLK3 (MHz) the value 75.000 cannot be changed. Moreover HSPCLKDIV and CLKDIV are to be set to 0 according to the screen shot in the example, but the following codes mean that both of them should be set to 1.

    /* Alternate code for configuring ETPWM and ECAP */
    /* Set the TBCLK frequency = VCLK4 frequency = 90MHz */
    etpwmSetClkDiv(etpwmREG1, ClkDiv_by_1, HspClkDiv_by_1);

    Divided by 0 .. hmm doesn't make sense, so "set 0 (or 1) in GUI" mean "set 1 in the code"?

    3. Under "ETPWM1" tab in PWM Configuration, there are two PWM (ETPWM xA and xB). Can I close either of them in the configuration?

    Thanks in advance!

    Best regards,
    Honig
  • HI Anthony, 

    Regarding the same example "etpwm_ecap", 

    I have tried to use ECAP1 to check the PWM generated by HET1, but I was even not able to compile the code. Is the ePWM module is the unique option?

    The modified "HL_sys_main.c" is the following:

    ------------------------------------------------------------------------------------------------------

    /* Include Files */
    
    #include "HL_sys_common.h"
    
    /* USER CODE BEGIN (1) */
    
    #include "stdio.h" /* printf */
    #include "HL_system.h"
    #include "HL_het.h" //#include "HL_etpwm.h"
    #include "HL_ecap.h"
    
    /* USER CODE END */
    
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    
    /* Enable interrupt */
    _enable_interrupt_();
    
    #if 1
    /* Initialize HET module */
    hetInit();
    /* Initialize ECAP module */
    ecapInit();
    
    #else
    /* Alternate code for configuring ECP */
    
    /* Configure ECAP2 */
    /* Configure Event 1 to Capture the rising edge */
    ecapSetCaptureEvent1(ecapREG2, RISING_EDGE, RESET_DISABLE);
    
    /* Configure Event 2 to Capture the falling edge */
    ecapSetCaptureEvent2(ecapREG2, FALLING_EDGE, RESET_DISABLE);
    
    /* Configure Event 3 to Capture the rising edge with reset counter enable */
    ecapSetCaptureEvent3(ecapREG2, RISING_EDGE, RESET_ENABLE);
    
    /* Set Capure mode as Continuous and Wrap event as CAP3 */
    ecapSetCaptureMode(ecapREG2, CONTINUOUS, CAPTURE_EVENT3);
    
    /* Start counter */
    ecapStartCounter(ecapREG2);
    
    /* Enable Loading on Capture */
    ecapEnableCapture(ecapREG2);
    
    /* Enable Interrupt for CAP3 event */
    ecapEnableInterrupt(ecapREG2, ecapInt_CEVT3);
    
    #endif
    
    /* Run forever */
    while(1);
    
    /* USER CODE END */
    }
    
    /* USER CODE BEGIN (4) */
    
    void ecapNotification(ecapBASE_t *ecap, uint16 flags)
    {
    /* #41 expected an identifier */
    uint32 cap1, cap2, cap3;
    float64 duty, period;
    
    /* #138 expression must be a modifiable lvalue */
    cap1 = ecapGetCAP1(ecapREG2);
    cap2 = ecapGetCAP2(ecapREG2);
    cap3 = ecapGetCAP3(ecapREG2);
    
    duty = (cap2 - cap1) * 1000 / VCLK4_FREQ;
    period = (cap3 - cap1) * 1000 / VCLK4_FREQ;
    
    printf("Duty = %fns\n", duty);
    printf("Period = %fns\n\n", period);
    
    }
    
    /* USER CODE END */
    
    
    ------------------------------------------------------------------------------------------------------
    
    Compile and fail with errors:
    
    Description	Resource	Path	Location	Type
    #138 expression must be a modifiable lvalue	HL_sys_main.c	/hetPwm_ecap_RM57L/source	line 125	C/C++ Problem
    #138 expression must be a modifiable lvalue	HL_sys_main.c	/hetPwm_ecap_RM57L/source	line 126	C/C++ Problem
    #138 expression must be a modifiable lvalue	HL_sys_main.c	/hetPwm_ecap_RM57L/source	line 127	C/C++ Problem
    #41 expected an identifier	HL_sys_main.c	/hetPwm_ecap_RM57L/source	line 122	C/C++ Problem

    Thanks in advance!

    Best regards,

    Honig

  • Hi Anthony,

    There are several ways to enable interrupts:

    /* Enable both IRQ */
    _enable_IRQ_interrupt_(); // declared in "HL_sys_core.h"
    _enable_IRQ(); // where is its declaration?
    
    /* Enable both IRQ and FIQ */
    _enable_interrupt_(); // declared in "HL_sys_core.h"
    

    In this example "etpwm_ecap", FIQ interrupt is used, so we can use _enable_IRQ(); instead?

    Thanks in advance!

    Best regards,

    Honig

  • Honig,

    Regarding #41, I don't 'see' a problem with your code.  uint32 should be defined in HL_hal_stdtypes.h.

    II'm guessing that the #138 errors are a secondary effect of the #41 errors though.


    Do you get any error messages about not being able to find the header files when you build?

    Also are you building on linux.  there were some forum posts about this error #41 where it seems like the path to the header file is case sensitive.

  • Hi Honig,
    Regarding the IRQ v.s. FIQ question I don't understand, because the code above actually shows that you are using the IRQ.
    Normally you should use IRQ level for all your application interrupts, and reserve the FIQ as an NMI for serious errors (on the Hercules parts). Since it is NMI, you won't want to use FIQ for interrupts that need to be 'masked' which would be most of your application interrupts.
  • Honig,

    Sorry I was out of the office for a few days.

    1. Under "PINMUX" tab after checking boxes "ETPWM" and "ECAP", ball A4 has a conflict. I removed ETPWM1SYNCI (synchronization of PWM to another input signal?), since the generated PWM in this tutorial should be considered as output. Must the synchronization of PWM signal refer to an external PWM signal or signals of other forms of waves? And since TBCLK sync (interal synchronization?) is enabled, ETPWM1SYNCI and ETPWM1SYNCO can both be disconnected?

    Yes this is correct.

    2. Under "ETPWM1" tab in Clock Configuration, VCLK3 (MHz) the value 75.000 cannot be changed. Moreover HSPCLKDIV and CLKDIV are to be set to 0 according to the screen shot in the example, but the following codes mean that both of them should be set to 1.

    /* Alternate code for configuring ETPWM and ECAP */
    /* Set the TBCLK frequency = VCLK4 frequency = 90MHz */
    etpwmSetClkDiv(etpwmREG1, ClkDiv_by_1, HspClkDiv_by_1);

    Divided by 0 .. hmm doesn't make sense, so "set 0 (or 1) in GUI" mean "set 1 in the code"?

    You are just getting the register *value* mixed up with the effective divider.   Please see below from page 2005 of SPNU563.

    (You didn't read all 2129 pages!  ;) ...   this is why we have HalCoGen, 2129 pages is too much for any person to absorb.  But when you do have a question like this you can always check the TRM next to see if what HalCoGen is doing makes sense or not).

    3. Under "ETPWM1" tab in PWM Configuration, there are two PWM (ETPWM xA and xB). Can I close either of them in the configuration?

    Yes but if you pick a different one than the example, it may mean making additional changes.   Should be easy changes, but I am not sure what they are (if any).

  • Hi Anthoy,

    The #41 error is caused by the macros .. cap1, cap2, cap3 are already defined as constants in HL_het.h. Eventually I can use eCAP to measure PWM generated by HET.

    Thank you once again!
    Best regards,
    Honig