Interrupt optimisation

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Interrupt optimisation

Postby PeterR » Tue May 12, 2020 4:52 pm

Trying to figure out how to load optimise interrupt servicing within the ESP drivers and/or understand causes.
I am seeing CAN overrun errors. The CAN device has buffering for around 5 or 6 RX frames. At 250Kbps thats 500uS per or 2.5mS total. That seems a long time to be locked out.

As I understand it app_main() is launched from Core 1.
My app_main() creates the drivers (CAN, I2C, Ethernet) and so I expect that CAN, I2C & Ethernet interrupts will run from Core 1 and so may block each other?

Who uses Core 0? The documentation says 'system tasks', what are the 'system tasks'?
Can I prioritise interrupts? The I2C interrupt for example may take a low level. I imagine Ethernet is well DMA buffered and would be happy on a lower priority.

What else should I look at?
& I also believe that IDF CAN should be fixed.

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: Interrupt optimisation

Postby PeterR » Wed May 13, 2020 11:45 pm

Cannot even find the CAN interrupt allocation, device interrupt enable flags sure but I need to check host service priority. That said I have not found any documentation which explains interrupt priorities. Not getting why I regularly overflow at 250Kbps 30%. Anyone else working withn CAN?
& I also believe that IDF CAN should be fixed.

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Interrupt optimisation

Postby ESP_igrr » Thu May 14, 2020 10:09 am

Hi PeterR,

You can adjust priority of specific interrupts by passing ESP_INTR_FLAG_LEVEL1, ESP_INTR_FLAG_LEVEL2, ESP_INTR_FLAG_LEVEL3 (optionally ORed with ESP_INTR_FLAG_IRAM) flags to the respective driver install function. Higher interrupt levels can preempt lower interrupt levels. (A bit more on interrupt allocation can be found here.)

With regards to tasks running on Core 0:
* app_main function is called from the "main" task, which runs on Core 0. This task terminates once app_main returns.
* FreeRTOS timer task, with priority 1, runs on Core 0.
* esp_timer (high resolution timer) task runs on Core 0.
* If you are using the esp_event library, default event loop task runs on Core 0.
* If you are using Wi-Fi, the affinity of the Wi-Fi task and LWIP task can be adjusted in menuconfig ( CONFIG_LWIP_TCPIP_TASK_AFFINITY, CONFIG_ESP32_WIFI_TASK_CORE_ID
* If you are using Bluetooth, the affinity of related tasks can also be adjusted (CONFIG_BTDM_CTRL_PINNED_TO_CORE_CHOICE, CONFIG_BT_BLUEDROID_PINNED_TO_CORE_CHOICE, CONFIG_BT_NIMBLE_PINNED_TO_CORE_CHOICE)

Who is online

Users browsing this forum: Bing [Bot] and 90 guests