User manual
...the world's most energy friendly microcontrollers
2012-04-24 - Giant Gecko Family - d0053_Rev0.96 463
www.energymicro.com
USARTn_CLKDIV = 256 x (f
HFPERCLK
/(2 x brdesired) - 1) (17.4)
When the USART operates in master mode, the highest possible bit rate is half the peripheral clock rate.
When operating in slave mode however, the highest bit rate is an eight of the peripheral clock:
• Master mode: br
max
= f
HFPERCLK
/2
• Slave mode: br
max
= f
HFPERCLK
/8
On every clock edge data on the data lines, MOSI and MISO, is either set up or sampled. When CLKPHA
in USARTn_CTRL is cleared, data is sampled on the leading clock edge and set-up is done on the
trailing edge. If CLKPHA is set however, data is set-up on the leading clock edge, and sampled on the
trailing edge. In addition to this, the polarity of the clock signal can be changed by setting CLKPOL in
USARTn_CTRL, which also defines the idle state of the clock. This results in four different modes which
are summarized in Table 17.8 (p. 463) . Figure 17.15 (p. 463) shows the resulting timing of data
set-up and sampling relative to the bus clock.
Table 17.8. USART SPI Modes
SPI mode CLKPOL CLKPHA Leading edge Trailing edge
0 0 0 Rising, sample Falling, set-up
1 0 1 Rising, set-up Falling, sample
2 1 0 Falling, sample Rising, set-up
3 1 1 Falling, set-up Rising, sample
Figure 17.15. USART SPI Timing
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
USn_CLK
USn_CS
USn_TX/
USn_RX
CLKPOL = 0
CLKPOL = 1
CLKPHA = 0
CLKPHA = 1 X
X X
X
If CPHA=1, the TX underflow flag, TXUF, will be set on the first setup clock edge of a frame in slave
mode if TX data is not available. If CPHA=0, TXUF is set if data is not available in the transmit buffer
three HFPERCLK cycles prior to the first sample clock edge. The RXDATAV flag is updated on the last
sample clock edge of a transfer, while the RX overflow interrupt flag, RXOF, is set on the first sample
clock edge if the receive buffer overflows. When a transfer has been performed, interrupt flags TXBL
and TXC are updated on the first setup clock edge of the succeeding frame, or when CS is deasserted.
17.3.3.3 Master Mode
When in master mode, the USART is in full control of the data flow on the synchronous bus. When
operating in full duplex mode, the slave cannot transmit data to the master without the master transmitting
to the slave. The master outputs the bus clock on USn_CLK.
Communication starts whenever there is data in the transmit buffer and the transmitter is enabled. The
USART clock then starts, and the master shifts bits out from the transmit shift register using the internal
clock.