English
Language : 

AS8218_1 Datasheet, PDF (110/123 Pages) ams AG – Highly Integrated Single Phase 2 Current Energy Metering Integrated Circuits
Data Sheet AS8218 / AS8228
The UART1 asserts an interrupt whenever flag SCON.RI is ‘1’ or SCON.TI is ‘1’. These flags are set if a
successful receive or transmit operation has taken place. The flags to SCON.RI and SCON.TI must be cleared
by software. The MCU program branches to the interrupt routine if the serial interrupt is enabled in the IE
register, with IE.4 (= ES) = ‘1’. Since SCON.RI and SCON.TI are linked together (logic-or), there is a common
interrupt service routine for both transmitting and receiving. The interrupt service routine has to decide which
event triggered the interrupt request (by querying the flags RI and TI). It is important to clear the flags before
leaving the interrupt service routine.
Multiprocessor Communications
Mode 2 has a special provision for multiprocessor communications. In this mode, a 9th data bit is received and
goes into RB8. Then a stop bit follows.
The port can be programmed such that when the stop bit is received, the serial port interrupt will be activated
only if RB8 = 1. This feature is enabled by setting bit SM2 in SCON. A way to use this feature in multiprocessor
systems is as follows:
When the master processor wants to transmit a block of data to one of several slaves, it first sends out an
address byte which identifies the target slave. An address byte differs from a data byte in that the ninth bit is 1
in an address byte and 0 in a data byte. With SM2 = 1, no slave will be interrupted by a data byte. An address
byte, however, will interrupt all slaves, so that each slave can examine the received byte and see if it is being
addressed. The addressed slave will clear its SM2 bit and prepare to receive the data bytes that will be
coming. The slaves that were not being addressed leave their SM2s set and go on about their business,
ignoring the coming data bytes.
Modes
The UART1 can be used in two different modes: mode 0 (= mode 1) and mode 2 (= mode 3). The mode
selection is due the bits SM0, SM1 in the SCON register.
Mode 0 and 1
8 bit UART1 with variable baudrate controlled by the baudrate generator.
WrStrobeSFR
TransmitEnable
TransmitSBUF
Transmitting
EndOfTransmission
TxD
TI
001000010010 000100001001 000010000100 000001000010 000000100001 000000010000 000000001000 000000000100 000000000010
Start Bit
1
0
0
1
0
0
0
0
Stop Bit
Figure 29: Transmitting in mode 1: here ‘09h’ is sent. The resulting bit stream on the TxD line is:
start bit (=‘0’) + ‘10010000’, for LSB is sent first.
The process of transmitting is initiated by writing to SBUF. The byte written to SBUF is held in register
TransmitSBUF. The transmission starts with the next 1-pulse on the internal signal TransmitEnable. Output TxD is
driven with a start bit (‘0’), eight data bits with the LSB first shifted out from TransmitSBUF, and a stop bit (‘1’). At
Revision 3.0, 31-May-06
Page 110 of 123