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.

Synchronizing ECAPs on TMS320C6742

Other Parts Discussed in Thread: OMAP-L138, OMAPL138

For the product I'm working on now, we need the three ECAP modules to run on synchronized timers (we need to calculate the time offset between pulses on the inputs).

According to the datasheet we can use the ECCTL2.SYNCI_EN/ECCTL2.SYNCO_SEL setting to daisy chain the sync pulses to all three ECAP modules. When we then set the ECCTL2.SWSYNC on ECAP0 it should propagate to ECAP 1 and 2. I have this implemented in the attached project. But the result is that only ECAP0 loads the CTRPHS register into the TSCTR register. The TSCTR register from ECAP 1 and 2 continue running.

Am I doing something wrong, or is this a bug in the ECAP modules?

EcapTest.tar.gz

  • Hi,

    Thanks for your post.

    To synchronize all eCAP modules with SWSYNC and to know more info. on the same, please refer the below thread which would help you better:

    https://e2e.ti.com/support/dsp/omap_applications_processors/f/42/t/313493

    Thanks & regards,

    Sivaraj K

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

    Please click the Verify Answer button on this post if it answers your question.

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

  • Hi,

    I already saw those posts, but although they have (exactly) the same question as I have (how to sync all ECAPs on a platform), the final answer does not answer my question.  The second post in the thread does only verify that other people have the same problem I have.

    To give an answer to the answer in the other post:

    When you look at the example code I've attached, you can see that I already use the ECAPSyncInOutSelect() function from the C674x starterware:

    ECAPSyncInOutSelect(ECAP0_BASE_ADDR, ECAP_ENABLE_Counter, ECAP_SYNC_IN);
    ECAPSyncInOutSelect(ECAP1_BASE_ADDR, ECAP_ENABLE_Counter, ECAP_SYNC_IN);
    ECAPSyncInOutSelect(ECAP2_BASE_ADDR, ECAP_ENABLE_Counter, ECAP_SYNC_IN);

    Note: The starterware code has a major bug, and you need to apply this patch to get it to work:

    --- a/include/ecap.h
    +++ b/include/ecap.h
    @@ -118,9 +118,9 @@ extern "C" {
     ** signal
     */
     
    -#define  ECAP_SYNC_IN                    (00 << ECAP_ECCTL2_SYNCO_SEL_SHIFT)
    -#define  ECAP_PRD_EQ                     (01 << ECAP_ECCTL2_SYNCO_SEL_SHIFT)
    -#define  ECAP_SYNC_OUT_DISABLE           (10 << ECAP_ECCTL2_SYNCO_SEL_SHIFT)
    +#define  ECAP_SYNC_IN                    (0x0 << ECAP_ECCTL2_SYNCO_SEL_SHIFT)
    +#define  ECAP_PRD_EQ                     (0x1 << ECAP_ECCTL2_SYNCO_SEL_SHIFT)
    +#define  ECAP_SYNC_OUT_DISABLE           (0x2 << ECAP_ECCTL2_SYNCO_SEL_SHIFT)
      
     /****************************************************************************/
     /*
    

    When I have set it up this way, the ECAP0.ECCTL2.SWSYNC only loads the CTRPHS into the TSCTR for the ECAP0 counter, it does not propagate to the other ECAP counters.

    When I look at the code of the example from the wiki, the purpose of the code is to do a difference calculation between rising and falling edges from a signal at ECAP2, for this you don't need to have all timers synchronized.

    Looking at the code, the big difference is that I already have the TSCTR running when setting up the ECAP modules. But when I modifed my example code to to this later on, I still have the same problem -> only ECAP0 sets the TSCTR register.

    Best regards,

    Gerard Bos

  • Hi Gerard,

    Thanks for your update.

    Have you tried PWM pulse instead of SWSYNC to sync the eCAPs? I think, there is an example project for the C6747 eCAP module and in this example the EHRPWM is configured to output a shifting duty cycle which is then read in through the eCAP and If you set a breakpoint inside the ISR you should be able to compare the CAP2-4 values and see them equal each other. Please take this example as a reference and you could use it for OMAP-L138.  

    http://processors.wiki.ti.com/index.php/C6747_eCAP_to_EHRPWM_example

    Please check the ecap driver code at the OMAP-L138 Starterware package and to my opinion, each of the eCAP's can be programmed independantly and you should  see independant waveforms on each channel (APWM0, 1, & 2) which is my understanding.

    Thanks & regards,

    Sivaraj K

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

    Please click the Verify Answer button on this post if it answers your question.

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

  • HI Sivaraj,


    Sorry for the delay. I just tried to generate the SYNC using the PWM module, I'm still trying, but for now, I don't even see that the sync is passed to the ECAP Modules.

    I tried to take a look at the example reference for the OMAP-L138 you gave, but this is using the ECAP in difference mode (on one ECAP). So you don't need/have the synchronised ECAPs.

    Can you take a look at the example I gave and try to figure out why it is not working?

    Thanks, Gerard

  • Hi,

    Thanks for your update.

    I have shared the example which is for C6747/OMAPL137 and if it needs to be used for OMAPL138, you would require code modifications on peripheral_init.c which would require changes in PLL initialization, PINMUX registers and require additional modification to configure the appropriate pins. Have you changed the code for PLL initialization, PINUMX etc. accordingly to work for OMAPL138/C6747?

    peripheral_init.c file is responsible for the following:

    Configuring the PLL

    Powering up the necessary peripherals (PSC0 and PSC1)

    Configuring the necessary pins (PINMUX)

    Enabling up interrupts (IER)

    Initializing EHRPWM0

    Initializing eCAP2

    if you are planning to plug this code to another EVM platform like OMAPL138, you need to take care of the above configuration appropriately to the respective hardware platform.

    Please ensure the above configuration which would make the example work for the respective EVM board for sure.

    Note; Each function to configure the above needs to be called only once at system startup

    Thanks & regards,

    Sivaraj K

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

    Please click the Verify Answer button on this post if it answers your question.

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

  • Hi Sivaraj,

    Sorry for the delayed answer.

    I don't have an EVM board available (not for OMAPL138 or the C6747). I only have the device where the C6742 is placed onto.
    Secondly I still don't see the solution for my problem in this example code, as I can synchronise one eCAP module, but I can't synchronise all three together.

    Best Regards,
    Gerard
  • Hi,

    Try modifiying the shared example code to adapt it for C6742 platform from C6747 which would require PLL initialization, PINMUX registers and require additional modification to configure the appropriate pins.

    The above example would be the appropriate benchmark to synchronize all three eCAP modules.

    Thanks & regards,
    Sivaraj K