Professional Documents
Culture Documents
AND
EMBEDDED SYSTEMS
MICROPROCESSOR VS MICROCONTROLLER
Conti..
1.
2.
3.
4.
5.
6.
7.
8051 Family
8051 PROGRAMMING IN C
The reasons for writing programs in C
It is easier and less time consuming to
write in C than Assembly.
C is easier to modify and update
You can use code available in function
libraries.
C code is portable to other microcontroller
with little of no modification.
DATA TYPES
Data Type
Size in bits
Data range/Usage
Unsigned Char
0 to 255
signed Char
-128 to +127
Unsigned int
16
0 to 65535
signed int
16
-32,768 to +32,767
Sbit
bit
SFR
TIME DELAY
There are two way s to create a time delay in 8051 C
be mindful of three factors that can affect the accuracy of the delay
Compiler choice
Conti
Conti
Conti
LOGIC OPERATIONS
Logical operators
AND (&&), OR (||), and NOT (!)
Bit-wise operators
AND (&), OR (|), EX-OR (^), Inverter (~),
Shift Right (>>), and Shift Left (<<)
Conti
PIN DESCRIPTION
Conti
CONNECTION DIAGRAM
XTAL1 andXTAL2
The 8051 has an on-chip oscillator but requires
an external clock to run it.
1. A quartz crystal oscillator is connected to
inputs XTAL1 (pin19) and XTAL2 (pin18).
2. The quartz crystal oscillator also needs two
capacitors of 30 pF value.
Conti
1.
2.
RESET
i.
ii.
EA PIN
Conti
PORT 3
Port 3 can be used as input or output.
Port 3 does not need any pull-up resistors.
Port 3 has the additional function of providing
some extremely important signals.
TIMER PROGRAMMING
Conti
Both timers 0 and 1 use the same register, called TMOD
(timer mode), to set the various timer operation modes.
TMOD is a 8-bit register
The lower 4 bits are for Timer 0
The upper 4 bits are for Timer 1
In each case,
I.
The lower 2 bits are used to set the timer mode
II.
The upper 2 bits to specify the operation
Conti
Conti
??????