Hello, greetings as I am new to the forum.
I have the following problem on a custom board based on ATMEGA2560
On all the 4 UARTs it happens that the TX writes do not come out if more than 10 seconds have passed since the last write, unless there has been at least one byte in input that seems to wake up the write.
Normally on those UARTs a protocol runs for which RX and TX are always active and therefore I had never noticed it. I noticed it having to debug through one of the UARTs, and therefore sending a string only in the face of an event that rarely happens.
I reduced the test code to the bare minimum and verified that 12 seconds of delay are actually enough to no longer have output after the first print.
But it is enough to send a byte from the console and the print comes back to life and then goes back to not working if nothing else is received on the port in question.
Furthermore, the counter confirms that the CPU is running correctly and executing code.
I verified this both from the Arduino IDE console and via terminal emulator (Putty).
But, if I run the same code on an official MEGA2560 the problem does not occur.
However, I confirm that the custom has the official bootloader on board (that is, I see it as an official MEGA2560)
I confirm that the Custom board with respect to the UARTs is identical to the MEGA2560 and I can run exactly the same code with the same target board.
I have verified the same problem on more than one custom board, so I would exclude a hardware failure.
The only difference that I macroscopically see is that my board has an ATMEGA2560-16U-TH while the official Arduino that works has an ATMEGA2560-16AU (16U vs 16AU)
Below is the really minimal code to verify the problem:
Do you have any ideas or advice
Thanks in advance
Pierpgm
void setup() {
Serial.begin(115200);
while (!Serial) {;}
}
void loop()
{
byte mybyte;
unsigned int mycount;
Serial.println("Start");
mycount=0;
while(1)
{
if(Serial.available()) mybyte=Serial.read(); // it is enough the read on byte to have Serial.print working again...
// delay(1000); // works if data witten every 1 sec
delay(12000); // doesn't work if delay is more than about 10 seconds
mycount++; // to check that CPU is really running....
Serial.print(millis());Serial.print("->alive, count=");Serial.println(mycount); // check counter to verify that CPU is really running
}
}