Skip to content
Glenn Lopez edited this page Feb 13, 2016 · 4 revisions

What is the purpose of the preprocessor directive “# include”?

The preprocessor examines the code before actual compilation of code begins (akin to dependencies with respect to Bash scripting) and resolves all these directives before any code is actually compiled. These include files can be anything from identifiers to subroutines that are commonly used within the project.

Provide one reason why you would include the “ez8.h” header file in your programs if you will access PORTS in your programs?

If we dont include ez8.h, the code wouldn't compile because the compiler wouldn't know what to make of PAIN, PAOUT. PAIN and PAOUT are pre "#define"-ed macros in ez8.h telling your compiler what to do with PAIN or PAOUT.

What is “main()” in a C program?

"main()" contains instructions that tell the microcontroller to carry out whatever instructions you want (it's not required to do anything). All C language programs require a main() function; it doesn't really have to do anything other than be present inside your C source code.

Describe one difference between a “char” and an “int” variable?

char and int both hold integers (non-floating point/whole numbers ie: not 1.0, 1.9, 2.etc..). The only difference between them is that char datatypes holds 0 to 255 values (2^8) and int contains 0 - 65,536 (2^16). Use char when describing your age, size of your penis, or the letter of your bra cup (A, B, C). Use int when describing how long these classroom lectures seem to take in relative time.

What is the effect of this statement in your C program: #define PI 3.14159 ?

This define statement will translate every occurrence of the Constant 'PI' in the program to the floating-point integer '3.14159'. Similarly #define PAOUT (*((volatile unsigned long *)0x40025010)) is used to translate every instance of PAOUT to a registry manipulation (found in your ez8.h file).

For the following C statements, describe the actions that take place: int value; value=0x1a;

Variable "value" is assigned a value of 0x1a

How does “value1” differ from “value2”: int value1; unsigned int value2;

value1 can contain negative integers where as value2 is unsigned so it will not be possible to store negative integers in this variable.

How does a breakpoint affect the operation of your program and why would you use it?

Breakpoints don't get compiled so it does nothing. You can use it for debugging your code without having to delete it. ie: make use of //comment or /* comment */ to comment out code.

Clone this wiki locally