tonton81 / ESP32_CAN

ESP32 CAN library based off of FlexCAN_T4
MIT License
10 stars 3 forks source link

1ms delay in _CAN_TASK prevents absolute packet timings #1

Open aberridg opened 3 years ago

aberridg commented 3 years ago

Hi! I'd love to use this lib in my project, but unfortunately it isn't suitable as things stand...

The vTaskDelay(1) in _CAN_TASK means that the maximum frequency of sending packets is limited to 1ms. I need to send a group of packets every 20ms, spaced at 250us for each packet, otherwise my engine's ECU doesn't like the packets that are sent.

I wonder if the lib could be switched to using an interrupt-based timer for _CAN_TASK? Delaying for microseconds would hold up the processor, which wouldn't work in my application either.

Thanks!

Andrew

tonton81 commented 3 years ago

have you tried commenting out that delay? the task should be free-running i would think, let me know

aberridg commented 3 years ago

Hi!

I can test that - my main concern would be around multitasking and pre-emptive task switching on the ESP32, which I don't yet fully understand.

Will the task scheduler get a look in if the CAN_TASK is running in a tight loop?

Andrew

On Mon, 12 Jul 2021 at 03:50, Antonio Brewer @.***> wrote:

have you tried commenting out that delay? the task should be free-running i would think, let me know

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tonton81/ESP32_CAN/issues/1#issuecomment-877929514, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHLJITPCO5W4IDHWRB5I3XDTXJKBHANCNFSM5AFJEY7A .

--

Andrew Berridge - TIBCO Data Science | M: +44 77 89764017 | E: @.*** | www.tibco.com

tonton81 commented 3 years ago

the tasks is built into the rtos core, it would be faster than polling a function in the loop() which ran the same task

tonton81 commented 2 years ago

Have you done more tests? There is a new update that fixes a new bug found in the FIFO HW

Also 1 tick is not 1ms, it is much faster than that :)