AnsweredAssumed Answered

Kinetis fast IO operations?

Question asked by Charles Zimnicki on Feb 18, 2015
Latest reply on Feb 19, 2015 by Mark Butcher

This may be a basic questions but I am new to Kinetis and KDS. I am trying to migrate an 8-bit project with critical IO timing. To establish a baseline, I tried few tests with FRDM-K22F running at 120MHz and max other clock speeds. First, I started with using their APIs (just because it was super simple). I wrote a very simple loop flipping a couple of pins using DigitaOut(). To my surprise, the shortest period per IO operation was something on the order of 550ns. Then, (after quite a bit of struggle to set up KDS) I wrote a similar program using Processor Expert setup, switching pins with GPIO_DRV_ClearPinOutput() and GPIO_DRV_SetPinOutput(), again running at maximum achievable frequencies. And again, I got a similar result, over 500ns per operation. Then I performed a third test, using direct register access to IO pins. Finally, I was able to get an IO period of about 30ns - something I would expect from a part running at 120MHz.


My questions are very basic. If I want a "normal" IO speed, am I stuck trying to figure out how to write directly to registers? I can understand why the library functions have overhead, but over a magnitude slower? I know I can use peripherals for PWM, communications, etc, but unfortunately I need just rudimentary, fast IOs for this project. Any links to examples with fast IO would be very appreciated.