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.

AM6442: How to latch QPOSCNT simultaneously on two eQEP modules using ePWM ADCSOCA as STROBE on AM64

Part Number: AM6442
Other Parts Discussed in Thread: SYSCONFIG,

Tool/software:


Hi,

I'm working on an AM64x-based system and would like to latch the position counter (QPOSCNT) of two eQEP modules simultaneously using a periodic signal generated by ePWM.

Here's what I'm trying to achieve:

  • Generate a 10Hz pulse using ePWM.
  • Use ADCSOCA from ePWM as an internal trigger.
  • Route this ADCSOCA signal to both eQEP0 and eQEP2 as their STROBE input.
  • Configure both eQEPs to latch QPOSCNT on the rising edge of the STROBE signal.

I believe the following API calls are relevant:

      EQEP_setStrobeSource(baseAddr, EQEP_STROBE_OR_ADCSOCA);
      EQEP_setLatchMode(baseAddr, EQEP_LATCH_STROBE_RISING);


My questions:

  • Is it valid to use the same ePWM ADCSOCA signal as the STROBE source for multiple eQEP modules?
  • Are there any limitations or considerations when doing this on AM64x?
  • Could you provide guidance or an example on how to configure this using SysConfig?
  • Do I need to configure any crossbar or internal routing explicitly, or is this handled automatically?


Any help or example projects would be greatly appreciated!

