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.

TM4C1294NCPDT: GPIO read time

Part Number: TM4C1294NCPDT

Hi,

In one of the application I require time measurements so, for that to check controller suitable or not, i need time for reading a gpio pin, or no of. clock cycles required to read a digital input. Peresent;ly my system clock is 120Mhz, by using PLL.

PSFLT=GPIOPinRead(GPIO_PORTK_BASE,GPIO_PIN_4);

Please help

Regards

Khodidas Domadiya

  • Hello Khodidas,

    Do you need to read the total high (or low) time of a signal? If so we have a timer example which would do that in TivaWare: timer_edge_capture

    That would remove the need for knowing the clock cycles.

    As far as the answer goes, that depends on how the pin is being read. You would need to see how many lines of code are being executed first. If the timer does not work, this might be one of the rare cases you would benefit from DRM code so you can bypass the TivaWare APIs which will add clock cycles.

    Best Regards,

    Ralph Jacobi

  • Hi, Ralph,

    as I need to read simple gpio and similarly about 30 gpio read but as we have time constrains in application and that need to be scanned for  8 time and the data is to be transferred over ethernet, it also includes data read from other 10 devices via uart, and all this things require tobe finished within one millisecond, so to check every constrain it is mandatory to know simple gpio status by reading a pin.

    Regards

    Khodidas

  • Hello Khodidas,

    So in general each instruction takes 8.33 ns to execute assuming the system clock is running at 120 MHz, so it would boil down a bit to how efficient you can get your code to be on execution. Using TivaWare vs DRM would have different results. DRM vs assembly might too because DRM still simplifies the code from just raw assembly.

    Another element is that depending on the instruction, it may take more than one clock cycle to execute. See: Cortex-M4 instructions

    For TivaWare GPIOPinRead there would be overhead like the Assert check, and also just how the function would pass the variable down the line instead of having a hard coded check:

        //
        // Check the arguments.
        //
        ASSERT(_GPIOBaseValid(ui32Port));
    
        //
        // Return the pin value(s).
        //
        return(HWREG(ui32Port + (GPIO_O_DATA + (ui8Pins << 2))));

    Ultimately you will need to assess how granular you need to get with the code and then count the cycles of the code you end up using for this purpose in order to understand that element. 

    Best Regards,

    Ralph Jacobi