Serial communication issue on Atmega328

Hello,

I'm having a serial communication issue with an Atmega328PB-AU and after 3 days of debugging it's driving me insane. I'm trying to use a simple code:

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("a");
  delay(300);

}

I'm using an SP-880 RS232 converter for communication. My code uploads without issue, and I can see the device transmitting (RX LED flashes on the RS232 converter). However, I don't see anything other than whitespaces in the Arduino IDE serial monitor. The correct COM port is selected with speed set to 9600 and newline (I tried every other option as well, no luck). I also tried to use the powershell to read the serial port using this guide. ReadLine() just waits until I get bored of it.

I used the following hardware:

RXD0 goes to PD0 and TXD0 goes to PD1 on the Atmega328PB-AU. I also have a jumper on the MAX232 outputs to bypass it if needed (for TTL comm), I'm aware that the lines are switched up there. Shouldn't matter, the connectors are connected to the MAX outputs.

Voltages are the following:
V+: 9.28V
V-: -8.46V
TX line: -8.11V
RX line: -6.3V (with the SP-880 connected)

I checked the TX line with a scope, looked good:

The SP-880 also works, because I can echo everything (from computer side) if I connect the RX and TX pins. Works from the Arduino IDE and powershell as well. Scoped waveform:

Sending an "a" character from the computer to the devices is also good, at least I can see this on the RX connector on my PCB:

One more thing, if I try a code which responds with a string when it reads something on serial, I can see the transmission go out (TX LED flashes on the SP-880) but I don't see any response (no RX LED flashing).

What else can I do to make it work? I tried to exclude pretty much everything I thought of.

I am confused.

The Atmega328PB-AU is an IC. Is it being used on your own custom-designed PCB?

Why is the Adafruit USB-RS232 cable needed?

.

ieee488:
I am confused.

The Atmega328PB-AU is an IC. Is it being used on your own custom-designed PCB?

Why is the Adafruit USB-RS232 cable needed?

.

Yes, I use it on my own design as part of a bigger project. I created the software using the Arduino IDE and used a Mega to prototype it (that’s already done and it worked on the Mega) and upload it to the microcontroller (with ArduinoISP). Now I’m trying to set up the circuit but got stuck with the communication, so I tried the simple code mentioned above.

I need the RS232 converter because I wrote a PC side software to help process the data coming from the circuit and the communication is done via serial. I hope this clarifies the situation.

balazs:
I need the RS232 converter because I wrote a PC side software to help process the data coming from the circuit and the communication is done via serial. I hope this clarifies the situation.

Have you tried the RS232 converter with the Mega?

...R

Robin2:
Have you tried the RS232 converter with the Mega?

...R

I can see "0y=" instead of "a".

balazs:

Have you tried the RS232 converter with the Mega?

I can see "0y=" instead of "a".

That is a very strange answer to my question.

Perhaps you meant to say, yes but it does not seem to work properly because I can see "0y=" instead of "a".

If that is the case then I see no prospect of getting the RS232 converter to work with your Atmega 328 until you have figured out how to get it work with the Mega.

...R

Robin2:
I can see "0y=" instead of "a".

That is a very strange answer to my question.

Perhaps you meant to say, yes but it does not seem to work properly because I can see "0y=" instead of "a".

If that is the case then I see no prospect of getting the RS232 converter to work with your Atmega 328 until you have figured out how to get it work with the Mega.

...R

That's what I meant. I used the same code as above and got the wrong output. I will investigate further.

I found the root cause of the problems. Even though I started with burning the bootloader, it failed, so the internal 8MHz crystal were used with CKDIV8, resulting in 1MHz clock. Not surprising that all timing related code failed, while other things worked. Now I burned it again, successfully this time.