2.5. PIC16 C Functions and Structure

• Program structure

• Functions, arguments

• Global and local variables

The structure of a C program is created using functions (Figure 2.11). This is a block of code written and executed as a self-contained process, receiving the required parameters (data to be processed) from the calling function and returning results to it. Main()is the primary function in all C programs, within which the rest of the program is constructed.

Figure 2.11. Hierarchical C Program Structure

When running on a PC, main() is called by the operating system, and control is returned to the OS when the C program is terminated. In the microcontroller, ...

Get Programming 8-bit PIC Microcontrollers in C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.