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.

TMS320F28062: Can I cut a position compare output pulse short?

Part Number: TMS320F28062


I am trying to use the position compare output feature of the EQEP unit to output a pulse that rises at one position compare, and falls at a different position compare.  I can see the output pulse, and have configured an interrupt handler for the position compare event -- these work fine.  While setting up the second position compare, I configure the output pin as GPIO output.  This was more difficult than it should be because the state of the pin is not reflected by the GPADAT register, but it now works.

After setting up the second compare, I have to configure the pin as EQEP again, but *after* the pulse is over.  Waiting is awkward: Either I have to busy wait, or I have to schedule a timer interrupt to do the work.  Ideally there would be a way to stop the output pulse under software control.  Changing the pulse width in QPOSCTL does not do the trick, is there any other solution?

Failing a way to short circuit the pulse, is there any way to determine that it is over?

  • Hi Radey,

    Could you share some code snippets you have for this use case? I am not understanding the configuration completely.

    Are you using an eQEP signal as your output signal, PCSOUT in the TRM (can be index or strobe pin), or just a regular GPIO to generate your output pulse? PCSPW in the QPOSCTL register will only have an effect if using the eQEP signal PCSOUT.

    Based on the below, it sounds like it'd be better to use a regular GPIO not attached to the eQEP module and set it high/low in an interrupt.

    Radey Shouman said:
    I am trying to use the position compare output feature of the EQEP unit to output a pulse that rises at one position compare, and falls at a different position compare.  I can see the output pulse, and have configured an interrupt handler for the position compare event -- these work fine.

    Best,

    Kevin

  • snip.asmHi Kevin,

    I have attached a snippet of asm code.  Unfortunately it does not have all the definitions needed to actually assemble it, but perhaps it will give an impression.

    I am using the strobe pin as an eQEP output.  I have a requirement for less than 100 ns (8 cycles) from position match to rising edge of the output signal, so using an ISR to toggle a GPIO is not workable.

    The idea behind the code attached is that an eQEP output pulse is used to generate the edges, and the ISR turns the eQEP pin into a GPIO before the end of the pulse, then busy waits until the pulse is over to turn the pin back into an eQEP pin.  I would like to eliminate that busy wait.

    regards,

    Radey

  • Hi Radey,

    OK, I think I have a decent understanding of what you're trying to accomplish. Is the method you are currently using working and you're just wondering if there's a better way? I'll need to get back to you regarding if there's a better way to accomplish this, as it isn't a common use-case (or at least I haven't come across it before).

    Toggling a GPIO in an ISR seems ideal, but you're right that your latency requirement would likely not be met.

    Are you wanting your compare value to be the same when the output rises/falls (i.e. toggles at a set compare value)? Or do you have it rise at one compare value and fall at a completely different compare value?

    Best,
    Kevin
  • Hi Kevin,

    I am not happy with the method I am currently using, because it is too sensitive to my estimate of the maximum interrupt latency.  Because of the behavior of the GPADAT register, I am not able to detect timing failures, so I cannot test my implementation under typical use conditions without some pretty fancy external test equipment.  So, yes, if there is a better way I would like to hear it.

    The compare values for rise and fall will in general be different.

    The main source of the heartburn was a requirement that a minimum time of 10 us between rise and fall be possible, in a system that is using most of the available processor cycles already.  The customer has since relaxed this requirement, to the point that I believe I can handle some of the hardware re-configuration in a periodic ISR.

    However, if this compromise isn't necessary it would be good news.

    Thank you,

    Radey

  • Hi Radey,

    I spoke with my colleague on your use case to help brainstorm some ideas. We see the three below options if you are needing to meet the strict latency requirement:

    1. Use your current method, switching between a GPIO and eQEP output.

    2. Use your current method, but use the CLA if you're wanting to save some CPU bandwidth. The CLA has access to the eQEP on F2806x:

    3. Use the ePWM Trip-zone module to set an output high/low. Have the eQEP create a short sync output pulse that is connected (externally) to the ePWM's trip-zone, which would set an ePWM output high/low when it receives a pulse. This will take up some more resources, ePWM module and external connections, but should meet your latency requirement.

    Best,

    Kevin

  • Hi Kevin,

    Thanks for the effort you have put into this, it is appreciated.

    The application is a board that is already in some of our customers' customers' hands, so upgrading to a chip with CLA or making changes to the pinout is not practically possible.  The problem has been dealt with by allowing a longer period between the rising and falling edges, meaning that some of the work may be done in regularly scheduled ISRs.

    I'll mark the issue resolved.

    best regards,

    Radey Shouman