arduino / ArduinoCore-renesas

MIT License
109 stars 74 forks source link

Serial.print() - from Interrupt callbacks hangs the processor. #38

Closed KurtE closed 1 year ago

KurtE commented 1 year ago

With the current release (actually current code as well) as has been mentioned on a few threads now including: https://forum.arduino.cc/t/serial-print-from-isr-will-hang/1145292

If you run a sketch like the unmodified example RTC->Test_RTC The program will completely hang when it tries to do any Serial.print() statements... Actually would be true as well for Serial1.print()...

I am guessing that the current UART class code has not really been completed but just enough to be able to use the new board. For example I am assuming that at some point there will be a TX software queue and the like.

But a quick and dirty fix would be to change the Interrupt priority for the UART to a high enough priority such that the NVIC code would allow it to be called from for example a timer interrupt callback.

On my machine I changed cores\arduino\IRQManager.cpp: line 14: #define UART_SCI_PRIORITY 6 //12 Which allows it to preempt most IRQs except maybe SPI Master.

But again I do not believe this should be the long term fix, but may be sufficient for the short term

Edit: Note I have the Uno R4 Wifi

KurtE commented 1 year ago

removing detritus from my list of open github issues.