hi friends!
i wanted to implement rs485 communication b/w an avr and a pc.. the reason being distance up to 50 m b/w the two.. i am using the max485 ic, being the first time for such project wanted help and guidence.. i have a rs232-485 converter that i am going to use.
as far as my thw knowledge i have upto now is that aprt from being half duplex, there is no other big difference in coding.
i have the following code for initialization,
well i am using 4800 baud rate because the other functions best suit 1mhz freq.
for a test program that just listens for a byte and echos it back to pc
is this all ok, plz comment on code and give a better one if available....
thanx in advance
if someone can guide me to a tutorial on hyper terminal that would be really a great help...
i wanted to implement rs485 communication b/w an avr and a pc.. the reason being distance up to 50 m b/w the two.. i am using the max485 ic, being the first time for such project wanted help and guidence.. i have a rs232-485 converter that i am going to use.
as far as my thw knowledge i have upto now is that aprt from being half duplex, there is no other big difference in coding.
i have the following code for initialization,
Code:
char ReceivedByte;
UCSR0B |= (1 << RXEN0) | (1 << TXEN0); // Turn on the transmission and reception circuitry
UCSR0C |= (1 << UCSZ00) | (1 << UCSZ01); // Use 8-bit character sizes
UBRR0L = 0x0c; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register
UBRR0H = 00; // Load upper 8-bits of the baud rate value into the high byte of the UBRR register
well i am using 4800 baud rate because the other functions best suit 1mhz freq.
for a test program that just listens for a byte and echos it back to pc
Code:
for (;;) // Loop forever
{
//enable_rx;
PORTD|=0x01;
while ((UCSR0A & (1 << RXC0)) == 0) {}; // Do nothing until data have been recieved and is ready to be read from UDR
ReceivedByte = UDR0; // Fetch the recieved byte value into the variable ByteReceived"
//enable_tx
PORTD&=0xFE
while ((UCSR0A & (1 << UDRE0)) == 0) {}; // Do nothing until UDR is ready for more data to be written to it
UDR0 = ReceivedByte; // Echo back the received byte back to the computer
}
thanx in advance
if someone can guide me to a tutorial on hyper terminal that would be really a great help...