4-10
Function Argument
Baud Rate
1
110
2
150
3
300
4
600
5
1200
6
2400
7
4800
8
9600
9
19,200 (default)
10
38,400
11
57,600
12
76,800
13
115,000
14
230,000
15
460,800
16
1 Meg
Table 4.1 Baud rate values
After initialization by calling
s1_init()
, SER1 is configured as a full-duplex serial port and is ready to
transmit/receive serial data at one of the specified 16 baud rates.
An input buffer,
ser1_in_buf
(whose size is specified by the user), will automatically store the receiving
serial data stream into the memory by macro service operation. In terms of receiving, there is no software
overhead or interrupt latency for user application programs even at the highest baud rate. Macro service
transfer allows efficient handling of incoming data. The user only has to check the buffer status with
serhit1()
and take out the data from the buffer with
getser1()
, if any. The input buffer is used as a
circular ring buffer, as shown in Figure 4.1. However, the transmit operation is interrupt-driven.
ibuf
in_tail
ibuf+isiz
in_head
Figure 4.1 Circular ring input buffer
The input buffer (ibuf), buffer size (isiz), mode (mode), and baud rate (baud) are specified by the user with
s1_init()
.The mode is the setting value for the serial port control register. A value of 0xC9 will set the
serial port in the following manner:
transmit enable, receive enable, no parity, 8 data bits, 1 stop bit
Due to the nature of high-speed baud rates and possible effects from the external environment, serial input
data will automatically fill in the buffer circularly without stopping, regardless of overwrite. If the user does
not take out the data from the ring buffer with
getser1()
before the ring buffer is full, new data will
overwrite the old data without warning or control. Thus it is important to provide a sufficiently large buffer
if large amounts of data are transferred. For example, if you are receiving data at 9600 baud, a 4 KB buffer
will be able to store data for approximately four seconds.