[已解决] SPI_SLAVE通信不正确

defender
Posts: 6
Joined: Sun Apr 18, 2021 5:24 pm

[已解决] SPI_SLAVE通信不正确

Postby defender » Mon May 24, 2021 4:11 am

我很困惑,配置SPI_SLAVE连的sender和receiver例程后,收发会出现不正确的情况。
sender收到的数据出错会比较多,由于我只想半双工,发送给receiver的内容改为: int res = snprintf(sendbuf, sizeof(sendbuf),
"Sender, transmission no. %04i\r\n", n);
但是receiver还是会出错(有一些接收不到),请问应该如何修改呢?
espidf版本 v4.0.1,芯片ESP32-WROOM-32
引脚:
#define GPIO_HANDSHAKE 2
#define GPIO_MOSI 5
#define GPIO_MISO 17
#define GPIO_SCLK 16
#define GPIO_CS 4

接收数据为:
Received: Sender, transmission no. 1834

Received: ���������������������������������������������������������������������������������������������������������������������������������G�?
Received: Sender, transmission no. 1836

Received: Sender, transmission no. 1837

Received: Sender, transmission no. 1838

Received: Sender, transmission no. 1839

Received: Sender, transmission no. 1840

Received: Sender, transmission no. 1841

Received: Sender, transmission no. 1842

Received: Sender, transmission no. 1843

Received: Sender, transmission no. 1844

Received: Sender, transmission no. 1845

Received: ���������������������������������������������������������������������������������������������������������������������������������G�?
Received: Sender, transmission no. 1847

defender
Posts: 6
Joined: Sun Apr 18, 2021 5:24 pm

Re: SPI_SLAVE通信不正确

Postby defender » Mon May 24, 2021 5:02 am

已解决。
删除receiver端向sendbuf填数据的代码,问题消失(可能是因为两次transmit间隔被拉的有点长了)

Who is online

Users browsing this forum: No registered users and 33 guests