0% found this document useful (0 votes)
21 views

C Program Micro

This document summarizes a simple C program that controls an output pin on a microcontroller. The program uses #include and #use directives to configure the microcontroller. It defines a main function containing two calls - one to set the pin low and another to set it high. The summary explains the basic structure of C programs including the use of comments, directives, functions, and semicolons to terminate statements.

Uploaded by

cristianciublea
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

C Program Micro

This document summarizes a simple C program that controls an output pin on a microcontroller. The program uses #include and #use directives to configure the microcontroller. It defines a main function containing two calls - one to set the pin low and another to set it high. The summary explains the basic structure of C programs including the use of comments, directives, functions, and semicolons to terminate statements.

Uploaded by

cristianciublea
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

http://www.swarthmore.edu/NatSci/echeeve1/Ref/C%20for%20PIC/C_Intro.

html

A very simple C program is shown below.

/*simple.c -- sets a pin low, then high*/


#INCLUDE <16F873.h>
#USE DELAY (CLOCK=4000000)
void main() {

output_low(pin_C1);
output_high(pin_C1);
}

This program has many common features of C programs. The first line is a comment that
is ignored by the compiler. It is simply there to document what the program code does.
A comment is anything that occurs between a "/*" and the subsequent "*/". The next line
is a "directive". All directives begin with a "#" and are used to convey information to the
compiler. The directive in this program tells the compiler to include a header file
("16F873.h") which is necessary when using the microcontroller’s input and output
capabilities. The next two directives tell it how to configure the device, and how fast it
goes. The next line tells the compiler that this is the "main" program, and that everything
between the opening brace, {, and the matching closing brace, , constitutes the main
program. The main program itself is only two lines. The first line (not a comment) is a
call to the "output_low" function, which sets output pin pin_C1 low, and a call to
output_high, which sets it high. . Note that after every program statement there is a semi-
colon. This is very important.

You might also like