-->
Page 1 of 2

Very Slow GPIO

PostPosted: Sun May 29, 2016 9:03 am
by Piotr41
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

Re: Very Slow GPIO

PostPosted: Sun May 29, 2016 9:34 am
by Mmiscool
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.

Re: Very Slow GPIO

PostPosted: Sun May 29, 2016 9:43 am
by Piotr41
I2C is a good idea, thanks

Re: Very Slow GPIO

PostPosted: Sun May 29, 2016 4:56 pm
by cicciocb
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