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] , ] [9 ,
, (Carry), ] [10 ][1
) , ( 10^1=10 ] [ 0 ). . (10^0=1
, ) (9 , ) ( 9
)( 10 ( 2^10=100 ) .
, ,
.
, , ) ( 16 ,10 ,8 ,2
1 .
2

.
3 .
4 .

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

Binary

, , 2 ) , (0,1

) ( , ,
MSB LSB

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


) ( 2
37 :
37 2 18 1

18 2 9

9 2 4

4 2 2

2 2 1

1 2 0

, 37 , ) ( bit
.

100101 = 37

: ,
.

Octal

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

) ( 8
267 :
)(Lsd
267 8 33 3
33 8 41
)(MSD
4 8 0 4
,267 ,
.
267 413 .

Hexadecimal

Hex

, , 16 ,

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

HEX to Decimal

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

1991

1991 16 124 7
124 16 7
7

12

16 0 7

)(MSD

1991 = 7C7

Binary

0
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010

Octal

HEX

Decimal

0000
1
2
3
4
5
6
7
8
9
10

1
2
3
4
5
6
7
10
11
12

1
2
3
4
5
6
7
8
9
A

1011
1100
1101
1110
1111
10000
10001

13
14
15
16
17
20
21

B
C
D
E
F
10
11
)(BCD

11
12
13
14
15
16
17

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 :

-1 35 .

1024. ,

, ,,
.

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

. 13 -6O/I /

. .

) ( -7INT:
. .
, .
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 .

W.
MOVLW k
MOVF f ,
WF .
d
MOVWF f W
.

CLRF f
CLRW


.0
W .0

f,
d

COMF

DECF f ,
d
INCF f ,
d

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

BCF f ,
b
.1
BSF f ,
b
RLF f ,
. carry
d
WF .
RRF f ,
. carry
d
Flag WF .
SWAPF f , MS LS
. WF .
d

.
GOTO k
.
CALL k
.
RETURN
W.
RETLW k

RETFIE
BTFSC f ,
d
BTFSS f ,
d
DECFSZ f ,
d
INCFSZ f ,
d

NOP

.
.
.0
.
.1
1 .
. 0 W
F .
1
. 0 WF .

) (

Break .


Watchdog .
CLRWDT
OPTION ( W )


.
SLEEP

Reset .

TRIS f
W .


ANDLW k AND W
W .
ANDWF f AND W
W .
,
d
IORLW k OR W
W .
IORWF f OR W
W .
,
d
XORLW k XOR W
W .
XORWF f XOR W
WF .
,
d

ADDWF f W
W.
,
d
W .
ADDLW k
W W .
SUBLW k
SUBWF f W
WF .
,
d

:
= f .
= d .
= k .

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

indirect addresing INDF FSR ,


, , ,
, , ), (.

FSR , ,
, INDF , :

07 09
08 02
07 FSR

INDF 09

FSR , INDF 02

. ,

W
, FSR ,
INDF FSR
FSR ,
ALTALI GOTO

20H

MOVLW

FSR

MOVWF

INDF

ALTALI

CLRF
FSR

INCF

FSR,4

BTFSS

ALTALI
.................
.................

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

AKMIL

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

TMR0Timer0

, ,
, RA4/TOCKI

OPTION

TIMER ) FF( ) (255 ,


) (00

, ,
,

OPTION
PRESCALER

PRESCALER

,
,
OPTION

OPTION

)(

PS1

PS2

PSA

TOSE

TOSC

INTEDG

RBPU#

OPTION

81h

) ( PS2 PS1 PS0 ) ( PRESCALER )(PSA


) (WDT TIMER0
TIMER0

WD

PS2 PS1 PS0

1:1

1:2

1:2

1:4

1:4

1:8

WDT

=PSA
1

1:8

1:16

TMR0

=PSA
0

1:16

1:32

1:32

1:64

1:64

1:128

1:12

1:256

TOSE

TOSE=1 TIMER0
TOSE=0

TIMER0

TOCS
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
RB4 RB7 RBIF=0

INT

INTF =1

0Bh,8Bh INTCON

INTF=0 INT

TIMER0

TIMER0

TOIF =1
TOIF =0


RBIE=1
RBIE=0
INT

INTE=1

INTE=0
TMRO

TOIE=1

TOIE=0
EEPROM

EEIE=1

EEIE=0
GIE=1
GIE=0

STATUS
bit 1
DC

bit 2
Z

bit3
PD

bit 4
TO

bit 5
RP0

bit 6
RP1

bit 7
IRP

". "0
RP0 , 5 , 1 , 0

0 0 .1
, , .

CLRWDT-SLEEP TO=1
FF TO=0 00
CLRWDT PD=1
PD=0 SLEEP
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,
.

, trisb , port a, port b , trisa


) , (ALU ) (W
. .

trisb " "11111111 ) (ALU W

. Trisb

35 :

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

MOVLW
MOVWF

b , W BINARY

10


2

, ch fh
12 80

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

.
Hossam_elkady@hotmail.com