Sanguino 644p Serial0 not working proper

Hi,

my name is Jochen and i’m from Germany.

I try to get an ATMEGA644p working. I downloaded Sanguino-0101r1 and put the files in the Arduino hardware folder. I used an Arduino Mega2560 as ISP to write the bootloader to the 644p.

Serial commuicator is an Atmega Uno (without the IC in the socket, just using the Atmega 16U2 as USB to TTL Adapter) and as second test device a Digitus Usb2 Serial Converter with an MAX202 behind for TTL levels.
.
I wrote the following code to test the serial.

void setup(){

Serial.begin(9600);
Serial1.begin(9600);
}
int count=0;
char inchar1;
char inchar2;
void loop(){

if (Serial.available() > 0){
count++;
inchar1=Serial.read();
Serial.println(inchar1);
Serial.println(count); }
if (Serial1.available() > 0){
count++;
inchar2=Serial1.read();
Serial1.println(inchar2);
Serial1.println(count); }

}

My problem is, if i write to serial0 (Pins 14 and 15) the sanguino works for a few char inputs (the sended input chars are returned), then the sanguino halts and reboot (count starts at 1 and debug LED is short flashing). Especially when i write serveral characters to the serial it stops and reboots the atmega.
If i’m using the serial1 everything is fine on this second serial.

I have tried to replace the HardwareSerial.cpp and the HardwareSerial.h from the sanguino folder with the newer ones from the arduino folder. But this also doesn’t work.

I also tried to write the program direct to the atmega, without using the bootloader, but this didn’t work also. Same problem like with uploaded by the bootloader.

Any ideas??

THX Jochen

Buffer overrun ? Where do the characterns written to serial1 end up?

Characters are written by the Arduino Serial Monitor. Tested with all available LineEndings.

The funny thing is, if i use the second Serial1 from the 644p on pins 16 and 17 all is working fine. If run the sketch on an UNO R3 or Mega2560R3 i have no problems.

I think something in the HardwareSerial Libary causes the 644p to overflow at some point. But i can't find the error.

Maybe anyone else have an saguino644p and can run the sketch to verify this problem.

pin 14/15 is used/connected to IDE-interface.
What if you write a testprog where the 644 communicates with itself Ser0 <-> Ser1 (no USB / PC connection)
Indicator can be made from a LED telling status…

Nice Idea,

will try it this evening with some LED's for RX/TX indications on both sides

I wrote a little sketch, which puts a single char on the serial and then reads from the serial. if i connect TX to RX from Serial0 the 644p seems to reboot and sometimes it completly halts, same thing if i put TX1 to RX0 (Serial1 to Serial0). if i put TX1 to RX1 this is working perfect (serial1 crossover connect). Also if i put TX0 to RX1. It only seems to crash if RX0 is geeting data. There's no usb connection while testing. Atmega is direct powered by a stabilezed power supply.

I thought about hardware failure at the RX0, but the sketch upload trough the bootloader is working without problems.

..never heard of that behavior earlier.. Got no ideas.