
Working with Serial Ports 131
/**********************************************************************
*
* Function: helloWorld()
*
* Description: Send a text message to the serial port periodically.
*
* Notes: This outer loop is hardware-independent.
*
* Returns: This routine contains an infinite loop.
*
**********************************************************************/
void
helloWorld(void)
{
Timer timer;
SerialPort serial(PORTA, 19200L);
timer.start(10000, Periodic); // Start a periodic 10 s timer.
while (1)
{
serial.puts("Hello, World!"); // Output a simple text message.
timer.waitfor(); // Wait for the timer to expire.
}
} /* helloWorld() */
Though the periodicity has a different length, the general structure of this task is
the same as that of the flashRed function. So, the only thing left for us to discuss is
the makeup of the serial port driver. We’ll start with a description of a generalized
serial ports interface and then finish with the specifics of the serial controller
found on the Arcom board.
Working with Serial Ports
At the application level, a serial port is simply a bidirectional data channel. This
channel is usually terminated on each end with a hardware device called a serial
communications controller (SCC). Each serial port within the SCC—there are usu-
ally at least two serial ports per controller—is connected to the embedded proces-
sor on one side and to a cable