Page 1 of 1
ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function
Posted: Sat Dec 02, 2023 9:07 am
by Vineethad
Hello Everyone,
I am using ESP32C3 module and the tool is ESPRESSIF IDE(v5.1.1). I am trying to connect ESP32C3 as a SPI Slave mode with the master.
I tried to enable the SPI slave interrupt using esp_intr_enable_source(ETS_SPI2_INTR_SOURCE) and whenever any byte I receive from the master, control goes to receive ISR and do some task for that I am using esp_intr_alloc(ETS_SPI2_INTR_SOURCE, ESP_INTR_FLAG_SHARED, spi_slave_isr_handler, &t, &SPI_intr) but I am getting error like ESP_ERR_NOT_FOUND.
I have mentioned the related code below, Please help me to solve this error.
Thanks & Regards,
D. Vineetha.
Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function
Posted: Sat Dec 02, 2023 10:35 am
by MicroController
I am using esp_intr_alloc(ETS_SPI2_INTR_SOURCE, ESP_INTR_FLAG_SHARED, spi_slave_isr_handler, &t, &SPI_intr) but I am getting error like ESP_ERR_NOT_FOUND.
That's because the SPI slave driver internally does the interrupt handling for you. After the driver is initialized, the corresponding SPI interrupt is already 'allocated' to the driver's own ISR.
Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function
Posted: Tue Dec 05, 2023 9:59 am
by Vineethad
Thank you for the reply,
As per your suggestion we are tried this but SPI slave was not receiving any data from the master in interrupt mode.
Please can you explain briefly how the SPI slave driver internally does the interrupt handling.
Thanks & Regards,
D. Vineetha.
Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function
Posted: Tue Dec 05, 2023 10:18 am
by MicroController
As per the
example, you need to prepare and enqueue an SPI transaction with the driver. This transaction will sit there waiting for the master to start communication and when it is done you receive the post_trans_cb callback.
Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function
Posted: Wed Dec 06, 2023 5:17 am
by Vineethad
Thanks for the response,
"you need to prepare and enqueue an SPI transaction with the driver"
my bad, I didn't got what you mean by enqueue an SPI transaction with the driver, can you explain what does it mean and how to do it.
I understood that in the example which you have shared we need to call the SPI_SLAVE _TRANSMIT() function for every transmission and receive from the slave. I don't want to call SPI_SLAVE _TRANSMIT() in main loop as it is waiting until data is sent from the master.
my requirement is some process will be running in the main while loop continuously and whenever a data of some number of bytes(ex. 3 bytes) from master is sent the execution in the slave should go to the SPI ISR where I can collect the data sent from the master. After executing the ISR the execution should go back to the main while loop and this process should repeat. This should happen independent of handshake pin, can you share if there is any example available related to do this or else can you guide me how to do this.
Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function
Posted: Wed Dec 06, 2023 12:32 pm
by MicroController
See
spi_slave_queue_trans().
Also, consider creating one or more
tasks to run concurrently to your main loop.
Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function
Posted: Thu Dec 07, 2023 5:11 am
by Vineethad
Hello,
Thanks for the response,
Actually I don't want to use rtos, the whole thing I explained in my previous reply should work in bare metal. Is that possible.
Please help me in this regard.
Thanks & regards,
D. Vineetha