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.

RTOS/TMDXIDK5718: PWM control from DSP

Part Number: TMDXIDK5718
Other Parts Discussed in Thread: AM5718, AM5728

Tool/software: TI-RTOS

Hello,

I want to configure a PWM in the AM5718 for the IDK571x board, and two questions have arised:

1. Is there any xdc module for PWMs? I have found pwm_test in Diag, but it doesn't use any libraries.

2. Can we test the output of the PWM in the IDK571x board? My aim was to use VIN2A_D2/eCAP1_in_PWM1_out, but it doesn't seem to be in any connector.

Thanks and best regards,

Laura

  • Hi,

    1. There is no XDC PWM module and there is no RTOS driver/example for this. The PWM_DIAG is the reference code for the testing. It is bare metal.

    2. The diag folder pdk_am57xx_1_0_12\packages\ti\board\diag\pwm\build showed that the platform we supported is evmAM572x. The source code also showed:
    /**
    * \file pwm_test.c
    *
    * \brief PWM diagnostic test file
    *
    * Targeted Functionality: Validating the CSL functional layer APIs for
    * PWM module
    *
    * Operation: This tests demonstrate the usage of PWM CSL FL APIs by
    * configuring the PWM module to generate a pulse of 1KHz with different
    * duty cycle - 25, 50 and 75%.
    *
    * Supported SoCs: K2G, AM572x, AM437x & AM335x
    *
    * Supported Platforms: evmK2G, evmAM572x, idkAM437x & evmAM335x
    *
    * Note: Manual verification is needed to confirm the PWM pulse generation.
    * Details of PWM pin used on each platform is given below
    * evmK2G - J12 pin 33
    * evmAM572x - P17 pin 5
    * idkAM437x - J16 pin 14
    * evmAM335x - J5 pin 13

    Do you have evmAM572x? Or IDK AM571x only?

    Regards, Eric
  • Hi,

    If you have to use IDK AM571x, from AM5718 TRM: chapter 29

    Table 29-2. PWM Subsystems I/O Signals
    PWMSS Modules Level
    Signal Name
    Device Level Signal
    Name
    I/O Type(1) Description Module Pin
    Reset Value
    PWMSS1
    EPWM1A ehrpwm1A O PWM1 output A 0
    EPWM1B ehrpwm1B O PWM1 output B 0
    EPWM1SYNCI ehrpwm1_synci I PWM1 Sync input HiZ
    EPWM1SYNCO ehrpwm1_synco O PWM1 Sync output 0
    EPWM1_TRIP_TZ[0] ehrpwm1_tripzone_input I PWM1 TripZone input HiZ
    ECAP1_CAPIN_APWMOU
    T
    eCAP1_in_PWM1_out I/O eCAP1 Capture input/PWM1
    output
    HiZ
    EQEP1_A eQEP1A_in I eQEP1 Quadrature input HiZ
    EQEP1_B eQEP1B_in I eQEP1 Quadrature input HiZ
    EQEP1_INDEX eQEP1_index I/O eQEP1 Index input/output HiZ
    EQEP1_STROBE eQEP1_strobe I/O eQEP1 Strobe input/output HiZ

    I understood you can use eCAP1_in_PWM1_out signal.

    From IDK AM571x user guide: www.ti.com/.../sprui97b.pdf
    I don't see any pin for eCAP1_in_PWM1_out.

    From AM5718 datasheet: Table 4-26. PWM Signal Descriptions:
    eCAP1_in_PWM1_out ECAP1 Capture Iniput / PWM Output IO D1

    This signal is available to ball D1. From table 4-2,
    Table 4-2. Ball Characteristics, this D1 ball can be used as either as vin2a_d2 (pinmux mode 0) or eCAP1_in_PWM1_out(PINMUX mode 10). You can modify the pinmux of am5718 IDK as long as you don't use VIN2A port.

    Then from IDK AM571x user guide: www.ti.com/.../sprui97b.pdf. The pin is accessible from J21 expansion port, pin 48.

    So, test is possible. For change PINMUX, please see software-dl.ti.com/.../Board_EVM_Abstration.html

    Regards, Eric
  • Thank you very much for your answer.

  • Part Number: TMDXIDK5718

    Tool/software: TI-RTOS

    Hello,

    I am trying to configure the PWM from DSP as in RE: RTOS/TMDXIDK5718: PWM control from DSP https://e2e.ti.com/support/processors/f/791/p/740558/2734930#2734930

  • I guess part of the message has been erased:

    Firstly, I see that for the example in pwm_test.c, that for AM5728, it uses ehrpwm2A and not eCAP2_in_PWM2_out (which is the one that I must use for module 1 for IDK5718).

    How does eCAPn_in_PWMn_out work? Does it follow A, B or a combination of both? When I configure CTRL_CORE_PAD_VIN2A_D2 with MUXMODE = A, how does it know whether it is CAP input or PWM output?

    Anyway, to continue with the test, I have decided to use ehrpwm1A, configured from CTRL_CORE_PAD_VIN2A_VSYNC0 (0x4A00 3564) .

    For AM571x IDK EVM, it is accessible from J21 pin 42 (AM57XX_GPMC_AD12 AM571X_VIN2A_VSYNC0).
    If I change the code of pwm_test.c to work with PMW 1 instead of 2, and configure the related pin, should I see the PWM signal in J21 pin 42? It is not working.

    Thanks and best regards,

    Laura
  • Laura Valverde said:
    How does eCAPn_in_PWMn_out work? Does it follow A, B or a combination of both? When I configure CTRL_CORE_PAD_VIN2A_D2 with MUXMODE = A, how does it know whether it is CAP input or PWM output?

    Laura,

    These signals come from two different peripherals:

    • eCAPn_in_PWMn_out : This comes from the eCAP module which is documented in Section 29.3 of the TRM.
    • ehrpwm2A : This comes from the ePWM module which is documented in Section 29.2 of the TRM.

    Each of these pins belongs to a unique peripheral, and correspondingly each has its own mux mode.

    Is there a specific pin that you are required to use due to existing hardware implementation?  Which one?  Both the ePWM and the eCAP are capable of creating a PWM, though the ePWM module has a lot more capabilities such as creating a complimentary pair with hardware deadband, etc.  If you just need a simple PWM, either one can do it.

    Best regards,
    Brad

  • Hi Brad,

    Thanks again for our support! The hardward implementation will be using eCAP1_in_PWM_out, so I need to configure the CAP module instead of ePWM.

    I have changed the code in order to work with eCAP. I have used some of functions in ti/csl/src/ip/ecap/V0/priv/ecap.c.

    The code is as follows:

    #include "ti/board/board.h"
    #include "ti/board/board_cfg.h"
    #include <ti/csl/soc/am571x/src/cslr_soc_mpu_baseaddress.h>
    #include <ti/csl/soc/am571x/src/cslr_control_core_pad_io.h>

    #include <ti/csl/soc.h>
    #include <ti/csl/csl_epwm.h>
    #include <ti/csl/src/ip/ecap/V0/ecap.h>

     /*Address of the PAD config pinMux register*/
    #define CTRL_CORE_PAD_VIN2A_D2_ADDR             (CSL_MPU_CORE_PAD_IO_REGISTERS_REGS + \
                                                     CSL_CONTROL_CORE_PAD_IO_PAD_VIN2A_D2)

    #define MODULE_CLK                              (133000000U)/*133MHz*/

    #define TBCLK_FREQ                              (MODULE_CLK/4)
    #define PWM_FREQ                                (1000)/*1KHz*/

    #define PERIOD_APWM  (uint32_t)(TBCLK_FREQ/PWM_FREQ)
    #define DUTY_CYCLE 60
    #define COMPARE_APWM  (uint32_t)((PERIOD_APWM * DUTY_CYCLE)/100)


    /* Enables clock for PWM module */
    static void pwmClockConfig(void)
    {

        /* Enable PRCM for PWMSS1 */
        HW_WR_REG32(SOC_L4PER_CM_CORE_BASE + CM_L4PER2_PWMSS1_CLKCTRL, 0x2);
      
      //TODO: Timer for returning when it fails
        while ((HW_RD_REG32(SOC_L4PER_CM_CORE_BASE +
                            CM_L4PER2_PWMSS1_CLKCTRL) & (0x00030000)) != 0x0);
        /* Time base clock for PWMSS1 module */
        HW_WR_FIELD32(SOC_CTRL_MODULE_CORE_CORE_REGISTERS_BASE +
                      CTRL_CORE_CONTROL_IO_2,
          CTRL_CORE_CONTROL_IO_2_PWMSS1_TBCLKEN, 1);

    }

    /* Configures pinmux for PWM module */
    static void pwmPinmuxConfig(void)
    {
     uint32_t regVal;


        regVal = HW_RD_REG32(CTRL_CORE_PAD_VIN2A_D2_ADDR);
     regVal = ((regVal & ~0x0F) | 0x0A);
        HW_WR_REG32(CTRL_CORE_PAD_VIN2A_D2_ADDR, regVal);

    }


    int APWM_Init(void)
    {

        pwmClockConfig();
        pwmPinmuxConfig();
        ECAPOperatingModeSelect(APWM_BASE_ADDRESS, ECAP_APWM_MODE);
        ECAPOperatingModeSelect(APWM_BASE_ADDRESS, ECAP_APWM_ACTIVE_HIGH);
        ECAPAPWMCaptureConfig(APWM_BASE_ADDRESS, COMPARE_APWM, PERIOD_APWM);
        ECAPCounterControl(APWM_BASE_ADDRESS, ECAP_COUNTER_FREE_RUNNING);

    }

    I look in pin 48 in J21 for the PWM signal, but it doesn't work. However, I see that the register are configured correctly and TSCNT counter is running.

    What am I doing wrong?

    Thanks and best regards,

    Laura

  • Laura Valverde said:
    I look in pin 48 in J21 for the PWM signal, but it doesn't work. However, I see that the register are configured correctly and TSCNT counter is running.

    That signal is routed to both the LCD Backlight as well as the header you mentioned, but at any given time you would select one or the other based off resistor population options:

    • R416: Populated by default.  Routes the PWM to the backlight controller.
    • R853: Not populated by default. Routes the PWM to the J21 header.

    So I see a couple options:

    1. Probe for your PWM on R416. -OR-
    2. Depopulate R416. Populate R853.  Probe J21 pin 48.

    Hopefully that does the trick.  If not, please open a memory window to the eCAP registers and provide the values observed for further analysis.  Your code looked ok as far as I could see, so I'm hoping it's just related to where you're looking for the signal.

    Best regards,
    Brad

  • Hi Brad,

    Thanks again for your help! You were right. When I probe it on R416, I get the PWM.

    One last question, for the EPWMs we could set the TBCLK frequency  in EPWMTBCTL register. In eCAP module, the clock will be the module clock, won't it? The value is 133 Mhz, but how can I obtain it teorically?

    Thanks and best regards,

    Laura

  • You're right that there's no prescaler for the eCAP. However, the eCAP has 32-bit registers for the period and duty cycle, so I wouldn't expect a prescaler to be required unless you needed a period greater than 32 seconds. I'm not sure if I answered your question, so please let me know if I misunderstood what you were asking.
  • Thanks again, Brad. Yes, I wanted to make sure that it was not affected by any prescaler, but I wanted also to ask how can I obtain the value the system clock frequency.

    Best regards,

    Laura

  • Laura,

    For understanding the clocking, I highly recommend using the Clock Tree Tool:

    http://www.ti.com/tool/CLOCKTREETOOL

    From the Cortex A15 running Linux you can run the command "omapconf ctt rd1".  That will generate a file CTT-DRA7xx_ES1.rd1 which can then be imported into the Clock Tree Tool (Save / Load -> Load Registers).  Please start a new thread if you have questions about using the Clock Tree Tool.

    Best regards,
    Brad