Skip to Content
Programming Embedded Systems in C and C++
book

Programming Embedded Systems in C and C++

by Michael Barr
January 1999
Beginner to intermediate
200 pages
7h 43m
English
O'Reilly Media, Inc.
Content preview from Programming Embedded Systems in C and C++
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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

You might also like

Embedded Systems Object-Oriented Programming in C and C++

Embedded Systems Object-Oriented Programming in C and C++

Israel Gbati

Publisher Resources

ISBN: 1565923545Catalog PageErrata