- Fri Jul 21, 2017 11:51 am
#68417
Okey now I have some data! I connected pin 12 and 14 to MAX6675(D0 CS CLS)
12 - D0
14 - CLk
Where to connect CS??
What options to set in ISP
timer 1000, [check.rotate]
spi.setup(9600,1,1)
wait
[check.rotate]
rec = spi.byte(2)
print rec
wait
FUNCTIONS SPI
The SPI port (H/W) is available for general use.
The following pins are defined :
SCK : GPIO14
MISO: GPIO12 (Master Input, Slave Output) (input for the ESP8266)
MOSI: GPIO13 (Master Output,Slave Input ) (output for the ESP8266)
The CS pin can be any pin. (controlled by user program)
spi.setup():
Opens the SPI port and set the speed.
It possible to optionally define the SPI_MODE and the data direction.
By default these values are SPI_MODE0 and MSB_FIRST. Only spi modes 0 and 1 are supported.
spi.setup({speed}, {MODE}, {MSB_FIRST})
Example :
spi.setup(1000000) -> 1Mbit/sec, mode 0, MSB_FIRST
spi.setup(500000, 1, 1) ->500Kb/sec, mode 1, MSB_FIRST
spi.setup(100000, 1, 0) ->100Kb/sec, mode 1, LSB_FIRST
spi.byte():
Write and receive byte at the same time (the arguments are numbers)
rec = spi.byte({send variable})
The value received and sent are numbers (byte)
Can be used as a command if the received argument is not required
Example :
rec = spi.byte(55)
spi.byte(123)
spi.string():
Write and receive a string of len chars.
var$ = spi.string({string}, {len})
Example:
dat$ = spi.string("Hello World!", 12)
spi.hex():
write and receive a string containing an hexadecimal message representing len bytes.
var $ = spi.string({hex_string}, {len})
Example:
dat$ = spi.hex("a1b2c3d4e5f6", 6) -> send 6 bytes (sequence of a1, b2, c3, d1, e5, f6) and receive in dat$
spi.setmode():
Allows for changing of spi modes on the fly after the spi setup function has been used. Only modes 0 and 1 are supported.
spi.setmode({MODE})
spi.setfrequency():
Allows for changing of spi frequency on the fly after the spi setup function has been used.
spi.setfrequency({FREQUENCY})