avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Help setting up USART on ATmega32 in C


From: Rick Mann
Subject: [avr-gcc-list] Help setting up USART on ATmega32 in C
Date: Fri, 13 Feb 2004 18:38:29 -0800

Hi. Sorry if this really isn't the right place for this question.

I'm trying to set up the USART on an ATmega32 (4.000 MHz) in C, with the following code:

void
sendMMCByte(char inByte)
{
        while (!(UCSRA & _BV(UDRE)));
        
        UDR = inByte;
}


int
main (void)
{
        UBRRH = 0;                              //      Set baud rate of 38400
        UBRRL = 6;
        UCSRA = 0;
        UCSRB = _BV(TXEN);              //      Enable the transmitter
        UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);
        
        sendMMCByte(0xd0);
        sendMMCByte(0x01);
        sendMMCByte(0x04);
        sendMMCByte(0xfe);
        sendMMCByte(0x00);
        sendMMCByte(0x02);
        sendMMCByte(0x00);
        sendMMCByte(0xd5);
}


Although I see a pulse train on the oscilloscope, I'm not sure the bit rate is correct. I've also tried using the speed doubling feature with a value of 12.

Any ideas?

Thanks!

--
Rick


--
"A facility for quotation covers the absence of original thought."
                                               --Lord Peter Wimsey



reply via email to

[Prev in Thread] Current Thread [Next in Thread]