Connect with us

ATMEGA2560//Atmel Doccumentation Error?

Discussion in 'Microcontrollers, Programming and IoT' started by Fish4Fun, Mar 2, 2016.

Scroll to continue with content
  1. Fish4Fun

    Fish4Fun So long, and Thanks for all the Fish!

    Aug 27, 2013
    In the Data Sheet for the ATMEGA2560 the following code example is given to initialize a UART:

    Assembly Code Example(1)
    ; Set baud rate
    sts UBRRnH, r17
    sts UBRRnL, r16
    ldi r16, (1<<U2Xn)
    sts UCRnA, r16
    ; Enable receiver and transmitter
    ldi r16, (1<<RXENn)|(1<<TXENn)
    sts UCSRnB,r16
    ; Set frame format: 8data, 1stop bit
    ldi r16, (2<<UMSELn)|(3<<UCSZn0)
    sts UCSRnC,r16
    (Taken from Page 211, 2549P–AVR–10/2012)
    Great News....It works! However, later on in the documentation.....

    The UMSELn Table Breakdown of the UCSRnC Registers shows:

    Table 22-4. UMSELn Bits Settings
    UMSELn1 UMSELn0 Mode
    0 0 Asynchronous USART
    0 1 Synchronous USART
    1 0 (Reserved)
    1 1 Master SPI (MSPIM)
    (Taken from Page 225, 2549P–AVR–10/2012)
    When it is all said and done, $86 is the most commonly used setting for RS232-TTL type comm, which obviously shows UCSRnC.7 as being Set and USCRnC.6 as being cleared....But the results of the "example code" work perfectly, LoL! Not a huge deal until you run into a comm port that isn't responding correctly and you are pulling your hair out attempting to get it to work.....

    For giggles i will point out that the ACTUAL PROBLEM I was having had nothing to do with my code or the UART settings.....Turns out the last batch of ARDUINO 2560 Clones I received have a silkscreen error! LoL, the Rx and Tx pins are mislabeled on UART1 (simply reversed).....It turns out that there isn't a register setting to make the Rx line transmit!

    I caught the apparent Atmel Documentation Error while attempting to figure out why I couldn't Tx to a slave device.....Likely the documentation has been updated, or there has been a "Notice" of some sort about the apparent error, but I found the Actual Problem before I found any reference to the contradiction.....

    Six hours of my life wasted....but other than that no real harm or foul.


    Arouse1973 likes this.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day