Thanks in advance.

  • Hi Miyako, some answers/comments below

    Is it valid to use the same ePWM ADCSOCA signal as the STROBE source for multiple eQEP modules?

    Yes, it is a valid option.

    Are there any limitations or considerations when doing this on AM64x?

    There are no specific limitations. However, it's essential to ensure that the ePWM and eQEP modules are properly configured and that the ADCSOCA signal is correctly routed to the eQEP modules.

    Could you provide guidance or an example on how to configure this using SysConfig?

    Unfortunately, you will need to do EPWM's and EQEP's SOCA configuration outside of SysConfig as we don't have it currently enabled

    Do I need to configure any crossbar or internal routing explicitly, or is this handled automatically?

    In general, if you select EPWM SOCA as the strobe source for eQEPs modules, and after configuring CTRLMMR_SOCA_SEL to point to EPWM0_ADCSOCA I believe we should be ok. However, let me double check, if we need to call any specific API.

    Thank you,

    Paula

  • Hi Paula,

    Thank you very much for your detailed explanation.

    I'm just getting started with the AM6442, so I'm still not very familiar with how to configure things properly.
    Do you happen to have any sample code that demonstrates this setup?

    Also, could you please guide me on how to configure EPWM0, ADCSOCA, EQEP0, and EQEP2 for this use case?
    A step-by-step explanation or example would be extremely helpful, as I'm still learning how to work with this device.

    I would really appreciate your guidance on the API usage as well.

    Best regards,

    Miyako

  • Hi Miyako, please allow me few days as I would need to check documentation and consult with colleagues.  

    thank you,

    Paula

  • Hi Paula, 

    Thank you for looking into it. I understand it may take some time, and I really appreciate your effort.

    I’d really appreciate it if you could share anything you find out along the way, even if it’s only partial. Since I’m not very familiar with this AM64, it takes me some time to fully understand things.

    regards

    Miyako 

  • Hi Paula, 

    I just wanted to follow up—it's been about 9 days since I received the message saying to wait a few days, so I was wondering if there might be any updates.
    I'd really appreciate it if you could let me know when you have a chance.

    Thanks again!

  • Hi Miyako, sorry for the delay, I will come back to you by tomorrow

    thank you,

    Paula

  • Hi Miyako, let me go one by one your requirements.

    1) Generate a 10Hz EPWM signal.

    For this I would suggest you use example from MCU+SDK as a starting point. AM243x MCU+ SDK: EPWM Duty Cycle

    One cavate it that currently our selection for scalers is not the correct/optimal one for low frequencies. Our developers are working on that and this will be fixed in a future MCU+SDK release.

    For now, just FYI: [EXT_SITMPUSW-81] MCU+ SDK: EPWM_tbTimebaseClkCfg does not choose the optimal pre-scaler combination - Software Issue Report (SIR) 

    One solution is to use maximus hspClkDiv and lspClkDiv values to ensure TBPRD is not overflowing 16-bit as explained in below E2E:MCU-PLUS-SDK-AM243X: ePWM inaccuracy at low frequency? - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums

    Another solution is to get the optimal values as a customer posted here:  AM6422: MCU+ SDK: EPWM: EPWM_tbTimebaseClkCfg does not choose the optimal prescaler combination - Processors forum - Processors - TI E2E support forums

    I will post later information with respect to the other points.

    thank you,

    Paula

  • 2) Use ADCSOCA from ePWM as an internal trigger

    We don't have API's in our MCU+SDK for configuring SOCA, but mainly the ideas to setup below registers


    EPWM_ETSEL[SOCAEN] =1 to enable SOCA output
    EPWM_ETSEL[SOCASEL] 2h to enable event time-base counter equal to period (PRD_eq event)
    EPWM_ETPS[SOCAPRD] = 1h: to generate pulse on SOCACNT = 1 (1-st event)


    below few screenshots from our TRM with some additional information.

    AM64x/AM243x Technical Reference Manual (Rev. H)

    Also, as a reference, in below E2E there is an example API's for SOCA configuration created by a customer: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1489966/am620-q1-how-to-implement-m4f-control-epwm-soca-pulse-output-function-on-am620/5777323#5777323 

    Thank you,

    Paula

  • With respect to:

    3) Route this ADCSOCA signal to both eQEP0 and eQEP2 as their STROBE input.

    4) Configure both eQEPs to latch QPOSCNT on the rising edge of the STROBE signal.

    You can use EQEP example from MCU+SDK as a starting point AM64x MCU+ SDK: EQEP Capture

    API's you pointed out should work for your use-case

    EQEP_setStrobeSource(baseAddr, EQEP_STROBE_OR_ADCSOCA);
    EQEP_setLatchMode(baseAddr, EQEP_LATCH_STROBE_RISING);

    Additional information TRM: AM64x/AM243x Technical Reference Manual (Rev. H)

    Thank you,

    Paula

  • Hi Paula, thank you for your helpful response.

    I understand that the current scaler selection may not be optimal for low frequencies like 10Hz. I haven’t tested it yet, but I’m considering using a slightly higher frequency, such as around 60Hz, to see if it works more reliably with the current SDK.

    * Is there a known minimum frequency threshold above which the ADCSOCA trigger and eQEP strobe latch work reliably?
    * Are there any recommended workarounds or manual scaler settings that could improve behavior at lower frequencies?
    * Would it help to use a different ePWM module or clock source?

    I’d appreciate any guidance or suggestions you might have. Thank you again for your support!

  • Hi Miyako, 

    * Is there a known minimum frequency threshold above which the ADCSOCA trigger and eQEP strobe latch work reliably?

    I am not aware of any test done in this front so no sure

    * Are there any recommended workarounds or manual scaler settings that could improve behavior at lower frequencies?

    You can try to use maximum hspClkDiv and lspClkDiv values and see if it works ok for you

    Also, a customer posted his solution for finding optimal dividers in case you want to take a look:

    AM6422: MCU+ SDK: EPWM: EPWM_tbTimebaseClkCfg does not choose the optimal prescaler combination - Processors forum - Processors - TI E2E support forums

    * Would it help to use a different ePWM module or clock source?

    Changing EPWM shouldn't help. About changing source clock I see this API SOC_moduleSetClockFrequency() However, I need to confirm if function could be used to change ePWM's clock module

    AM64x MCU+ SDK: APIs for SOC Specific Functions --> SOC_moduleSetClockFrequency()

    thank you,

    Paula

  • Hi Paula, Thank you for your continuous supports.

    When connecting a signal from ePWM via SOCA to the eQEP STROBE input, is it okay not to assign any physical pin for the STROBE signal(as shown in the picture below)?

  • Hi Paula, 

    Thank you again for your previous response. I have a follow-up question regarding the EPWM → SOCA → EQEP routing on the AM6442.

    I have configured EPWM to generate a SOCA pulse, and since EPWM_ETFLG.bit2 is set, I believe the SOCA pulse is being generated correctly.

    However, the system is still not working as expected. I suspect the issue may lie in the routing or ADC configuration.

    Could you please clarify the following points?

    1. If I do not need to use the ADC conversion result, is it still necessary to configure the ADC module (e.g., prescaler, mode, enable) just to use it as a trigger path?

    2. Is it necessary to configure CTRLMMR_ADC0_CTRL.TRIG_SEL or any other CTRLMMR settings? If so, could you please explain how to configure them properly?


    Additionally, I have a related question:

    3. In my use case, I’m using the SOCA signal from EPWM to latch QPOSCNT on both eQEP0 and eQEP2 simultaneously.
    Given this setup, how synchronized are the two latches expected to be?
    Can I assume near-simultaneous capture(within one clock cycle?, or several clock?), or is there any measurable delay between them? 

    Any explanation or example code would be greatly appreciated.

    Best regards,

    Miyako 

  • Hi Paula, 

    I’ve successfully configured the system to output an SOC signal from the EPWM module and connect it to the STROBE input of both EQEP modules. 

    Currently, I want to verify whether the latching timing of the two EQEP modules is truly synchronized. However, I’m not sure how to confirm this directly. As a workaround, I’m comparing the times of the interrupt service routines (ISRs) triggered by each EQEP. While this gives me a rough idea that the latching is synchronized, it’s not precise enough.

    If there is a way to directly verify the actual latch timing instead of relying on ISR timing, I would greatly appreciate any advice or recommended methods.

    I apologize for asking again. I previously posted several questions. I still trying, so any guidance would be very helpful. Thank you for your time and support. 

    regards

    Miyako 

  • Hi Miyako, Sorry I missed your previous post, I am glad you were able to successfully configure the system to output an SOC signal from the EPWM module and connect it to the STROBE input of both EQEP modules.

    Now, with respect to how to verify latching synchronization between EQEPs, one idea could be to use the same encoder connected to both eQEPs and then capture EQEP_QPOSSLAT for both eQEPs. This would help you to calculate any differences between them. Ideally, both EQEP_QPOSSLAT should be the same or with ~same offset.

    Also, probably you want to use the encoder at a constant, relatively high resolution in order to ensure QPOSCNT values are changing continuously and fast (this should help to get more distinct counts).

    I hope this helps.

    Paula

  • Thank you very much for your helpful response.


    By the way, regarding the performance of the eQEP module — if the A/B/Strobe inputs are exactly the same for both eQEPs, is it correct to assume that the latching will occur at exactly the same timing?

    In other words, would the difference between the two position count values(QPOSLAT) be within less than one eQEP clock cycle?

  • Miyako, I am confirming with some experts, but that is my understanding.

    thank you,

    Paula