Multiple SPI Devices

mustafa_aus
Posts: 3
Joined: Thu Sep 19, 2019 12:41 am

Multiple SPI Devices

Postby mustafa_aus » Thu Sep 19, 2019 1:32 am

Hello everyone,

Let me preface this by saying I'm quite new to the ESP32 and the ESP-IDF framework, so please bear with me.

Essentially, I've got three ESP32s that I want communicating with each other; one is a 'master' node that acquires field data, and the two others are 'slave' nodes that receive the data from said master. Both devices need to be on the same bus (i.e. common MOSI, MISO and SCLK but different CS), as I'm restricted in terms of GPIO pins. The current setup I've got consists of an interrupt that is triggered by a pulsed signal. The ISR gives a binary semaphore that is received by a background task which is responsible for the SPI transaction(s). This works perfectly fine with a single device, but fails when I introduce the second i.e. I receive no data on one device and garbled data on the other.

In the task, the SPI bus is initialised and slave devices are added before it enters an infinite loop, where the transactions are made. The transaction structure is built once, then using the spi_device_transmit()API function, it is sent to device 1, before the structure is rebuilt and sent to device 2. As the SPI bus is common, both transactions should be made in the same task. I've fiddled around with the clock speeds and I've introduced delays between the two spi_device_transmit() commands, but to no avail.

Perhaps there are timing considerations that need to be made, or perhaps the approach I'm taking isn't correct. I'd appreciate opinions so please feel free to offer any. I apologise for not having any code in this post; I'm currently at work.

Regards,

Mustafa

Who is online

Users browsing this forum: Baidu [Spider] and 190 guests