-->
Page 6 of 6

Re: GPIO sampling speed?

PostPosted: Fri Jan 27, 2017 2:56 pm
by 1314258
marcelstoer wrote:
devsaurus wrote:I guess that there are too many inaccuracies when doing this from Lua.


We've had and example in our repo at https://github.com/nodemcu/nodemcu-firm ... irsend.lua for quite some time but I have no idea whether that still works.


i don't know other people,but i tested it,it doesnot work in my situation.

Re: GPIO sampling speed?

PostPosted: Sat Jul 18, 2020 4:12 pm
by Erhannis
I've lost track of whether we're using Lua or C or what, but this code (C, I believe, compiled from Arduino Studio) yields a ~5.5MHz on/off cycle, according to the oscilloscope that just arrived in the mail.

Code: Select all#define PIN_OUT        D1
#define PIN 1<<5

void setup()
{
  ESP.wdtDisable();

  pinMode( PIN_OUT, OUTPUT );
  digitalWrite( PIN_OUT, LOW );
}

void loop() {
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, PIN);
  GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, PIN);
}