You are on page 1of 30

.

Hossam_elkady@hotmail.com



http://www.Qariya.com

:
) (Microcontroller )
(Microprocessor


.PIC


IC .
ic
: ic
c

.........

... c & vb



+


......

) = (

.....
..........

pic......
PIC
PIC ) (IC
Microchip
PIC16F84a
PIC16F84a
EEPROM
.
PIC16F84a 4 10
.

PIC
-1
-2 )(Parallel printer cable
-3 7 15
-4 PIC
-5 PIC

PIC
PIC16F84 a
# 35
# ) (Single Cycle ) (Branches
)(Two Cycle

13 # Input/Output
# )(Power Saving
#

data sheet
pic
http://www.microchip.com/download/l...6f8x/35007b.pdf
=============================

pic
hardwaer
==================================
..........

[ . DECIMAL , ] ,

,
10
800 , ,
, .

] [ 0,1,2,3,4,5,6,7,8,9
, ,

, ] [0 , ] [1. [2] , ]
, (Carry), ] [10
) ,(10=1^10 ] [ 0 )^10
, ) (9 , ) ( 9
) ( 100=10^2 )( 10 .
. , ,

, , ) ( 16 ,10 ,8 ,2
1
2

.
3 .
4 .

) ( 735 , 5 LSD
.Least Significant Digit 7 (MSD ) ,
)
( 3 ) ,
, 735 ) (7
) , (Most Significat Digit
( 3 . :
x 100 + 3 x 10 + 5 x 1 7 =735
= x 10^2 + 3 x 10^1 + 5 x 10^0 7
= 700+30+5

Binary

, , 2 ) , (0,1

) ( , ,
MSB LSB

) , , , , .... (
) , , , , , , ,
....(.
, , 900 , 1009
, . 41
.
10010 .
. , 1
161 ...... 16 , ,
. , 21 2
.
16 2 , 18 ,
10010 .
x 2^4 + 0 x 2^3 + 0 x 2^2 + 1 x 2^1 + 0 x 2^0 1 = 10010
= 18 = 0 + 2 + 0 + 0 + 16


) ( 2
37

:
37 2 18 1
18 2 9

9 2 4

4 2 2

2 2 1

1 2 0

, 37 , ) ( bit
.

37 = 100101

: ,
.

Octal

, 8 ) , ( 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 )
( 9 , 8 .


) ( 8
267

:
)(Lsd

267 8 33 3
33 8 4 1
)(MSD
4 8 0 4
,267 ,
.
267 413 .

Hexadecimal

Hex

, , 16 ,
0 9 ) ( A , B , C , D , E , F
) (F 15 ,
F ) (A23F , 23FF , F4 , DF , 123

HEX to Decimal


A23F

) ( ,4096 ) ( , 256 ) ( , 16 ) ( 1
A23F = 10 x 4096 + 2 x 256 + 3x16 + 15 x 1
= 15+ 48 + 512 + 40960
= 41535

1991

1991 16 124 7
124 16 7 12
7

16 0 7

)(MSD

7C7 = 1991

Binary

0
1
2
3
4
5
6

Octal

HEX

0
1
2
3
4
5
6

1
2
3
4
5
6

Decimal

0000
0001
0010
0011
0100
0101
0110

7
8
9

7
8
9

0111
1000
1001

7
10
11

1010
1011
1100
1101
1110
1111

10
11
12
13
14
15
16
17

12
13
14
15
16
17

10
11

)(BCD

20
21

A
B
C
D
E
F
10000
10001

Binary-Coded-Decimal

, , .
, BCD.

4975

0100
1001
0111
1001
4975

)0100 1001 0111 1001

)=BCD

PIC16F84A

