SPI slave communication with another microcontroller
SPI slave communication with another microcontroller
Hi,
Anyone has an example code of SPI communication. The esp32 supposed to work as slave with an other microcontroller.
The esp32 has to receive some data (with interrupt or not) and respond.
Thanks you for your help.
Anyone has an example code of SPI communication. The esp32 supposed to work as slave with an other microcontroller.
The esp32 has to receive some data (with interrupt or not) and respond.
Thanks you for your help.
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: SPI slave communication with another microcontroller
There is an example of two ESP32s communicating with eachother using SPI, one as a master, the other as a slave. You can find it in esp-idf under examples/peripherals/spi_slave.
Re: SPI slave communication with another microcontroller
Thank you for your response, but i want the ESP32 wait for spi communication initiated by the master.
in the example code of spi communication between ESP32s in esp-idf, the function used is:
spi_slave_transmit(HSPI_HOST, &t, portMAX_DELAY); and this transmit data.
to simplify the flowchart of the example i am looking for is:
Start -> Idle -> if SPI interrupt -> Read spi data -> End
Thank you in advance for your help.
in the example code of spi communication between ESP32s in esp-idf, the function used is:
spi_slave_transmit(HSPI_HOST, &t, portMAX_DELAY); and this transmit data.
to simplify the flowchart of the example i am looking for is:
Start -> Idle -> if SPI interrupt -> Read spi data -> End
Thank you in advance for your help.
- Attachments
-
- spi.png (12.76 KiB) Viewed 16426 times
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: SPI slave communication with another microcontroller
Spi_transmit will actually block until the master has exchanged data with the slave. No need to mess around with interrupts specifically, the driver will take care of that.
Re: SPI slave communication with another microcontroller
Ok thanks for your help
Re: SPI slave communication with another microcontroller
Hi,
I come back to you, about the spi transaction, My esp32 works as slave, I need SPI Read transaction that the slave begins transmitting data on the MISO After receiving a "read commad" as shown in the folowing figure:
thank you for your help.
I come back to you, about the spi transaction, My esp32 works as slave, I need SPI Read transaction that the slave begins transmitting data on the MISO After receiving a "read commad" as shown in the folowing figure:
thank you for your help.
- Attachments
-
- spi.png (81.63 KiB) Viewed 16252 times
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: SPI slave communication with another microcontroller
That unfortunately is not possible using the current driver. The SPI slave interface does have another mode of operation which can use the mixed instruction/data concept that's shown in your picture (and the hardware for that is documented in the technical reference manual), but we do not have a driver for it. With the help of the technical reference manual, you should however be able to write your own.
Re: SPI slave communication with another microcontroller
Ok thank you.
-
- Posts: 4
- Joined: Thu Nov 23, 2017 12:33 pm
Re: SPI slave communication with another microcontroller
Hi,
I have the similar question like @karimuk.
I am trying to connect ESP32 as a SPI Slave mode with a sensor (the senor is not just a sensor, it is a sensor device, equipped microcontroller in it, which is the Master).
I want to enable the receive interrupt of SPI slave, so that, whenever any byte I receive from Sensor, control goes to receive ISR and do some task.
In the driver provided by esp-idf, I couldn't find the interrupt enable option and also interrupt handler/ISR.
From the application code it looks like we have call this function[/b][/b] to send or receive anything through SPI. But I want to get an interrupt whenever ESP32 SPI slave receives some data.
So, kindly help me in finding, how I can enable the receive interrupt for SPI communication while it is in slave more. Any information will be highly appreciated.
Thanks
Dipankar
I have the similar question like @karimuk.
I am trying to connect ESP32 as a SPI Slave mode with a sensor (the senor is not just a sensor, it is a sensor device, equipped microcontroller in it, which is the Master).
I want to enable the receive interrupt of SPI slave, so that, whenever any byte I receive from Sensor, control goes to receive ISR and do some task.
In the driver provided by esp-idf, I couldn't find the interrupt enable option and also interrupt handler/ISR.
From the application code it looks like we have call this function
Code: Select all
spi_slave_transmit(HSPI_HOST, &t, portMAX_DELAY);
So, kindly help me in finding, how I can enable the receive interrupt for SPI communication while it is in slave more. Any information will be highly appreciated.
Thanks
Dipankar
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: SPI slave communication with another microcontroller
Effectively, you don't. That call will not return until a transmission is done by the master. (Other tasks will run while the SPI interface is doing this.)
Who is online
Users browsing this forum: No registered users and 20 guests