Rainbow-electronics ATmega8515L Bedienungsanleitung Seite 150

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 223
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 149
150
ATmega8515(L)
2512A–AVR–04/02
Read Access Doing a read access to the UBRRH or the UCSRC Register is amore complex opera-
tion. However, in mostapplications, it israrely necessary to read any of these registers.
The read access iscontrolledbyatimedsequence. Reading the I/Olocation once
returns the UBRRH Registercontents. If the registerlocation wasread in previous sys-
tem clock cycle,reading the register in the current clock cycle will returnthe UCSRC
contents. Note that thetimedsequence forreading the UCSRC is an atomic operation.
Interrupts musttherefore be controlled(e.g.,bydisabling interrupts globally) during the
read operation.
The following codeexample shows how to read the UCSRC Registercontents.
Note: 1. Theexample codeassumes that the part specificheaderfileis included.
Theassembly codeexample returns the UCSRC value in r16.
Reading the UBRRHcontents is not an atomic operation and thereforeitcan be read as
an ordinary register, aslong as the previous instruction did not access the register
location.
USART Register
Description
USART I/O Data Register –
UDR
The USART Transmit Data Bufferregister andUSART Receive Data Buffer Registers
sharethe same I/O address referred to asUSART Data Register orUDR. TheTransmit
Data Buffer Register(TXB) will bethe destination fordata writtentothe UDR Register
location. Reading the UDR Registerlocation will returnthe contents of theReceive Data
Buffer Register(RXB).
For 5-, 6-, or7-bit characters theupper unusedbitswill beignoredbytheTransmitter
andset to zero by theReceiver.
Assembly Code Example
(1)
USART_ReadUCSRC:
;
Read UCSRC
in r16,UBRRH
in r16,UCSRC
ret
CCode Example
(1)
unsigned char USART_ReadUCSRC( void )
{
unsigned char ucsrc;
/*
Read UCSRC
*/
ucsrc = UBRRH;
ucsrc = UCSRC;
return ucsrc;
}
Bit 76543 210
RXB[7:0] UDR (Read)
TXB[7:0] UDR (Write)
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value00000000
Seitenansicht 149
1 2 ... 145 146 147 148 149 150 151 152 153 154 155 ... 222 223

Kommentare zu diesen Handbüchern

Keine Kommentare