AM2432: AM2432 Sitara MCU Timer Configuration for High Speed GPIO Toggling - Troubleshooting

Part Number: AM2432
Other Parts Discussed in Thread: SYSCONFIG

Hi TI Team,

I want to require clarification on timer's capabilities in terms of speed for toggling GPIO.

Can you specify that how much minimume time i can achieve by timer for toggling GPIO?

Meanwhile, I able to toggle my GPIO at 1us when timer is configured at it's highest values of register.

Kindly provide me the information for the same.

  • Hi Nilesh,

    Meanwhile, I able to toggle my GPIO at 1us when timer is configured at it's highest values of register.

    Is the goal to have time under 1 microsecond?

    There are lot of other factors like, interrupt entry latency, ISR execution and Register write, hence all of these closely contribute to 1 microsecond.

    You could try exploring PWM.

    Kind Regards,

    Vaibhav

  • Is the goal to have time under 1 microsecond?

    Yes. my goal is to achieve 1ns toggling time of GPIO using timer.

    Theoretically, it can toggle with nano seconds timing. However, it's not providing the result in nano seconds.

    Can I achieve it using PRU GPIOs? If yes, then what minimum timing i can achieve for toggling? 

  • Can I achieve it using PRU GPIOs? If yes, then what minimum timing i can achieve for toggling? 

    Hi Nilesh,

    We will respond shortly on the PRU GPIO question.

    Kind Regards,

    Vaibhav

  • Hello Nilesh ,


    The PRU core operates at a maximum frequency of 333 MHz, which corresponds to a cycle time of ~3 ns per instruction.
    • Toggling a PRU GPIO high typically requires one instruction (~3 ns).
    • Toggling the GPIO low also requires another instruction (~3 ns).
    • When the toggle is placed inside a loop, the loop instruction itself adds another ~3 ns per iteration.

    Because each PRU instruction consumes approximately one cycle, any additional instructions in your PRU firmware will further increase the timing proportionally.

    So, the PRU cannot achieve 1 ns GPIO control , since the minimum achievable timing granularity is approximately the instruction cycle time (~3 ns). Therefore, 1 ns precision is not feasible with PRU GPIOs.

    Regards,

    Anil.

  • Hi Anil,

    Thanks for sharing insights regarding to PRU Pins.

    In our application, we are thinking that we can achieve minimum toggling time of pins while implementing PRU-Pins as GPIO. However, based on the provided information, it seems that there is no major difference between Main/MCU Domain GPIO & PRU-PINS in terms of timing.

    Please share your views on the same.

  • Hello Nilesh ,

    However, based on the provided information, it seems that there is no major difference between Main/MCU Domain GPIO & PRU-PINS in terms of timing.

    The PRU core has the capability to toggle the PRU GPIO pins very fast as compared to the MAIN and MCU cores.

    Regards,

    Anil.

  • Hi,

    I have implemented GPTIMER for toggling GPIO (MAIN_DOMAIN) using timer ISR for achieving maximum toggling speed. As a result, I am getting the GPIO Toggling speed of 300Khz when the timer is configured with 25Mhz clock. I have also tried with increase in clock but did not get any result.

    I want to know that does it's the maximum toggling speed of GPIO which i can achieve? If No, then what modification I have to do in sysConfig for Timer or GPIO?

    When I perform GPIO Toggling with Clock tick delay function (available in unseconds), It provide me the speed of 1Mhz approx. However, In GPTIMER, it's not providing the fruitful result.

    Kindly provide your feedback that how i can achieve the maximum toggling speed.

    #include <kernel/dpl/DebugP.h>
    #include <kernel/dpl/ClockP.h>
    #include "ti_drivers_config.h"
    #include "ti_drivers_open_close.h"
    #include "ti_board_open_close.h"
    #include <kernel/dpl/SemaphoreP.h>
    #include <drivers/hw_include/cslr_gpio.h>
    
    SemaphoreP_Object gOverflowSemObj;
    
    uint32_t pinToggle = 0;
    uint32_t gpioAdd;
    uint32_t regIndex, regVal;
    volatile CSL_GpioRegs*  hGpio;
    
    void tickTimerCallBack(void *args)
    {
        //Nothing...
    }
    
    void OverFlowCallbackUser(GPTIMER_Handle handle)
    {
        pinToggle ^= 1;
    
        if(pinToggle)
        {
            CSL_REG32_WR(&hGpio->BANK_REGISTERS[regIndex].SET_DATA, regVal);
        }
        else {
            CSL_REG32_WR(&hGpio->BANK_REGISTERS[regIndex].CLR_DATA, regVal);
        }
        //GPTIMER_setCount(gGpTimerHandle[0], 0xFFFFFFAEU);
    }
    
    void gp_timer_overflow_callback_main(void *args)
    {
        Drivers_open();
        Board_driversOpen();
        gpioAdd = (uint32_t) AddrTranslateP_getLocalAddr(CONFIG_GPIO0_BASE_ADDR);
        hGpio = (volatile CSL_GpioRegs*)((uintptr_t) gpioAdd);
        regIndex = GPIO_GET_REG_INDEX(CONFIG_GPIO0_PIN);
        regVal = GPIO_GET_BIT_MASK(CONFIG_GPIO0_PIN);
        /* Set Tiemr Count to a high value so that overflow can happen sooner */
        //GPTIMER_setCount(gGpTimerHandle[0], 0xFFFFFFAEU);
            /* Start the Timer */
        GPTIMER_start(gGpTimerHandle[0]);
    
        DebugP_log("Overflow Interrupt triggered !!\r\n");
    }


  • Hi Swargam,

    Kindly update on the same.

  • Hello Nilesh ,

    You are currently controlling the GPIO using PWM, which is not the correct method to measure the optimized GPIO toggling time.

    Instead, you can simply call GPIO set-high and set-low functions in a continuous loop. This will give you the actual toggling time of the GPIO pin.
    Please ensure that this test is performed with a Release build.

    From a theoretical perspective, the R5F core takes approximately 0.2 µs to write to a register when R5F core runs at 800MHz.
    Therefore, for a full ON + OFF toggle, you should expect around 0.4 µs of delay.

    Additionally, when using the PRU core, toggling GPIO without any loop overhead takes approximately 0.006 µs when the PRU operates at 333 MHz.

    Regards,

    Anil.