Owner manual

149
ATmega8515(L)
2512A–AVR–04/02
Accessing
UBRRH/UCSRC
Registers
The UBRRH Registershares the same I/Olocation as the UCSRC Register.Therefore
some specialconsideration must betaken when accessing thisI/Olocation.
Write Access When doing a write access of thisI/Olocation, the highbit of thevalue written, the
USART RegisterSelect (URSEL) bit,controls which one of thetwo registers that will be
written. If URSEL iszero during a write operation, the UBRRH value will beupdated. If
URSEL is one, the UCSRCsetting will beupdated.
The following codeexamplesshowhow to access thetwo registers.
Note: 1. Theexample codeassumes that the part specificheaderfileis included.
As the codeexamples illustrate,write accesses of thetwo registers are relatively unaf-
fected of the sharing ofI/Olocation.
Assembly Code Examples
(1)
...
;
Set UBRRH to 2
ldi r16,0x02
out UBRRH,r16
...
;
Set the USBS and the UCSZ1 bit to one, and
;t
he remaining bits to zero.
ldi r16,(1<<URSEL)|(1<<USBS)|(1<<UCSZ1)
out UCSRC,r16
...
CCode Examples
(1)
...
/*
Set UBRRH to 2
*/
UBRRH = 0x02;
...
/*
Set the USBS and the UCSZ1 bit to one, and
*/
/*
the remaining bits to zero.
*/
UCSRC = (1<<URSEL)|(1<<USBS)|(1<<UCSZ1);
...