-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPI_MODE #14
Comments
Hi @scargill. Assuming you do have no logic analyzer, have you tried driving an LED with the MISO, MOSI, SCK and CS pins? I guess a |
I only have the one nano sadly... I'm looking at the code for the Arduino - and it seems to be receiving a byte and sending one as well. Does that means I should be doing this? I'm getting some debug feedback from the Arduino but it is not receiving the "1" I'm trying to send.. So I looked at the ESP code and it appears one can send and receive at the same time - I tried that - no better. This is my attempt at sending and receiving 8 bits.. really not sure about that spi_mode command however. Look good/bad? spi_init(1); // HSPI mode |
I ran into an issue with a particular SPI device that expected the chip select (slave select) pin to be opposite to what the ESP8266 does for active. (ie active low instead of active high). There’s no way to reconfigure this on the ESP8266 that I’m aware of which is odd because it’s pretty common in most microcontrollers. Absolute best way to debug SPI on anything is to use a logic analyser. The cheap $10 clones are good enough with the open source sigrok (or use the official salae logic app if it’s “compatible”). Just to make sure the ESP8266 is actually putting out what you expect. I’ve also used a Rigol scope heaps with SPI decode enabled.
|
The following should work:
(I swapped the calls to rx8 and tx8). As the Arduino seems to receive the byte the CS pin is correct, check the MISO connection. As @MetalPhreak wrote, you should definitely get a logic analyzer. |
I have that transmit and receive - and what I'm sending out on the ESP seems right - but what comes back is rubbish - I realise the ESP can set which edge the clock runs on - and whether the clock is high normally - I'm not sure what the Arduino is expecting.... So I'm sending spi_transaction(1,8,1,0,0,0,0,8,0); The first byte out is 1 - I'm sending no data at the end there - just receiving 8 bytes... but I'm NOT getting what the Arduino thinks it is sending back. Can someone confirm how the Arduino is expecting things to work - I'm assuming ENABLE normally high, active low, CLOCK normally high trigger on rising edge |
I wonder if you or anyone else can help.
I'm trying to get this code working with a simple example of an Arduino slave...
https://forum.arduino.cc/index.php?topic=184527.0
I have the SLAVE demo running - as far as I can tell it should at least toggle the light on and off when it gets a byte with 1.
So I tried - I am SURE the wiring is right - the light on the Arduino is on and the serial says it is ready...
But nothing... when I tried
spi_init(1); // HSPI mode
spi_tx8(1,arg1);
with various values for arg1 including of course - 1..
Then I noted you have a function called spi_mode - which does not seem to be used in any of your examples and is not called in your c code.. I added that into the init and tried all 4 variations of args 2 and 3 in spi_mode....
Am I missing something? any pointers?
Pete.
The text was updated successfully, but these errors were encountered: