ESP32 BLE Interrupt Priority

User avatar
WardMas
Posts: 75
Joined: Fri Jun 19, 2020 9:09 am

ESP32 BLE Interrupt Priority

Postby WardMas » Mon Jun 29, 2020 11:57 am

Hello friends,
I am working on a project were I am using several interrupts (two timers interrupts, GPIO interrupt and BLE which has GATT and GAP callbacks). I amusing ESP32 WROOM module with ESP IDF. usually it is possible to change the interrupt level by changing the interrupt flag when registering an interrupt but it is not possible to pass such a parameter in esp_ble_gatts_register_callback(), esp_ble_gap_register_callback() and esp_ble_gatts_app_register() functions so is there a way of setting priority for these interrupts.
Thank you.
You can always visit my YouTube channel for embedded systems related tutorials
https://youtube.com/user/wardzx1

ESP_ulipe
Posts: 7
Joined: Fri Mar 27, 2020 8:13 pm
Location: Campinas, SP - Brazil

Re: ESP32 BLE Interrupt Priority

Postby ESP_ulipe » Mon Jun 29, 2020 2:26 pm

Hi WardMas, these functions you are referring to actually register callbacks that are invoked in a task context, the Bluetooth core has a task that also manages the invocation of the callback of different layers from the BT stack, in your example the GAP and GATT layers. For this reason, they don't have such property to add a priority.

Please let me know if this information was helpful to you :)

Felipe

User avatar
WardMas
Posts: 75
Joined: Fri Jun 19, 2020 9:09 am

Re: ESP32 BLE Interrupt Priority

Postby WardMas » Tue Jun 30, 2020 5:34 am

Hi ESP_ulipe , thank you for your reply that was absolutely useful. Now the problem I am having is that BLE callback are interfering with the other interrupt subroutines that I had mentioned. that is why I wanted to play with interrupt priority hoping to find a solution for my problem. The critical point is that since ESP32 does not support UART 9 bits I had to create my own manual UART low level handling functions based on two timers for synchronization. As you may have noticed, I am accessing several interrupts quit often and using a logic analyzer I found that the transmitted data over UART is having some error at some points. Say 4 UART words are getting corrupted in a minute. so is there a way of solving such an issue?.

Thank you again
You can always visit my YouTube channel for embedded systems related tutorials
https://youtube.com/user/wardzx1

ESP_ulipe
Posts: 7
Joined: Fri Mar 27, 2020 8:13 pm
Location: Campinas, SP - Brazil

Re: ESP32 BLE Interrupt Priority

Postby ESP_ulipe » Thu Jul 02, 2020 6:54 pm

Hi WardMas, glad the information helped you.

Since you are in need of this bit-banged UART, you could use the dual-core capability of ESP32, for example by default the Bluetooth controller and host stacks runs their code in the CPU0(PRO_CPU), said this you can run your custom code in the APP_CPU(CPU1) which will not interfere in the BLE stack timings and vice-versa.

Try to create your UART code task to run in the CPU1 or use the IPC mechanism if you just want to run a procedure in a different CPU, see the documentation below:

https://docs.espressif.com/projects/esp ... m/ipc.html

Please let me know if I can help with more information.

Cheers.

Felipe

User avatar
WardMas
Posts: 75
Joined: Fri Jun 19, 2020 9:09 am

Re: ESP32 BLE Interrupt Priority

Postby WardMas » Fri Jul 03, 2020 5:04 am

Hi,
Thank you for your response. This is actually how I could solve the problem but instead of using IPC, I used task pinned to core 1 when initializing the required interrupts and I have shared this here viewtopic.php?f=13&t=16335 . Having a second core is a big advantage in ESP32.
You can always visit my YouTube channel for embedded systems related tutorials
https://youtube.com/user/wardzx1

Who is online

Users browsing this forum: No registered users and 100 guests