master salve implemtatation esp idf 4.0

ESP_alisitsyn
Posts: 203
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: master salve implemtatation esp idf 4.0

Postby ESP_alisitsyn » Tue Jan 12, 2021 3:07 pm

Hi @JuhToiva,

Modbus uses the timer group to measure the required timeouts which can be configured using kconfig options (CONFIG_FMB_TIMER_GROUP, CONFIG_FMB_TIMER_INDEX).

The Error code 0x105 is ESP_ERR_NOT_FOUND (for your reference: https://docs.espressif.com/projects/esp ... codes.html). When returned from timer_isr_register it means that a CPU interrupt with the required parameters have not been found. This may happen if your application is initializing a lot of interrupt-based drivers, and all the CPU interrupt sources are used up.

There is a total of 11 L1-L3 interrupts on PRO CPU, and 12 on the APP CPU. The interrupts are dynamically assigned to drivers as they are initialized. If more than one instance of a peripheral is initialized, each instance will use its own interrupt. The CPU on which the driver is initialized is the one to which the interrupt will be connected.

To troubleshoot this, please check the following:

Which of the ESP-IDF peripheral drivers is the application initializing before the modbus port error is observed? Are all of them used, or some can initialized only on demand? This may reduce the total number of interrupts required.

Can some of the driver initialization calls be made from the APP CPU? This will allow using the additional 12 interrupt inputs available on the APP CPU.

For the drivers which accept intr_alloc_flags argument in their initialization functions, you can try adding ESP_INTR_FLAG_SHARED flag to the bit mask. This flag indicates that the interrupt allocator can use single CPU interrupt input for multiple peripherals. This has very slight interrupt latency penalty, but allows reducing the total number of occupied interrupt inputs. See https://docs.espressif.com/projects/esp ... g-a-source and https://docs.espressif.com/projects/esp ... _sharediib for more details on interrupt sharing.

The Modbus patch for v4.1 is attached.
Attachments
patch_drv_modbus_v41_rc_1.zip
Modbus component v4.1 fixes
(25.94 KiB) Downloaded 294 times

JuhToiva
Posts: 4
Joined: Thu Jan 07, 2021 5:39 am

Re: master salve implemtatation esp idf 4.0

Postby JuhToiva » Mon Jan 18, 2021 10:28 am

Hello ESP_alisitsyn

I did figure out myself what was the problem for interrupts. There was on our side driver that was using all the timers in groups with interrupts.
Removing that driver totally from compilation did help the modbus working.

Thanks for the patch for the modbus for IDFv4.1. I am just starting to test that and will give the update when I am done.

BR Juha T.

ESP_alisitsyn
Posts: 203
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: master salve implemtatation esp idf 4.0

Postby ESP_alisitsyn » Fri Jan 22, 2021 1:55 pm

Hi JuhToiva,

Thanks for the update. Let me know if you have any issues.

JuhToiva
Posts: 4
Joined: Thu Jan 07, 2021 5:39 am

Re: master salve implemtatation esp idf 4.0

Postby JuhToiva » Mon Jan 25, 2021 8:33 am

Hi

Now the driver is working really fine after several days of testing.
Thank you very much for help.

BR Juha T.

Who is online

Users browsing this forum: No registered users and 138 guests