So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Phil333
#70664 I am building something with a stepper motor and use a DRV8825 to drive it by using the Arduino IDE.

I observed that the movement is not smooth with my ESP8266 (WeMos D1 mini - not tested any other Microcontroller so far) and I am now down to the basics.

The first step is now to make the digital write faster.
The pin I use for it is D0 (IO16).
If I do a simple
Code: Select allvoid setup()
{
  pinMode(16,OUTPUT);
}
void loop()
{
  digitalWrite(16,HIGH);
  digitalWrite(16,LOW); 
}


the fastes time to go from LOW to high is 900ns (1,11MHz).
This is pretty low!

I url=http://www.esp8266.com/viewtopic.php?p=37907]read[/url] that the digitalWrite() is already "well optimized", but on a 80MHz Microcontroller it should be A LOT faster than 1,11Mhz.

I already check the fastes possible speed on an Arduino Nano (16MHz clock speed) and this gave me a 16,5MHz puls frequency...
So its 16 times faster on a 5 times slower chip. (so this is top notch optimized and sets the pins every clock)

The Maple Mini (STM32) gave me 37MHz at the fastes write options and the ESP8266 should be in the same range - even if these 37MHz are also bad compared to the Arduino performance ;)

So: How can I make the ESP8266 to set the digital pins faster?

Thanks a lot in advance!
User avatar
By Phil333
#70678 @jarnoldbrown: very helpful comment for my issue :D
Measurements with 2 good oscilloscopes can't lie. To help you out in this situation, think about this: the rated clock speed is 16MHz but the on-board crystal is inaccurate and give in my case a higher clock.

Back to topic: how can I make the output faster?