Confusing Atmega128 UART communication circuit

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Hi All

 

I confused that the circuit below of Tx and Rx.

 

 

Should Max232 Tx pin be connected with  Atmega128 Rx pin or not?

 

ragard

 

Jay.lee

Last Edited: Mon. Nov 8, 2021 - 10:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

 

Welcome to AVRFreaks

 

Look at the names in the MAX232 symbol: "T1 IN" and "R1 OUT"

 

So:

  • "T1 IN" is the input to the MAX232's transmitter - it connects to the AVR's TXD output;
  • "R1 OUT" is the output from the MAX232's receiver - it connects to the AVR's RXD input.

 

 

This is actually a general question; not specific to AVR - it would be the same with any microcontroller ...

 

EDIT:

 

This diagram (from the TI datasheet) helps to show the INs and OUTs of the MAX232:

 

 

 

and, from the Maxim Product Page:

 

 

 

EDIT 2:

 

Historically (and the MAX232 is pretty historic), the original RS-232 specification defined "TXD" and "RXD" as circuits - not pins.

 

So "TXD" is the circuit (wire) which carries the data to be transmitted - thus, this will be an output at one end of the wire, and an input at the other;

 

Similarly, "RXD" is the circuit (wire) which carries the received data - thus, this will be an input at one end of the wire, and an output at the other.

 

Hence it's important to check whether a pin marked "TX" on a particular device is an output from that device, or an input to that device.

 

Nowadays, it is most common that a pin marked "TX" is an output - but always good to check...

 

See: http://www.8052mcu.com/forum/rea...

 

And: http://www.8052mcu.com/forum/rea...

 

#TxRxDirection #DteDce

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Mon. Nov 8, 2021 - 10:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

 

When I type "atmega128 uart max232" and do an image search one of the top hits was back to Freaks, this thread:

 

https://www.avrfreaks.net/forum/...

 

and this picture:

 

(except, as noted in that thread, the capacitors are wrong!!)

 

BTW in your image why do you terminate the lines in net names and then have the receiving net names almost right by that? Breaking the picture in this way makes it less easy to follow. When not just have the lines connected directly on the diagram ? (add net name labels alongside the signals if it helps).

Last Edited: Mon. Nov 8, 2021 - 09:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes,  you can connect MAX232 T1IN, R1OUT to TXD1, RXD1 on the mega128  i.e. USART1

 

If you want to use TXD0, RXD0 (USART0) it is wise to put a 1k0 series resistor in the RXD0 - R2OUT line.   (because PE0, PE1 pins are also used for ISP programming)

Edit.  the schematic in #3 omits this 1k0 resistor.   Which prevents ISP programming working with Atmel / Microchip programmers

 

Hint.   If you are unsure about schematics, pcb layout, components, ...  just find an existing commercial design.   AND COPY IT.

Beware "internet tutorials" that do not involve saleable products.   Compare with real-life products e.g. Atmel development boards.

Edit.  the "features" in #3 show exactly WHY it is wise to copy proven commercial designs.

 

David.

Last Edited: Mon. Nov 8, 2021 - 09:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't forget your 1uF chip cap for Vcc power to GND...the chip must have a power pin cap.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

What I found confusing about the schematic was the use of RS232_ net labels on the TTL side of the chip, those labels would have made more sense on the other side (the actual RS232 side) of the chip!

Jim

 

 

FF = PI > S.E.T

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps "MAX232_XXX" rather than "RS232_XXX" ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AVR_TX and AVR_RX might make more sense - as the "TX" and "RX" directions are as seen by the AVR ... ?

 

(or MCU_TX and MCU_RX to be generic)

 

EDIT

 

I hadn't noticed that the OP had already used the "AVR_" prefix - so that would have the added advantage of consistency... ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Mon. Nov 8, 2021 - 05:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Perhaps "MAX232_XXX" rather than "RS232_XXX" ?

seems more descriptive

 

awneil wrote:

AVR_TX and AVR_RX might make more sense - as the "TX" and "RX" directions are as seen by the AVR ... ?

 

(or MCU_TX and MCU_RX to be generic)

or ISP_PDI and ISP_PDO because that is what those pins are intended for.

 

Seriously.    Find a professionally made design.    COPY IT.   You know that it works.   You know that they have chosen standard names and labels.   You will not go to prison for hobbyist boards..  

If you are intending to manufacture 1000s of boards,   ask a professional to design it.   (Or make sure the design that you copy is open-source)

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Back in the day loads of stuff from the likes of Olimex, Futurlec and so on used MAX232's (back when 9 pin +/-12V was still "a thing") and I think a number published schematics.

 

For example:

 

https://www.olimex.com/Products/...

 

(CAN128 is very like mega128 but happens to have CAN too - but MAS232 interface is going to be the same)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Google should find those "dev board" schematics.

 

Incidentally,  my (early) Futurlec mega128 board had the ISP "error feature"

Later revisions solved it.

 

The original Futurlec simply sold a special programmer that had no current limits on the PDI, PDO signals.    Hence ISP just fought (and won) the MAX232.

Whereas Atmel programmers would just detect "a fight" and give up.

 

The OP's schematic makes no attempt to use USART0.   So there is no conflict with ISP.

 

David.

Last Edited: Mon. Nov 8, 2021 - 03:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


 

Does it used for DECAP ? then the value would be 0.1uF right?

 

Jay.lee

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Modern max232 chips use 100nF capacitors. The term ‘DECAP’ is confusing. You mean ‘decoupling’ or ‘bypass’ capacitor.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jay.lee wrote:
Does it used for DECAP ? then the value would be 0.1uF right?

 

Not, not, and one small yes- this chip is producing two more voltages: plus and minus 10V, and in moments does needs 22uF as a reservoir.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Modern max232

laugh laugh laugh laugh 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

because I expected to add other circuits so I thought space would be not enough

Jay.lee