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.

PROCESSOR-SDK-AM62A: Is it possible to get fixed number of pulse?

Part Number: PROCESSOR-SDK-AM62A

Tool/software:

Hi,

I am using a display which power IC required a init sequence. In the sequence, I have to give first 82 pulse of width 20us and after sometime second 24 pulse of width 20us to produce required voltage levels on the display's voltage bus.

I tired normal GPIO to toggle at that much speed which I couldn't. The least it can go is 200us and not below that.
I am think of using PWM pins. my question is,
1. Is there any way to control PWM signals upto few counts?
2. Is there any way to toggle high and low to that pin?

  • Hi Sathiyan, Let me check and come back to you soon.

    Thank you,

    Paula

  • Hello Sathiyan,

    Requirement :

    • First: 82 pulses, each width is 20usec .

    • After a delay, second: 24 pulses, also width is 20usec .

    Solution :

    We need to consider EPWM/TIMER PWM to solve this requirement. 

    • Configure the PWM to run at 50 kHz (period = 20µs) and generate an interrupt for every period.

    • Set the duty cycle as needed (e.g., 99% = 19.8µs HIGH, 0.2µs LOW)

    Control Number of Pulses :

    • Start the PWM

    • Use an interrupt to count output pulses

    • After 82 or 24 pulses, disable the PWM or set the output LOW

    Please let me know if the above method works for you .

    Regards,

    Anil.

  • Hi Swargam,

    Thank you for your guidance.

    Is there any implementation example for this?
    Primarily in kernel drivers, and also in userspace.

  • Hi swargam and Paula,

    Any update on this?

  • Hello Sathiya Narayanan,

    I am routing your query to Linux expert and I and Paula are experts on the RTOS/NO RTOS side.

    Regards,

    Anil.

  • Hi Nick,

    The above guide just says about how to use PWM.

    My question over here is, 

    Solution :

    We need to consider EPWM/TIMER PWM to solve this requirement. 

    • Configure the PWM to run at 50 kHz (period = 20µs) and generate an interrupt for every period.

    • Set the duty cycle as needed (e.g., 99% = 19.8µs HIGH, 0.2µs LOW)

    Control Number of Pulses :

    • Start the PWM

    • Use an interrupt to count output pulses

    • After 82 or 24 pulses, disable the PWM or set the output LOW

    How to generate n specific number of pulses and stop PWM? Swargam suggested that, I can generate an interrupt to count output pulses and stop at exactly based on my count. How to do that?

    You can guide me in kernel space also, if user space doesn't provide extra controls of PWM

  • Hello Sathiya,

    Setting Support expectations

    We can answer questions about TI hardware and TI software on these forums, but we cannot support questions about writing custom code. I will not be able to help you write a custom Linux driver to interface with this display.

    Does the manufacturer of the display provide a driver to use with their peripheral?

    A discussion on Linux & RTOS

    Anil & Paula were commenting from the perspective of controlling the PWM from the MCU R5F core. From that context, it could make sense to write dedicated code that counts interrupts that are generated every 20 usec, and then disables the PWM after a certain number of interrupts.

    However, Linux cannot operate with such tight time constraints. Just the interrupt response latency for Linux to stop what it is currently doing and switch contexts to handle an interrupt will often go above 20 usec.

    For more details, please refer to AM62Ax academy > multicore > Operating Systems
    https://dev.ti.com/tirex/explore/node?node=A__AcXUebjrS-3qRLoqvS66-A__AM62A-ACADEMY__WeZ9SsL__LATEST

    Any tools to count PWM pulses in the PWM hardware? 

    I did take another look through the TRM chapter, but I do not see any "pulse count" elements in the PWM.

    The closest I could see was the chopper - perhaps the PSCLK frequency could be set to 20 usec, and then the chopper waveform could be set to be wide enough that 82 or 24 pulses were generated before the PWM signals were driven low? But as far as I am aware, we have not enabled any of those features in the existing Linux PWM drivers.

    Regards,

    Nick

  • Hi Nick,

    we cannot support questions about writing custom code

    My question is primarily about TI hardware itself and how to enable the feature in driver if hardware supports.

    But as far as I am aware, we have not enabled any of those features in the existing Linux PWM drivers.

    Now that I understood by Linux it is not possible, I need guidance to enable the same in MCU R5F side.

    Meanwhile, if you are ready to help in AM62A side, how to do the same with chopper, I can make the Linux driver as I have setup to test also. Then I can provide the code which TI can also use in the future release.

  • Hello Sathiya,

    Please tell us more about how these signals connect, and how they will be used during runtime.

    What interface are these pulses getting driven to? The display backlight? The display's data interface? Are these some dedicated signals that are only driven during initialization, and not at any other point in time?

    How will you be interacting with the display during runtime? From Linux? From somewhere else?

    It might be more trouble than it is worth if the "optimal solution" is doing some interaction with the display from Linux, and some interaction with the display from the MCU R5F. Each peripheral interface can only be controlled by a single software instance, so you can't do something like drive display output from both Linux and MCU R5F.

    If this display does not come with Linux support, and if you will be driving the display from Linux, another consideration would be to select a different display that does not have the same real-time requirements as this one.

    Regards,

    Nick

  • Hello Nick,

    What interface are these pulses getting driven to? The display backlight? The display's data interface? Are these some dedicated signals that are only driven during initialization, and not at any other point in time?

    I am using the MP5611 triple-output power supply IC, where the number of input PWM pulses sets output voltages for the display. If extra pulses are sent (e.g., +10), the voltage may exceed the display's limit, risking damage.

    For prototyping, I am generating pulses via user-space PWM with a busy-wait loop for N × pulse_width time. Due to timing inaccuracy, I am using an offset ((N - OFFSET) × pulse_width), which gives results close to target but still varies by ±2 pulses — acceptable but unreliable for production. Sleep functions were worse.

    Thats why I am looking for a hardware-based solution to ensure precise pulse count and timing for production reliability.

    only driven during initialization, and not at any other point in time?

    Yes, only during initialization and suspend-resume cycles

    Each peripheral interface can only be controlled by a single software instance, so you can't do something like drive display output from both Linux and MCU R5F.

    Only the linux will use the display with simple panel driver and it is working smooth once the voltages are proper. The power sequencing is the only trouble here.

    Approach 1: Make MCU R5F generate only accurate pulse on the pin and linux do the IPC,
    Approach 2: Make linux driver to interact with the system registers and get the work done (using chopper way)

    I prefer approach 2 as it solely depends on linux.

  • Hi Sathiya, for Approach 1 you can use steps suggested by Anil. Let us know if you face any issues there. Or, if you need any assistance with IPC. If so, maybe better to open another thread where you share this link as context.

    For approach 2, our expert is currently in a business trip so replies might be delayed.

    thank you,

    Paula

  • Hi Paulo & Nick,

    My requirement of generating fixed pulse is solved by making the logic in Linux kernel driver.

    Kernel space is capable of generate timing with accuracy of microseconds. Thank You.

  • Great! thanks for letting us know

    Paula

  • Hello Sathiya,

    If your application is ok with pulse widths that are occasionally in the hundreds of microseconds range, then I would expect RT Linux is probably fine. You would want to set your priorities so that the code driving the PWM had higher priority than the other software running.

    When Linux has a lot of other threads trying to run on the same core, keep in mind that it is not uncommon for regular Linux to go into milliseconds of delay.

    Regards,

    Nick