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.

TMS320F280039C: Sysconfig produces code that is incompatible with Synchronizing PWMs

Part Number: TMS320F280039C
Other Parts Discussed in Thread: SYSCONFIG

I used sysconfig and enabled TBCLKSYNC in the SYSCTL section.  I expected this to synchronize the PWMs but it did not.  The problem is that in the generated board.c file, the SYSCTL configuration happens BEFORE the EPWM configuration.  In the documentation (which is apparently correct) the TBCLKSYNC must be disabled while the EPWMs are configured and then enabled after the configuration. When you use Sysconfig, this does not happen so the EPWMs are not synchronized.  It took a long time to figure that out!

I fixed the problem by disabling the TBCLKSYNC in the SYSCTL and used the following code:

  Board_init();

  //
  // To synchronize the PWM units you MUST disable TBCLKSYNC in the SYSCTL section of Sysconfig
  // Then the PWMs get configured in Board_init()
  // Now we must enable TBCLKSYNC below.
  // Enable sync and clock to PWM
  //
  SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

I think this is a bug in SYSCONFIG.  If not, it should be easier to find the issue.  I even tried this code from the example code but it fails to do anything if TBCLKSYNC is already on in SYSCONFIG -- it breaks the example.

    // Disable sync(Freeze clock to PWM as well). GTBCLKSYNC is applicable
    // only for multiple core devices. Uncomment the below statement if
    // applicable.
    //
    // SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_GTBCLKSYNC);
    SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

    //

    // Configure GPIO0/1 , GPIO2/3 and GPIO4/5 and GPIO6/7 as
    // ePWM1A/1B, ePWM2A/2B, ePWM3A/3B, ePWM4A/4B pins respectively
    // Configure EPWM Modules
    // 
    Board_init();

    //
    // Enable sync and clock to PWM
    //
    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

Regards

  • Hello Neil,

    The enable buttons only runs the specific enable function without accounting for sequencing. The functionality of enabling TBCLKSYNC with the Sysconfig doesn't account for conflicts with peripheral initializations in the later part of the code.
    If the peripheral initialization happens after board_init() user needs to account for the settings done within board_init().

    I agree that user standpoint you are expecting to enable TBCLKSYNC and sysconfig to take care if all initialization. I will forward your query with the team that handles sysconfig for improvement.

    Thanks,
    Prarthan.