Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] USART on mega48

2006-10-06 by Aaron

bibin john wrote:

>see these links
>   
>  http://booksbybibin.14.forumer.com/viewtopic.php?t=119
>  http://booksbybibin.14.forumer.com/viewtopic.php?t=108
>  http://booksbybibin.14.forumer.com/viewtopic.php?t=122
>  http://booksbybibin.14.forumer.com/viewtopic.php?t=118
>  http://booksbybibin.14.forumer.com/viewtopic.php?t=120
>
>   
>  Bibin John
>  www.bibinjohn.tk
>
>  
>
Wow, very comprehensive write-up... thanks for the links.



John Samperi wrote:

>
>Remember that the USART in the Mega 48/88/168 is **NOT** in the
>I/O space but in RAM space therefore the code example in the data
>sheet will NOT WORK. You will need to use STS/LDS to access the
>USART's registers. Holler if you want more info :-)
>  
>
Well, the compiler was taking care of that for me.

----------

After looking at the listing of the generated code, I am happy to report 
that I did find the problem.
However, I am unhappy to report the amount of time it took, so I won't.  :)

Anyway, I had written:

    void USART_transmit (unsigned char data)
    {
        while (!(UCSR0A & (1<<UDRE0)))    // wait for empty transmit buffer
        UDR0 = data;                    // send the data
    }


When I should have written:

    void USART_transmit (unsigned char data)
    {
        while (!(UCSR0A & (1<<UDRE0)))    // wait for empty transmit buffer
            ;                           <------------------ SEE WHAT I 
FORGOT??????
        UDR0 = data;                    // send the data
    }


duhhh!!!

Aaron

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.