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

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

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


From: Rick Mann
Subject: Re: [avr-gcc-list] SOLVED: Help setting up USART on ATmega32 in C
Date: Mon, 16 Feb 2004 19:39:03 -0800

I was pretty stupid. I didn't realize that the 4 MHz crystal wasn't being used; that I'd forgotten to change the clock source from the 1MHz internal osc to the crystal; so my baud rate calculations were off.

Thanks to all who helped.

On Feb 13, 2004, at 11:54 PM, Jack Valmadre wrote:

The ATmega32 datasheet contains C code to send and receive using USART.
Try using them.
Jack


-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of Rick Mann
Sent: Saturday, 14 February 2004 12:38 PM
To: address@hidden
Subject: [avr-gcc-list] Help setting up USART on ATmega32 in C

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


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list



--
"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]