missing bits in io decriptors.

Go To Last Post
3 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


I am using Atmel studio 7 1417.

I am using a ATmega1284P

I am trying to get the USART in SPI master mode.

I copied the following code from the datasheet:

void USART_Init( unsigned int baud )
UBRRn = 0;

XCKn_DDR |= (1<<XCKn); // changed this with my own names in my example

UCSRnC = (1<<UMSELn1)|(1<<UMSELn0)|(0<<UCPHAn)|(0<<UCPOLn);

UCSRnB = (1<<RXENn)|(1<<TXENn);

UBRRn = baud;

as I am using USART0 for that, I replaced all the lower case 'n' s with '0'

and all the defines then are OK except for 1 that is not recognised "UCPHA0"


in the datasheet it looks exactly the same:


If on the UCSR0C register I click on "Goto implementation"

the file "iom1284p.h" opens and I jump to the USCR0C register, and there the following is described:


#define UCSR0C _SFR_MEM8(0xC2)
#define UCPOL0 0
#define UCSZ00 1
#define UCSZ01 2
#define USBS0 3
#define UPM00 4
#define UPM01 5
#define UMSEL00 6
#define UMSEL01 7


This does not match the datasheet.


Am I missing something here ?

or is this a thing that should be raised as a bug to atmel/microchip?


for now I will workaround adding "#define UCPHA0 1" to my code but that should in my opinion not be needed, so something is not right.


  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Note that your datasheet also has:


I took a test program and built for another family member ('164PA) and the chip-include has the same results.


Just for fun, I did the same in CodeVision and found it taken into account:

/* UCSR1C - USART Control and Status Register C */
#define    UCPOL1          0       // Clock Polarity
#define    UCSZ10          1       // Character Size
#define    UCPHA1          UCSZ10  // For compatibility
#define    UCSZ11          2       // Character Size
#define    UDORD1          UCSZ11  // For compatibility
#define    USBS1           3       // Stop Bit Select
#define    UPM10           4       // Parity Mode Bit 0
#define    UPM11           5       // Parity Mode Bit 1
#define    UMSEL10         6       // USART Mode Select
#define    UMSEL11         7       // USART Mode Select

IIRC, the GCC files are robot-built from chip-specification file.  Apparently "multi-use" bits aren't take into account?  Dunno.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Last Edited: Thu. Mar 23, 2017 - 08:52 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HI Lee,

thanks for verifying that the bits are actually missing.

I have just added the missing bit name in my Usart0 spi driver file with a note that this bit is missing in the include files from Atmel.

If Atmel in the future then decides to add this bit I will get a warning and can just comment it out as it is only valid in the spi mode of the usart.