Serial communication problem in atmega328

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

1) Can i use avr studio in built serial monitor for receiving and transmitting the serial data from atmega 328 through serial communication .if yes then how ???
2) Also apart from Hercules terminal which serial monitor can i use for serial monitor .
3) I am currently using Hercules as serial monitor but it sometimes receive data( sometime it keeps on printing garbage values) and sometime does not.
I have rechecked and changed the fuse bytes and lock bytes still it does not print anything .
So is their problem in my programer or serial monitor that is Hercules????

This topic has a solution.

Kunal Gupta

github.com/gkunalupta

Last Edited: Tue. Jan 7, 2020 - 06:02 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Others can answer the Studio question.

 

Serial comms:

RS-232 and an "old" serial port or through a USB adapter?

 

M328:

Internal RC Oscillator, or external Crystal?

If using a crystal what is its frequency?

 

Does the M328 have a Divide Frequency by 8 Fuse, I don't recall off the top of my head?

 

What baud rate are you using?

 

Have you flashed an LED at once / Second to verify that the micro is actually running at the frequency you think it is running at?

 

There are many Terminal Emulator programs for a PC.

TeraTerm, Putty, and others.

 

Do you have an O'scope or a Logic Analyzer available to look at the serial port on the micro and see if it is sending data?

 

Your own PC board, or a commercial one?

 

JC

 

 

 

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

I am using external crystall oscillator of 16mhz .
I am using baud rate of 9600
And ftdi rs232 usb to TTL it has serial communication pins RX, TX

Kunal Gupta

github.com/gkunalupta

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

Kunalgupta wrote:
1) Can i use avr (sic) studio in built serial monitor for receiving and transmitting the serial data

Do you really mean AVR Studio (very old), or Atmel Studio (current) ?

 

https://www.microchip.com/mplab/avr-support/atmel-studio-7

 

But, whatever, I would suggest that you get a standard, well-known terminal application - and use that.

 

That way you are not tied to the IDE at all, and they are often much more capable!

 

Common examples include

 

TeraTerm -  https://ttssh2.osdn.jp/index.html.en

 

PuTTY -  https://www.chiark.greenend.org.uk/~sgtatham/putty/

 

Personally, I prefer TeraTerm - as it can give you a timestamped log of the comms.

 

But, as ever, each has its own special advantages & disadvantages.

 

Kunalgupta wrote:
sometime it keeps on printing garbage values

See Tip #2 - you will get this on any terminal when your Baud Rate is wrong!

 

It is such a common problem that it is also mentioned in the Signatures of several of the other regular contributors here!

 

EDIT

 

If you really want to see what is actually happening on the wires, you will need an oscilloscope - this will show you the "raw" behaviour of the signals before they get interpreted by the PC's UART (or the USB-to-Serial adaptor).

 

An oscilloscope is an invaluable (indispensable?) tool if you are serious about doing embedded microcontroller work ...

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: Thu. Dec 5, 2019 - 09:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
An oscilloscope is an invaluable (indispensable?) tool if you are serious about doing embedded microcontroller work ...

True, so is a logic analyzer, there are cheap ones of both, I would get the LA first and then if, no, when budget allows a good DSO oscope!!!! 

Jim

 

 

 

 

 

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

Kunalgupta wrote:
ftdi rs232 usb to TTL it has serial communication pins RX, TX

As answered in another of your posts, that is a confusing description of your interface, is it RS232, or TTL, it makes a BIG difference how it connects to the AVR tx/rx pins?

I have three terminal emulators on my PC, real term, putty, and tera term.   Each has features the others do not, so I use the one that works best for what I need at the time.

 

Jim

 

 

 

 

 

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

1) AVR/Atmel Studios 5, 6 and 7 have had a serial terminal built in. It's not very good. Was simply done as a summer project by a student intern so don't expect fireworks. Most people would choose a professional external program in preference

 

2) Teraterm, Realterm, Brays (renamed these days), Miinicom, Putty. A bit like whether your choose Ford or Chevrolet a lot of it comes down to person choice as to which to choose.

 

3) Well I guess any from (2) will isolate whether its problems in that particular software or whether it's a problem in the hardware or the AVR code.

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

thanks for the suggestion my query is solved

Kunal Gupta

github.com/gkunalupta

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

Please mark what post was the solution

Thanks

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

An after-note on terminology.

 

RS232 has +12V/-12V (nominal) signal levels.

 

Properly, TTL has logic levels of 0V/2.3V (nominal) which were logic levels from SN74xxx bipolar TTL logic. Nowadays, TTL is taken to have the logic levels of YOUR system. For example, if your MCU has Vcc = 5V, then TTL has 0V/5V signal levels. 

 

The terms "RS232" and "TTL" get confused with the term "asynchronous serial" (also known as "async serial"). RS232 and TTL refer to the logic levels of the signal. In addition, RS232 also defines behavior of some secondary signals. Neither refers to how the data is encoded, though RS232 is hardly ever used with anything other than asynchronous encoding. "Asynchronous" refers to the data transmission technique that does NOT require a clock to be part of the signal. This allows the two ends of the communications channel to be unsynchronized with respect to each other. In fact, there can be large delays. However, it DOES require that the two ends of the channel use timing that matches within a few percent of each other. 

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Fri. Dec 13, 2019 - 11:36 PM