Getting Started

(lily) #1

Chapter 4: C Types, Operators, and Expressions


of a mi ocontroller it is a place where outside voltages (0v or 3v) can be read or


t? And I bet you get the joke at the beginning of
is section.

ystem used in
icrocontrollers. It has a base of 16, that is 16 states per digit:

, 8, 9, A, B, C, D, E, and F.

nce we u th e 10 b n digits, fingers if you
unt the th finger, ount wi lp to imagine an alien with
fingers, yet: 4 h ith th , a
xadecima is pr d by byte representation of the
cimal nu s 0x he dec equivalents of the hex
bers ar

00 = 0x
= 0x
2 = 0010 = 0x2

0101 = 0x5
0x6

9 = 1001 = 0x9
0 = 0xA
11 = 1011= 0xB
00 = 0xC
13 = 1101 = 0xD
14 = 1110 = 0xE
15 = 1111 = 0xF


cr
set.


We use binary and hexadecimal numbers for ports because it is cumbersome and
non-intuitive to think of port data as decimal numbers, Quick, what will 66 look
like on our LEDs? Quick, what will 01000010 look like on our LEDs? Since
01000010 = 66, you see my poin
th


The hexadecimal system is another commonly seen number s
m


0, 1, 2, 3, 4, 5, 6, 7

Si se numbers to e bas ecause we have te
co umb as a to c th. It might he
16 or better ands w ree fingers and on thumb on each. In C
he l number ecede 0x. The hex
de mber 129 i 81. T imal and binary
num e:


0 = 00 0
1 = 0001 1


3 = 0011 = 0x3
4 = 0100 = 0x4
5 =
6 = 0110 =
7 = 0111 = 0x7
8 = 1000 = 0x8


10 = 101


12 = 11

Free download pdf