Skip to content

SPI transmit data on HSPI_HOST is wrong (GIT8266O-355) #791

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

Open
Bresenham opened this issue Dec 25, 2019 · 2 comments
Open

SPI transmit data on HSPI_HOST is wrong (GIT8266O-355) #791

Bresenham opened this issue Dec 25, 2019 · 2 comments

Comments

@Bresenham
Copy link

Bresenham commented Dec 25, 2019

Environment

  • Development Kit: Wemos D1 mini
  • IDF version: a353785
  • Development Env: Make
  • Operating System: Ubuntu 18.04
  • Power Supply: USB

Problem Description

The ESP8266 is configured as an SPI-Master and transmits 2 messages to an SPI-Slave. After these two message are transmitted, one SPI-read of 8-bits is performed.
The first message, called writeMsg in code, consists of five individual bytes. The second message, called readMsg in code, consists of four individual bytes. writeMsg[1:3] and readMsg[1:3] are equal (as you can see in the example code) but for whatever reason, readMsg[1:3] show up as 0 on my LogicAnalyzer even though writeMsg is transmitted perfectly fine.
However, if I don't transmitwriteMsg, readMsg is sent correctly.

Expected Behavior

Bytes readMsg[1:3] should be equal to [0x00, 0x16, 0xC5].

Actual Behavior

Bytes readMsg[1:3] are [0x00, 0x00, 0x00].

Steps to repropduce

  1. Copy linked code
  2. Compile and flash
  3. Watch SPI-Pins of HSPI_HOST via LogicAnalyzer / digital oscilloscope

Code to reproduce this issue

https://gist.github.com/Bresenham/f5c016361e21b9a3711ef5e7565f7874

Another version of the code which behaves the same but is more refined:
https://gist.github.com/Bresenham/fdda4ff163c68188a6f150df19bc4727

LogicAnalyzer of writeMsg: https://pasteboard.co/IMVfzCV.png

LogicAnalyzer of readMsg: https://pasteboard.co/IMVfHs1.png

Debug Logs

<27>[0;33mW (102718) spi: Using unaligned data may reduce transmission efficiency<27>[0m

Other items if possible

@github-actions github-actions bot changed the title SPI transmit data on HSPI_HOST is wrong SPI transmit data on HSPI_HOST is wrong (GIT8266O-355) Dec 25, 2019
@donghengqaz
Copy link
Collaborator

It is hard to using the SPI driver directly, but you can refer to the new SPI example and the new SPI high level driver.

@vargavik
Copy link

Hi, this problem is related with a small error in the spi driver. When the data is unaligned, only the first byte is sent (or read), all the other bytes will be zero. Since your first byte is already zero, you will end up with 3 zeros. Check out #723.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants