AVR Programmer and Serial I/O

Hello, I am trying to use the virtual serial port on the AVR usb programmer to output to a putty terminal session.
This is on a ATMEGA168. The sample code I found is below. I am using the built-in 8Mhz clock on the AVR.
I am getting data transmitted, back to putty, but it is garbled. I have putty also setup for 9600/8/N/1.
Any hints on what I am missing?

void serial_init(unsigned int bittimer)
{
	/* Set the baud rate */
	UBRR0H = (unsigned char) (bittimer >> 8);
	UBRR0L = (unsigned char) bittimer;
	/* set the framing to 8N1 */
	UCSR0C = (3 << UCSZ00);
	/* Engage! */
	UCSR0B = (1 << RXEN0) | (1 << TXEN0);
}

void serial_write(unsigned char c)
{
	while ( !(UCSR0A & (1 << UDRE0)) )
		;
	UDR0 = c;
}

#define SPEED 9600
int main (void)
{
	serial_init( ( F_CPU / SPEED / 16 ) - 1);

	while (1) {
		serial_write('A');
		_delay_ms(2);
	}

	return 0;
}

Never mind, got it working.

Hello, lamikam.

I’m glad you got it working. What was wrong?

–David

I had the wrong processor speed selected (CDIV8 flag).