USART communication with an ATmega1284P

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

Hi Guys,

 

I have put together a small test circuit on my breadboard, here it is what I have

- ATmega1284P with external 20MHz crystal, FUSEs are set, I could blink a LED properly

- A PL2303 USB to serial converter, where the PIN2 of the DSUB 9 (http://mitya.madein.hu/ss/rZDHSE...) is connected to PIN15 (http://mitya.madein.hu/ss/YUMDrb...)

 

I wanted to set up 9600 baud, 8 databits, no parity bit and one Stop bit.

 

Here is my result:

http://mitya.madein.hu/ss/cRWgmQ...

 

You can see how I initialized UCSR0C (in the above pic) and also you can see that I send a 'c' in every second, but on the PC side I receive 'N' for some reason.

You can see the minicom's settings as well.

What can be wrong ?

 

What else info do you guys need to be able to help me ?

 

Thanks,

Misi

This topic has a solution.
Last Edited: Sat. Mar 3, 2018 - 12:02 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ZMitya wrote:
A PL2303 USB to serial converter, where the PIN2 of the DSUB 9 (http://mitya.madein.hu/ss/rZDHSE...) is connected to PIN15 (http://mitya.madein.hu/ss/YUMDrb...)

 

Your converter follows the RS-232 specification, which uses +-12V signals with negative logic(-12V is 1, +12V is 0). The AtMegab uses TTL/CMOS signals with 0V/5V (or whatever your VCC is) with positive logic (5V is 1, 0V is 0). This is completely incompatible.

You could build a converter if you have any small signal transistor laying around. From MCU to PC probably works with 0V/5V signals, but the polarity is wrong. For the other direction, you must definitely use a level shifter or you might fry your AtMega. It won't like 12V!

-Patrick

 

"Some people die at 25 and aren't buried until 75." -Benjamin Franklin

 

What is life's greatest illusion?"  "Innocence, my brother." -Skyrim

 

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

ZMitya wrote:
A PL2303 USB to serial converter, where the PIN2 of the DSUB 9 (http://mitya.madein.hu/ss/rZDHSE...) is connected to PIN15 (http://mitya.madein.hu/ss/YUMDrb...)
A D-SUB-9 connector implies RS-232 signal levels. You can't connect that directly to the AVR. You either need additionally a RS-232/TTL converter, or an USB/Serial converter with TTL levels.

Stefan Ernst

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

pawi777 wrote:

Your converter follows the RS-232 specification, which uses +-12V signals with negative logic(-12V is 1, +12V is 0). The AtMegab uses TTL/CMOS signals with 0V/5V (or whatever your VCC is) with positive logic (5V is 1, 0V is 0). This is completely incompatible.

You could build a converter if you have any small signal transistor laying around. From MCU to PC probably works with 0V/5V signals, but the polarity is wrong. For the other direction, you must definitely use a level shifter or you might fry your AtMega. It won't like 12V!

-Patrick

 

 

pfff :(

 

Thank you very much guys ...

I need to learn a lot... 

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

Note that there are inexpensive USB<->TTL converters also on eBay.  (some titles appear to claim "universal"...)

https://www.ebay.com/itm/USB-2-0...

https://www.ebay.com/itm/USB-To-...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

This whole thing was discussed only yesterday: https://www.avrfreaks.net/comment...

 

 

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

theusch wrote:

Note that there are inexpensive USB<->TTL converters also on eBay.  (some titles appear to claim "universal"...)

https://www.ebay.com/itm/USB-2-0...

https://www.ebay.com/itm/USB-To-...

 

Thanks for this. Firstly I think I will try to solve my issue with a MAX232. Just for my curiosity. Once I know how it works, then I will buy these stuff :)

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

awneil wrote:

This whole thing was discussed only yesterday: https://www.avrfreaks.net/comment...

 

sorry for that .. :(

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

Hi Guys,

 

Let me continue this thread if possible.

 

So today I bought a MAX3232 connected to my AT and it seems to be working well. I can see the 'c' coming at the PC side.

 

However I realized that right after when I connect the battery to the circuit, the AT sends a few '0's rather than 99 (aka 'c').

Is that because the MCU has not yet 'booted' / initialised yet ? Or why this happens ?

 

Here is the output:

 

Thanks,

Mitya

Last Edited: Sat. Mar 3, 2018 - 12:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The "junk characters at startup" issue  has now been taken to a separate thread: https://www.avrfreaks.net/forum/uart-communication-issue-atmega1284p

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...
Topic locked