Rainbow-electronics ATmega8515L Manual de usuario Pagina 143

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 223
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 142
143
ATmega8515(L)
2512A–AVR–04/02
The receive function example reads all the I/Oregisters into the registerfile beforeany
computation isdone. This gives an optimalreceive buffer utilization sincethe buffer
location readwill be free to acceptnewdata as early aspossible.
Receive Compete Flag and
Interrupt
The USART Receiverhas one flag that indicates the receiverstate.
TheReceive Complete (RXC) flag indicates if thereareunreaddata present in the
receive buffer.Thisflag is one when unreaddata existinthe receive buffer, andzero
when the receive buffer is empty(i.e.,does not contain any unreaddata). If theReceiver
isdisabled(RXEN = 0), the receive bufferwill be flushed andconsequently theRXC bit
will become zero.
When theReceive Complete Interrupt Enable (RXCIE) in UCSRB isset, the USART
Receive Complete Interrupt will beexecuted aslong as theRXC flag isset (provided
that global interrupts areenabled). When interrupt-driven data reception is used, the
receive complete routine must read the receiveddata from UDRinorder to clear the
RXC flag, otherwiseanew interrupt will occur oncetheinterrupt routine terminates.
Receiver Error Flags The USART Receiverhas three errorflags: Frame Error(FE),Data OverRun (DOR) and
ParityError(PE).All can beaccessedbyreading UCSRA. Common for theerrorflags is
that they are located in the receive buffer togetherwith the frame forwhich they indicate
theerrorstatus. Due to the buffering of theerrorflags, the UCSRA must be readbefore
the receive buffer(UDR), since reading the UDR I/Olocation changes the bufferread
location. Another equalityfor theerrorflags is that theycan not bealteredbysoftware
doing a write to the flag location. However, all flags must be set to zero when the
UCSRA iswritten for upward compatibility offuture USART implementations. None of
theerrorflagscan generate interrupts.
The Frame Error(FE)flag indicates the state of the first stopbit of thenext readable
frame stored in the receive buffer.The FE flag iszero when the stopbit wascorrectly
read(as one), and the FE flag will be one when the stopbit was incorrect (zero).This
flag can beusedfordetecting out-of-syncconditions, detecting breakconditions and
protocolhandling. The FE flag is not affectedbythe setting of the USBS bit in UCSRC
sincethe receiver ignores all, except for the first,stopbits. Forcompatibilitywithfuture
devices, always set thisbit to zero when writing to UCSRA.
The Data OverRun (DOR)flag indicatesdata loss due to a receiverbufferfull condition.
A Data OverRun occurs when the receive buffer isfull (two characters), it is anewchar-
acterwaiting in theReceive ShiftRegister, and anewstart bit isdetected. If the DOR
flag isset there was one or more serialframe lost between the frame last readfrom
UDR, and thenext frame readfrom UDR. Forcompatibilitywithfuture devices, always
write thisbit to zero when writing to UCSRA. The DOR flag isclearedwhen the frame
receivedwassuccessfully movedfrom the Shift Register to the receive buffer.
TheParityError(PE) flag indicates that thenext frameinthe receive bufferhad a parity
errorwhen received. If paritycheck is not enabled thePEbit will always be readzero.
Forcompatibilitywithfuture devices, always set thisbit to zero when writing to UCSRA.
For more details see “ParityBit Calculation” on page 136 and “ParityChecker”onpage
144.
Vista de pagina 142
1 2 ... 138 139 140 141 142 143 144 145 146 147 148 ... 222 223

Comentarios a estos manuales

Sin comentarios