As the title says... Chat on...

User avatar
By raz123
#8805 I am sampling the GPIO pin to monitor the data on a external line. The line is driven at around 1 Mhz.
Given that the ESP runs at 80 Mhz, one would think that there is plenty of room for collecting all that passes through it.

However, after some testing with very limited tools, it seems that the GPIO sampling is incapable of being faster than a few Khz. Can someone else test this on their side?

You could use a square signal generator, feed it into, say, GPIO4 and run something like this in your preferred terminal application (I used LuaLoader):

Code: Select allgpio.mode(4, gpio.INPUT, 0)

for loops = 1,10 do

   memory = loops
   tmr.wdclr()
   
   for count = 1,1024 do
      memory = memory .. gpio.read(4)
   end

   print(memory)

end

print("Done.")
User avatar
By RichardS
#8806 I am thinking if you sample a pin in 100% LUA interpreted code, then yep, its going to be slow......

I did a C interpreter once and yep, it too slow! on 100Mhz ARMS!

Richard.
User avatar
By raz123
#8811 Yeah, I can't believe how slow this is.

The fastest I was able to get it going on GPIO output was 5.172 KHz.. for a 80 Mhz device, that's a huge order of magnitude of terrible. Even the Arduino platform blows it out of the water.

Image

This was accomplished running a simple loop:

Code: Select allgpio.write(4, gpio.HIGH)
gpio.write(4, gpio.LOW)


I wonder how faster it could get if done in C.

If someone has a way of getting this to process faster, please let me know!

EDIT: Seems like Markus Gritsch has already covered this here: viewtopic.php?f=24&t=832

By using the following, the speed can be bumped to 9.748 kHz:

Code: Select allgpio.write(4, 1)
gpio.write(4, 0)


Sad :(
User avatar
By RichardS
#8812 In pure C tight loop in AVR maybe 1Mhz
using Arduino calls to their API maybe 250khz
on 80Mhz 32 bit platform... maybe 10-20Mhz
and interpreted 10Khz lucky :-) there is too much overhead, way too much!

Again this is approx from my life experience :-)

Richard.