ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function

Vineethad
Posts: 55
Joined: Wed Jul 19, 2023 7:45 am

ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function

Postby Vineethad » Sat Dec 02, 2023 9:07 am

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.
Attachments
Screenshot 2023-12-02 143516.png
Screenshot 2023-12-02 143516.png (40.74 KiB) Viewed 8044 times
Screenshot 2023-12-02 143503.png
Screenshot 2023-12-02 143503.png (57.42 KiB) Viewed 8044 times
Screenshot 2023-12-02 143448.png
Screenshot 2023-12-02 143448.png (61.41 KiB) Viewed 8044 times

MicroController
Posts: 1706
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function

Postby MicroController » Sat Dec 02, 2023 10:35 am

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.

Vineethad
Posts: 55
Joined: Wed Jul 19, 2023 7:45 am

Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function

Postby Vineethad » Tue Dec 05, 2023 9:59 am

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.

MicroController
Posts: 1706
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function

Postby MicroController » Tue Dec 05, 2023 10:18 am

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.

Vineethad
Posts: 55
Joined: Wed Jul 19, 2023 7:45 am

Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function

Postby Vineethad » Wed Dec 06, 2023 5:17 am

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.

MicroController
Posts: 1706
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function

Postby MicroController » Wed Dec 06, 2023 12:32 pm

See spi_slave_queue_trans().
Also, consider creating one or more tasks to run concurrently to your main loop.

Vineethad
Posts: 55
Joined: Wed Jul 19, 2023 7:45 am

Re: ESP_ERR_NOT_FOUND error in ESP_INTR_ALLOC() function

Postby Vineethad » Thu Dec 07, 2023 5:11 am

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

Who is online

Users browsing this forum: No registered users and 63 guests