Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By rudi
#7318 hi
i have a play with spi and i take the bit banging method.
i use
GPIO 12 as MOSI
GPIO13 as MISO
CLK as GPIO5
CS as GPIO4
and maked as software spi as channel #2
i combinied this for playing next time with lcd and other doing.
here a little video from my play.
viewtopic.php?f=15&t=1255
my way is to make this next time in i2c too and ovelay spi and i2c by manageing this in fw.
next steps are sd card in micro form.
a next doing thing is a esp8266 as "slave" with other esp8266 for test in nodes and data transfer rate - only a test ;-)

best wishes!
rudi ;-)
User avatar
By alonewolfx2
#7344 I saw your video and there is no code again :)

rudi wrote:hi
i have a play with spi and i take the bit banging method.
i use
GPIO 12 as MOSI
GPIO13 as MISO
CLK as GPIO5
CS as GPIO4
and maked as software spi as channel #2
i combinied this for playing next time with lcd and other doing.
here a little video from my play.
viewtopic.php?f=15&t=1255
my way is to make this next time in i2c too and ovelay spi and i2c by manageing this in fw.
next steps are sd card in micro form.
a next doing thing is a esp8266 as "slave" with other esp8266 for test in nodes and data transfer rate - only a test ;-)

best wishes!
rudi ;-)
User avatar
By rudi
#7355
alonewolfx2 wrote:I saw your video and there is no code again :)


hi mehmet,

yes.. because i do my homework day for day for me ;-)
this is my hobby -

all can read and learn:
SPI / SD / MMSC
https://www.sdcard.org/downloads/pls/si ... t1_410.pdf
https://www.sdcard.org/downloads/pls/simplified_specs/

here are the GPIO register
http://bbs.espressif.com/viewtopic.php?f=7&t=112

here spi examples
http://bbs.espressif.com/viewtopic.php? ... 7fdfd00706

and all to do is combine this
;-)
ESP8266 is only a µC likewise AVR or PIC or other -
ok - more function - but the prozedures are all the same
..define
..declare
..and so on

and everybody who want make fw must know how c is code.
this can not learn from my examples :)

it's easy if day on day read spezifikation and test own code

ok... not when GPIO4 and GPIO5 at ESP-12 is printend wrong ;-)
i used it as CLK and CS, and in start - nothing go on.
so be warned:
the printed data at esp-07 and esp-12 must swapped at gpio4 and gpio5
then all ok

hey mehmet - this is still simplest SPI Master - Slave communication

set GPIO'S you need
MOSI
MISO
CLK
SS

make simple macros for
set
init
send
read

btw send and read you can make in one macro
send dummy packets if you want read..
look how spi is communicate
and read datasheet form mcp23s17 how it works
if you use it for input, you can work work with INT
and then you read the data with send/read macro

start!!
ist so simple:
spi_tx (opcode, register, data )
spi_tx(opcode, register, 'H')
spi_tx(opcode, register, 'a')
spi_tx(opcode, register, 'l')
spi_tx(opcode, register, 'l')
spi_tx(opcode, register, 'o')


there is no top secret on this - but i never post my own code,
because my code is hobby and for teaching better not to use or inspiration
;-) ..but it run

and each someone makes code other i work with inlines for smal grafik
you use pictures outside. with this code snippet i post here you can make your own
webserver like i made simple - and this is the fastest way - my think.

next step is to connect a LCD at a Port ( HALLO ) and make output for read.
step by step forward - you must make by self .. not wait for projekt with code
make web response for DS18B20 and DHT11 or DHT22 simple way to and build in in the
webserver code snippet. you will have fun more and doing by self

;-)

best wishes
rudi
User avatar
By TheLastMutt
#7391 Hi!

iabdalkader wrote:Does anyone know how to read the byte shifted in by the slave while writing ? It looks like SPI is working in half-duplex mode?


See my first post:
TheLastMutt wrote:For full-duplex operation use SPI_FLASH_DOUT only, but in combination with the SPI_DOUTDIN bit. Then you will receive the same amount of bits as you have configured in SPI_USR_OUT_BITLEN.


When I tested this I did not set SPI_WR_BYTE_ORDER or SPI_RD_BYTE_ORDER bits. The received data replaced the transmitted data (low byte of SPI_FLASH_C0) after the transmission was finished.