I am writing a small lua script to test the SPI of nodemcu. I have shorted the MOSI and MISO pins of nodemcu to go for a self loop test.
I tested the clk, ss and mosi signals on the oscilloscope and they seem to be good.
But, I am getting problem in receiving the data when I do loop test.
I am have used following lua script for this:
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8,8, spi.FULLDUPLEX);
s= {spi.send(1,0,0x05, 0x40,0x33, 0x54)}
read = spi.recv(1,1)
= s[1]
= s[2]
print(string.byte(read))
The output of this;
s[1] as 5 because 5 bytes were sent.
But I constantly receive 255 from spi.recv, no matter how many bytes i send, i still receive the read value as 255.
after writing this script, I use Send to ESP to view the outputs.
Can someone suggest where I am going wrong ?
Am I missing something ?
Any help will be appreciated
Thanks a lot