GPIO toglgle freq. is 1Mhz. Why?

i’m toggling gpio in while(1), which gives me output as 1Mhz freq.
But Colibri iMX7 have 1Ghz Processor.
How can i achieve full potential?
Or am i missing something?
I’m using gpio demo(C++).
Thanks in advance.

Dear @akshykhade

There’s two major factors which impact the maximum GPIO toggle frequency:

  1. The Gpio library is optimized to be generically usable. If you want to optimize the performance, use the Gpio library only for initializing the Gpio parameters. For the actual toggling, look up the Colibri iMX7 reference manual to find the relevant register address and register bit.
    Then toggle the releavant bit directly without the Gpio Lib, using register mapping with the MapMem library.
    I recommend to avoid read-modify-write operations, but use writes only instead (because of point 2. below).
    However, you must assure that writing does not modify any bits which need to stay untouched!
  2. The GPIO registers are connected to a peripherals bus which is much slower than the 1GHz CPU speed. You are probably aware that RAM access is also slower (that’s what cache memory is used for). The same is true for peripherals,
    The peripherals speed is given by hardware, there’s no way to overcome this physical limitation.

Regards, Andy

Thanks for explanation.
Actually i want use 16 bit ADC(4 channels).
i was checking how fast can i sample on WEC(in C++ ofcource).
should i prefer SPI to achieve 200ksps?
or do i have to code on M4 in freertos?

thanks in advance.

Dear @akshykhade,

This is a new topic to discuss. As per our community rules, could you create another ticket with a detailed explanation?
Also, you can check our developer documentation and our community forum where we already documented for the same topic or we might have answered other questions same questions e.g.:, that would help you.

Thank you.

thank you.