khoih-prog / Portenta_H7_TimerInterrupt

This library enables you to use Interrupt from Hardware Timers on an STM32H7-based Portenta_H7 board. It now supports 16 ISR-based timers, while consuming only 1 Hardware Timer. Timers' interval is very long (ulong millisecs). The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks. These hardware timers, using interrupt, still work even if other functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software timers using millis() or micros(). That's necessary if you need to measure some data requiring better accuracy
MIT License
15 stars 7 forks source link

Interference between timer interrupt and UART #1

Closed TuringTW closed 2 years ago

TuringTW commented 2 years ago

Describe the bug

I use the M7 core for the UART reading and the M4 core for the timer interrupt. I found the UART message screw up when the timer interrupt was enabled in the M4 core.

Steps to Reproduce

The following two example codes can reproduce the problem.

The message is from my GPS module, but I think the UART source can be replaced by anything else. When the timer interrupt is enabled, the UART message screw up, while it works fine when the timer interrupt is disabled.

I also try to remove all of the actions in the interrupt function. But the result is the same. I suspect the UART frequency is somehow interfered with by the timer interrupt.

Expected behavior

UART and timer interrupt should work independently.

Information

khoih-prog commented 2 years ago

Hi @TuringTW

Normally, when using Timer Interrupt, you've possessed a better knowledge about hardware, core, etc.

You must be aware of the duplication, priority, etc. of Interrupt Then UART messages must not have enough priority, or the system will crash.

Check your code, read the core code to know what wrong with the UART. BTW, Portenta_H7 core is still new and possibly have many issues, especially with using multicore M7/M4, if you don't have enough experience.

If you still can't solve the problem, post an issue on Arduino mbed_portenta.

I'm closing this now as this certainly has nothing to do with TimerInterrupt.

TuringTW commented 2 years ago

I see. Thanks for the reply