beautypg.com

5 framing error detection -17, 5 framing error detection – Maxim Integrated MAXQ7666 User Manual

Page 235

background image

MAXQ7665/MAXQ7666 User’s Guide

6-17

6.5 Framing Error Detection

A framing error occurs when a valid stop bit is not detected. This results in the possible improper reception of the serial word. The
UART can detect a framing error and notify the software. Typical causes of framing errors are noise and contention. The framing error
condition is reported in the SCON0 register for the UART.

The framing error bit, FE, is located in SCON0.7. Note that this bit normally serves as SM0 and is described as SM0/FE0 in the regis-
ter description. Framing error information is made accessible by the FEDE (framing error detection enable) bit located at SMD0.0.
When FEDE is set to logic 1, the framing error information is shown in SM0/FE (SCON0.7). When FEDE is set to logic 0, the SM0 func-
tion is accessible. The information for bits SM0 and FE is actually stored in different registers. Changing FEDE only modifies which reg-
ister is accessed, not the contents of either.

The FE bit is set to 1 when a framing error occurs. It must be cleared by software. Note that the FEDE state must be 1 while reading
for writing the FE bit. Also note that receiving a properly framed serial word does not clear the FE bit. This must be done in software.

6.6 Serial UART Example: Asynchronous 10-Bit Output at 115,200 Baud

move SCON0.6, #1

; Set to mode 1 (10-bit asynchronous)

move SCON0.4, #1

; Enable receiver

move SMD0.1, #1

; Baud rate = 16 x baud clock

move PR0, #75F7h

; PR0 = 2^21 * 115200 / 8MHz (crystal)

move SCON0.0, #0

; Clear received character flag

move SCON0.1, #0

; Clear transmit character flag

Loop1:

move Acc, #'0'

; Start with '0' character

move LC[0], #10

; Transmit from '0' - '9'

Loop2:

move SBUF0, Acc

; Send character

Transmit:

move C, SCON0.1

; check transmit flag

jump NC, Transmit

; wait for transmit to complete

move SCON0.1, #0

; clear transmit flag

add #1

; increment character by 1

djnz LC[0], Loop2

jump Loop1

Maxim Integrated

This manual is related to the following products: