trouble with serial communication

Hello,
I'm having trouble sending data to the avr from my pc.I can send data to the pc but when I tried to send data to the avr it triggers a reset as if the i'm sending a program to it.
If it makes any difference it's a freeduino 1.20 usb from nkcelectronics.com ,which I might add, I had a very good time assembling.

[edit]
I suppose I should add that I'm using c and and the code I use looks some thing like this:

int main()
{
DDRB = 0xff;
UBRR0L = (F_CPU / (16UL* 19200UL))-1;
UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(RXCIE0);

uint8_t c = uart_getc();
/*blink light */
if(c)
PORTB = 0xff;

return 0;
}

I send data to the mcu by usin echo

echo a > /dev/ttyUSB0

[/edit]
thanks.

I think I got it.It appears that what was happening was that when I issued the command 'echo > /dev/ttyUSB0 ' things happen as follows:

  1. echo opens a the device file ,which seems to result in the arduino been reset.
  2. echo writes data to device file.
  3. echo exits and closes file,this seems to trigger another reset for arduino.

So in order to remedy this I use the command 'stty -F /dev/ttyUSB0 -hup' this disables 'hang up' upon all file-descriptors being closed.I think this should be mention on the wiki page refering to tty use.

By the way whats the maximum baud rate that can be used with the arduino?

thanks.

Hi Micah,
Good to hear you got it going.

Not sure but I think you can get up to 1M bps with an ATmega168 on a 16mhz clock but the Arduino only supports a baud rate up to 115200.

I wonder what the reason is you are not using the arduino abstractions to do the low level stuff in your code?