Modbus fails in RTC Interrupt / Arduino Mkr Zero

We have developed a board based on the Arduino Mkr Zero board with the SAMD 21 G18 uC. The arduino sketch is converted and imported to an Atmel/Microship studio project. We are using the onboard RTC with the RTCZero lib for time based interrupts to get data. This data comes from i2c, ADC, and so on. This works fine and without any problems. The systems are connected via the SERCOM interface.
Now we wanted to add some modbus functionality via an MAX14840 IC and an UART interface (with SERCOM5 connection). When executed in the main loop everything works fine but when executed in the RTC interrupt the read holding register function of the Arduino Modbus lib crashes. When debugging in Microship Studio (break command) it seems like the controller waits in the Uart flush function, especially in the while loop. (in the original Uart.cpp file)

void Uart::flush()
  while(txBuffer.available()); // wait until TX buffer is empty


For me it looks there is a problem with some interrupts or the interrupt priority. Does anybody has faced similar problems? Or any other idea?

Thank you very much!

BR Thomas

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.