Getting Started

(lily) #1

Chapter 4: C Types, Operators, and Expressions


unsigned
is used in the definition of a char variable: ‘unsigned



  1. Many C compilers will have ‘byte’ or ‘Byte’
    ’. The ‘byte’ keyword is not part of C, but it is
    en nce in microcon e se a lot of numbers, but
    t a lot of ‘


n AVR mi
2768 to + cla ith ‘u value from
65535.

long an it
verybody else makes that dumb joke at this point, so why be different?

is stored in bytes of RAM, Random
dresse es that provide an alias
for the ing e’ll gory details in the ‘Variables
Externa


Const


onstants are data that cannot be changed by the program and are usually stored
e wherever
eeded, but that will get old quick, so we alias the value with a name. We usually
o this tart of the software module, which adds the
dvantage that if we ever want to change the constant we can do it once in the
convention, constant
ames are all caps. For example we might want to use pi in calculation (pi
at data type) so we define as follows:

If the modifier unsigned
char’, the value is from 0 to
defined as equaling ‘unsigned char
very conv ient, si trollers w usually u
no char’acters.


int
O crocontrollers int declares a 16 bit data variable as having values from
–3 32767. A variable de red w nsigned int’ will have a
0 to


The d short of
E
You can declare variables as ‘short int’ and ‘long int’. For C the size is machine
dependent, but on many systems a short int is the same as an int, 16 bits, while a
long int is 32 bits.


Variable Names


The changeable data you are processing
Access Memory, at specific da s. Variables are nam
address be used. W look at the
l, Static, and Register’ section of.


ants


C

in ROM, Read Only Memory. We could just type in the constant valu
n
d in a header file or at the s
a
definition instead of at each occurrence in the code. By
n
containts a decimal so we use the flo


#define PI 3.1415926
Free download pdf