Report Bugs Here

Moderator: Mmiscool

User avatar
By Piotr41
#48209 Change the state of the port is a very, very long.

Code: Select allfor i=1 to 100
ow 2 0
ow 2 1
next i


Time change is more than 2ms, why so long?
I need to generate a GPIO course of 50us, and it is not feasible.

01000001001110101000001000110111110001001
Every bit is to have 50us. How to do it?
ESP is set, max speed 160MHz
User avatar
By Mmiscool
#48211 ESP Basic is an interpreter. Bit banging is not going to be that easy.

There are special functions for SPI and i2c if you need a higher speed interface.
User avatar
By cicciocb
#48235 In your case you should use SPI.
If I converted correctly your binary code 01000001001110101000001000110111110001001 corresponds to '8275046F89' in hex. In order to have a bit @ 50us the frequency must be 20 KHz.
You can so use the following functions :
spi.setup(20000)
spi.hex("8275046F89", 5)

The output pin is the MOSI: GPIO13