RS232 over USB on linux

NetElemental:
I found the problem, if anybody runs into this in the future - while my code seemed to be set up at 9600 bps, when I set my terminal to receive at 1200 bps I got the correct output. I’m not sure what’s up with that, but whatever, I’ll go for it. If anybody does know, however, I would be very interested.

Thanks for all the great help!

I was pretty confused with this as well. I tried a few values of baudrate and I also didn’t know what was the clock freq of my AVR (Im a noob). I read some of the data sheets (the big 300+ page manual) and it started to make more sense.

So after much trying, I found out that you can use the default multiplier (16) up to 4800 bauds. If you jump to 9600, there’s too much errors or something (the data specs also show this), and it shows garbage. If you want more than 4800 bauds in asynchronous mode, you can set the U2X bit in the USCRA register to 1, and then the multiplier is 8 and you can get higher frequencies. I havent tried more than 9600 though.

This is more or less what I have now:

/* This is the default clock speed (for the uc and the UART) for the AVR Atmega32 */
#define OSCSPEED	1000000		/* in Hz */
	/* U2X
	 * Writing this bit to one will reduce the divisor of the baud
	 * rate divider from 16 to 8 effectively doubling the transfer
	 * rate for *asynchronous* communication.
	 */
    UCSRA = UCSRA | 0b00000010;
    unsigned int BaudRate = OSCSPEED / (8 * Baud) - 1;		
    //set BaudRate into registers
    UBRRH = (unsigned char) (BaudRate>>8);
    UBRRL = (unsigned char) BaudRate;