# Communication Atmega 8535 with RS232

Status
Not open for further replies.

#### dimas_lilik

##### Full Member level 2
I want to connect the 2 micro controller .
Atmega 8535 I used to take temperature data in some remote place. while 89S52, I use to view data and controls all Atmega 8535 ( 10 pcs).
Can anyone provide solutions for data communications between Atmega 8535 and 89S52 by using the RS232

#### nandhu015

Here is a tutorial for atmega

Code:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=45341

and here is for 8051

Code:
http://8052.com/tutser.phtml

set the same baud rate in both avr and 8051 and communication will be fine

#### dimas_lilik

##### Full Member level 2
thanks Nandhu, I'll try, although I am still confused with the Cristal clock on Atmega 8535 (4 MHz) and 89s52 (11 MHz). Does not affect the baud rate?

#### nandhu015

dimas_lilik said:
thanks Nandhu, I'll try, although I am still confused with the Cristal clock on Atmega 8535 (4 MHz) and 89s52 (11 MHz). Does not affect the baud rate?

Sure, there will be problems. Select the crystals that supports standard baud rates.
For example 11.0592MHz (By the way i havnt seen 11.000MHz crystal).

#### ChrisC

##### Member level 2
dimas_lilik said:
thanks Nandhu, I'll try, although I am still confused with the Cristal clock on Atmega 8535 (4 MHz) and 89s52 (11 MHz). Does not affect the baud rate?

It can do, although bear in mind that the actual baud rate can vary by up to 2% (though a variation of 1% or less is generally preferred) from the ideal rate, which gives you a bit of flexibility when it comes to clocking the UART from a system clock which isn't baud-rate friendly. I don't know about the 8952, but the AVR datasheets have a pretty good section on baud rate selection including tables of precalculated settings across a wide range of system clock frequencies, showing the error % for each baud rate.

So whilst using a baud-rate friendly system clock frequency is generally the best option if you're doing a lot of UART-based comms, if there are other constraints on the design which prevent you from doing this then it isn't the end of the world. The very first embedded system I worked on commercially was an 8535 (the original AT90S version, not the ATmega one you've got...) based HVAC controller clocked at 8MHz, which would quite happily chuck data back and forth across its UART all day long at 9600 and 38400 baud with no errors. We had 80 of them set up in the test department running 24/7 with continuous monitoring/logging, and whilst I did get quite a few fault reports (how else can you learn if you don't make mistakes!) the only comms-related ones were all down to firmware bugs - not once did any of those controllers (nor the thousands more that were subsequently installed around the world in the time I was with the company) have any comms problems at the hardware level.

#### dimas_lilik

##### Full Member level 2
Ok, Thanks for Nandhu and Chrisc. I will try

Status
Not open for further replies.