chip : PIC16F84A

)I/O
(interfaces ).(ADC

:


.

:
. 25 4 .
512 4096 128 .
.
) (ROM ) (EPROM
) (EEPRPM .

:
.

:
.

:
) (Analog ) (Digital .

chip chip
:

. 35 1-

1024. , 2-

, ,,
.

, RAM 3- 68
. EEPROM 4- 64
. 5- 15

O/I / 6- 13

) ( : INT 7-
. .
. ,
35

MPLA 35

MICROCHIP.COM
. . , 150
. PIC STARTPLUS
, , 5
.. 35,

13 /
13
PO PORTA PORT

PA1 PORTA 1
2

8.

PORTB

R . 1
5+ 1
. .


. 2

,
. .
. .


PIC16F84A 35
.
PIC16F84A 14
.
MOVL k
W


W .

MOVF f ,
W . F
d
MOVW f W
.
F
CLRF f
CLRW
f,
d

COMF

DECF f ,
d
INCF f ,
d


. 0
W . 0
.
W
. F
.
0 DECF
FF W . F
.
FF 0
W . F
. 0

BCF f ,
b
. 1
BSF f ,
b
RLF f , .
carry
d
W . F
RRF f , .
carry
d
Flag W . F
SWAP f , MS LS
. W . F
F
d

k
k
k
f,
d
f,
d
f,
d
f,
d


.
.
.

GOTO
CALL
RETUR
N
W .
RETLW
.
RETFIE
BTFSC .
. 0
BTFSS .
. 1
DECFS 1 .
. 0 W
Z
. F
INCFSZ 1
. 0 W . F
NOP


) (

Break .

. Watchdog

CLRWD
T
OPTION ) W (

.
SLEEP

. Reset
TRIS f
. W

ANDL k AND W
. W
W
ANDW f , AND W
. W
F
d
IORLW k OR W
. W
IORWF f , OR W
. W
d
XORL k XOR W
. W
W
XORW f , XOR W
W . F
F
d

ADDW f , W
.W
F
d
. W
ADDL k
W
W . W
SUBL k
W
SUBW f , W

W . F
:
= f .
= d .
= k .

, , , ,
, , ,
, 8, , ,:

indirect addresing INDF FSR ,


, , , ,
, , ), (.

FSR , ,

07 09
08 02
07 FSR INDF 09

FSR , INDF 02

. ,

W
, FSR ,
IND FSR
FSR ,
ALTALI GOTO

20H

MOVLW

FSR

MOVWF

INDF

CLRF

ALTALI

FSR

INCF

FSR,4

BTFSS

ALTALI
AKMIL

..............

..................

GOTO
.................
.................

TMR0 Timer0

, ,
, RA4/TOCKI

OPTION

TIMER ) FF( ) (255 ,


) (00

, ,

,
OPTION
PRESCALER

PRESCALER

,
,
OPTION

)(

OPTION

PS1

PS2

PSA

TOSE

TOSC

INTEDG

#RBPU

OPTION

81h

) ( PS0 PS1 PS2 ) ( PRESCALER )(PSA


) (WDT TIMER0

W
1:1
1:2
1:4
1:8
1:16
1:32
1:64
1:12

TIMER0
1:2
1:4
1:8
1:16
1:32
1:64
1:128
1:256

PS1 PS0
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1

PS2
0
0
0
0
1
1
1
1

WDT
TMR0

TOSE

TOSE=1 TIMER0
TOSE=0


TOCS

TIMER0

PSA=1
PSA=0

TOCS=1 TIMER0
TOCS=0
INTEDG
INT
INTEDG=1
INTEDG=0
RBPU
PORTB ,
,

RBPU=1
RBPU=0

PC

PC
13 , PCL ,
, PCLATH

PCH

INTCON
1

INTF

TOIF

RBIE

INTE

TOIE

EEIE

GIE

INTCON

RB4 RBIF=1

RB7

0Bh,8Bh INTCON

RB4 RB7

INTF =1

INT

INTF=0

INT

TOIF =1

RBIF=0

TIMER0
TIMER0

TOIF =0


RBIE=1
RBIE=0
INTE=1

INT

INTE=0
TOIE=1

TMRO

TOIE=0
EEIE=1

EEPROM

EEIE=0

GIE=1

GIE=0

STATUS
bit 1
DC

bit 2
Z

bit3
PD

bit 4
TO

bit 5
RP0

bit 6
RP1

". "0

bit 7
IRP

RP0 , 5 , 1 , 0

0 0 .1
, , .
CLRWDT-SLEEP TO=1
FF TO=0 00
CLRWDT PD=1
SLEEP PD=0
Z=1

Z=0

255 C
.1 0 "."255
DC , 15
DC=1 0

Z=1 . "" , 0

C=1

C=0

= 20= 10=-= 10
= -= 10 -

D W ,
.
Z=1 ,

porta portb
trisa trisb 8
, 0 1,
.

, port a, port b , trisa , trisb


) , (ALU ) (W
. .

trisb " "11111111 ) (ALU W


W . Trisb

35 :

MOVLW - 1 W
MOVWF -2 W " "
:
b`11111111
trisb

MOVLW
MOVWF

b , W BINARY

1 0


, ch fh
12 80

................. .....

.
Hossam_elkady@hotmail.com