sherazi
Banned
- Joined
- Feb 15, 2010
- Messages
- 388
- Helped
- 61
- Reputation
- 126
- Reaction score
- 61
- Trophy points
- 1,318
- Location
- Muscat, Oman, Oman
- Activity points
- 0
hi friends..
i have a circuit[attached] on Pcb, for rs 485 and am using avr atmega8, now when i make the power on and conncet the rs485 to pc using rs485-rs232 converter using hyper terminal i get this error "cannot open COM Port3 check port settings"
now when the power is removed this msg is not displayed, moreover if just avr is removed from socket even then the msg doesnt appear ...
i dont know why? com port is set, baud rate and data bits parity and stop bit settings are same,on pc as well as avr..and i had used the same type of program before on a prototype that was OK,
i would like to share the test code also
i have a circuit[attached] on Pcb, for rs 485 and am using avr atmega8, now when i make the power on and conncet the rs485 to pc using rs485-rs232 converter using hyper terminal i get this error "cannot open COM Port3 check port settings"
now when the power is removed this msg is not displayed, moreover if just avr is removed from socket even then the msg doesnt appear ...
i dont know why? com port is set, baud rate and data bits parity and stop bit settings are same,on pc as well as avr..and i had used the same type of program before on a prototype that was OK,
i would like to share the test code also
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
Void USART_Transmit(unsigned char data)
{
PORTC &=~0x20;//pc5 is used for enable of ma
while (!(UCSRA & (1<<UDRE))) sleep();
UDR = data;
}
unsigned char USART_Receive(void)
{
PORTC |=0x20;//PC5 is used for enable of max
while (!(UCSRA & (1<<RXC))) sleep();
return UDR;
}
void USART_Init(void)
{
// USART settings: 4800 baud 8-n-1
UBRRH = 0;
UBRRL = 207;
UCSRB = (1<<RXEN) | (1<<TXEN);
UCSRC = (1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0);
}
main()
{
USART_Init();
USART_TransmitString("OK!\r\n");
for (;;)
{
USART_Transmit(USART_Receive());
}
}