Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
TUT03.02.PVN.NTCR.050306

TUT03.02.PVN.NTCR.050306

Ratings: (0)|Views: 84 |Likes:
Published by api-19876597

More info:

Published by: api-19876597 on Dec 01, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Ng\u01b0\u1eddi b\u00e1o c\u00e1o:
Nguy\u1ec5n Trung Ch\u00ednh
T\u00e0i li\u1ec7u:
TUT03.02
Ng\u00e0y:
3/6/2006
Trang:
1/14
Tutorial 03.02
G\u1eedi\u0111\u1ebfn:
picvietnam@googlegroups.com
N\u1ed9i dung:
B\u00e0i 3: K\u0128 THU\u1eacT B\u1ea2NG
MICROSOFT WORD
T\u00f3m t\u1eaft:
Tutorial post l\u00ean picvietnam, topic \u201cPIC16F877A T\u1eea D\u1ec4 T\u1edaI KH\u00d3\u201d thu\u1ed9c lu\u1ed3ng \u201cC\u01a0 B\u1ea2N V\u1ec0
VI\u0110I\u1ec0U KHI\u1ec2N V\u00c0 PIC\u201d v\u1edbi n\u1ed9i dung:
\u2010Ph\u00e2n t\u00edch gi\u1ea3i thu\u1eadt k\u0129 thu\u1eadt b\u1ea3ng v\u00e0 m\u1ed9ts\u1ed1 \u1ee9ng d\u1ee5ng hi\u1ec3n th\u1ecbv\u1edbi LED.
1.
\u0110\u1eb7tv\u1ea5n \u0111\u1ec1
Tr\u01b0\u1edbc khi ph\u00e2n t\u00edch gi\u1ea3i thu\u1eadt c\u1ee7a k\u0129 thu\u1eadt b\u1ea3ng ta th\u1ef1c hi\u1ec7n m\u1ed9t\u1ee9ng d\u1ee5ng nh\u1ecf, coi nh\u01b0
v\u1eeba \u00f4n l\u1ea1i b\u00e0i c\u0169, v\u1eeba d\u1eb7t ra c\u00e1c v\u1ea5n\u0111\u1ec1 cho b\u00e0i m\u1edbi.\u1ee8ng d\u1ee5ng n\u00e0y s\u1eed d\u1ee5ng m\u1ea1ch nguy\u00ean l\u00ed\u0111\u00e3
\u0111\u01b0\u1ee3c x\u00e2y d\u1ef1ng \u1edf b\u00e0i 1.
\u1ee8ng d\u1ee5ng 1:Cho m\u1ed9t LED ch\u1ea1y t\u1eeb tr\u00e1i sang ph\u1ea3i sau m\u1ed7i kho\u1ea3ng th\u1eddi gian delay 100 ms.

Ta\u0111\u00e3 x\u00e2y d\u1ef1ng m\u1ed9t m\u1ea1ch\u1ee9ng d\u1ee5ng bao g\u1ed3m c\u00e1c LED\u0111\u01b0\u1ee3c g\u1eafn v\u00e0o PORTB c\u1ee7a vi\u0111i\u1ec1u
khi\u1ec3n PIC th\u00f4ng qua c\u00e1c\u0111i\u1ec7n tr\u1edf, v\u00e0 mu\u1ed1n LED n\u00e0o s\u00e1ng, c\u1ea7n xu\u1ea5t gi\u00e1 tr\u1ecb logic 1 ra ch\u00e2n
t\u01b0\u01a1ng\u1ee9ng c\u1ee7a PORTB. \u0110\u1ec3 thu\u1eadn ti\u1ec7n cho vi\u1ec7c theo d\u00f5i, s\u01a1 \u0111\u1ed3 m\u1ea1ch s\u1ebd \u0111\u01b0\u01a1c\u0111\u01b0a l\u1ea1i trong h\u00ecnh

d\u01b0\u1edbi\u0111\u00e2y.
R5
D2
4 MHz
HI
R6
D7
D5
D4
0
R2
R1
0
R9
D3
H
I
SW1
12
0
R7
D8
0
D1
0
R3
HI
R4
PIC16F877A
89
10
12
14

15 16 17 18

19
20
21
22
23
24
25
26
27
28
29
30
31
1
13
234567
33
34
35
36
37
38
39
40
11
32

RE0/RD/AN5
RE1/WR/AN6
RE2/CS/AN7

GND
OSC2/CLKOUT

RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL

RD0/PSP0
RD1/PSP1
RD2/PSP2
RD3/PSP3
RC4/SDI/SDA
RC5/SDO
RC6/TX/CK
RC7/RX/DT
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7
GND
MCLR/VPP
OSC1/CLKIN

RA0/AN0
RA1/AN1
RA2/AN2/VREF-/CVREF
RA3/AN3/VREF+
RA4/TOCKI/C1OUT
RA5/AN4/SS/C2OUT

RBO/INT
RB1
RB2
RB3/PGM
RB4
RB5
RB6/PGC
RB7/PGD
VDD
VDD
R8
C1
30 pF
D6
C2
30 pF
H\u00ecnh 1: S\u01a1 \u0111\u1ed3 nguy\u00ean l\u00ed m\u1ea1ch\u1ee9ng d\u1ee5ng.
Ng\u01b0\u1eddi b\u00e1o c\u00e1o:
Nguy\u1ec5n Trung Ch\u00ednh
T\u00e0i li\u1ec7u:
TUT03.02
Ng\u00e0y:
3/6/2006
Trang:
2/14

Ta\u0111\u00e3 bi\u1ebft\u0111\u01b0\u1ee3c c\u00e1ch thi\u1ebft l\u1eadp gi\u00e1 tr\u1ecb cho c\u00e1c ch\u00e2n I/O c\u1ee7a vi\u0111i\u1ec1u khi\u1ec3n (b\u00e0i 1), c\u00e1ch vi\u1ebft
ch\u01b0\u01a1ng tr\u00ecnh delay (b\u00e0i 2), v\u00e0 mu\u1ed1n c\u00e1c LED d\u1ecbch t\u1eeb tr\u00e1i sang ph\u1ea3i, ta s\u1eed d\u1ee5ng m\u1ed9t trong hai
l\u1ec7nh sau:

L\u1ec7nh RLF
C\u00fa ph\u00e1p: RLF thanh_ghi,noi_den
T\u00e1c d\u1ee5ng: d\u1ecbch tr\u00e1i c\u00e1c bit trong thanh ghi \u201cthanh_ghi\u201d th\u00f4ng qua c\u1edd carry C

(thanh ghi ch\u1ee9c n\u0103ng STATUS). K\u1ebft qu\u1ea3 sau khi d\u1ecbch\u0111\u01b0\u1ee3c l\u01b0u v\u00e0o thanh ghi
\u201dthanh_ghi\u201dn\u1ebfu tham s\u1ed1 \u201cnoi_den\u201d mang gia tr\u1ecb 1 ho\u1eb7c thanh ghi W n\u1ebfu tham
s\u1ed1 \u201cnoi_den\u201d mang gi\u00e1 tr\u1ecb 0. C\u00f3 th\u1ec3 h\u00ecnh dung c\u00e1ch d\u1ecbch c\u1ee7a l\u1ec7nh n\u00e0y theo
h\u00ecnh d\u01b0\u1edbi.

L\u1ec7nh RRF
C\u00fa ph\u00e1p: RRF thanh_ghi,noi_den
T\u00e1c d\u1ee5ng: d\u1ecbch ph\u1ea3i c\u00e1c bit trong thanh ghi \u201cthanh_ghi\u201d th\u00f4ng qua c\u1edd carry

C (thanh ghi ch\u1ee9c n\u0103ng STATUS). K\u1ebft qu\u1ea3 sau khi d\u1ecbch\u0111\u01b0\u1ee3c l\u01b0u v\u00e0o thanh ghi
\u201dthanh_ghi\u201dn\u1ebfu tham s\u1ed1 \u201cnoi_den\u201d mang gia tr\u1ecb 1 ho\u1eb7c thanh ghi W n\u1ebfu tham
s\u1ed1 \u201cnoi_den\u201d mang gi\u00e1 tr\u1ecb 0. C\u00f3 th\u1ec3 h\u00ecnh dung c\u00e1ch d\u1ecbch c\u1ee7a l\u1ec7nh n\u00e0y theo
h\u00ecnh d\u01b0\u1edbi.

\u0110\u1ebfn \u0111\u00e2y xem nh\u01b0ta \u0111\u00e3 c\u00f3 \u0111\u1ea7y \u0111\u1ee7 c\u00e1c th\u00f4ng tin \u0111\u1ec3vi\u1ebft ch\u01b0\u01a1ng tr\u00ecnh. Gi\u1ea3i thu\u1eadtc\u0169ng
kh\u00e1\u0111\u01a1n gi\u1ea3n, c\u00e1c b\u01b0\u1edbc ti\u1ebfn h\u00e0nh l\u1ea7n l\u01b0\u1ee3t nh\u01b0 sau:
\u2010 \u0110\u01b0a v\u00e0o thanh ghi PORTB gi\u00e1 tr\u1ecb 10000000b (cho LED \u0111\u1ea7u ti\u00ean s\u00e1ng).
\u2010D\u1ecbch ph\u1ea3i gi\u00e1 tr\u1ecb trong thanh ghi PORTB (LED s\u00e1ng c\u0169ng \u0111\u01b0\u1ee3cd\u1ecbch t\u01b0\u01a1ng \u1ee9ng).
\u2010Delay 100 ms.
\u2010L\u1eb7pl\u1ea1ib\u01b0\u1edbc 2.
V\u00e0\u0111\u00e2y, ch\u01b0\u01a1ng tr\u00ecnh c\u1ee7a\u1ee9ng d\u1ee5ng:
Ch\u01b0\u01a1ng tr\u00ecnh 3.1:
;=============================================================================
; WWW.PICVIETNAM.COM
; Lap trinh:
NGUYEN TRUNG CHINH
; Ngay bat dau:
23 thang 01 nam 2006
Ng\u01b0\u1eddi b\u00e1o c\u00e1o:
Nguy\u1ec5n Trung Ch\u00ednh
T\u00e0i li\u1ec7u:
TUT03.02
Ng\u00e0y:
3/6/2006
Trang:
3/14
; Ngay hoan thanh:
23 thang 01 nam 2006
; Kiem tra chuong trinh:
picvietnam@googlegroups.com
; Ngay kiem tra:
; Su dung vi dieu khien Microchip: PIC16F877A
title
\u201cchuongtrinh3\u20101.asm\u201d
processor 16f877a
include
<p16f877a.inc>
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC &

_WRT_OFF & _LVP_OFF & _CPD_OFF
; Cap nhat va bo sung:
; Mo ta chuong trinh: Chuong trinh dung de dieu khien m\u1ed9t LED sang d\u1ecbch sang phai sau

;
moi khoang thoi gian 100 ms.
; Mo ta phan cung:
8 LED duoc gan vao PORTB thong qua cac dien tro, cac
;
thanh phan di kem bao gom thach anh, mach reset va nguon
;================================================================================
;\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010
; Khoi tao cac bien
;\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010
count1 EQU 0x20
; cac bien dung cho doan chuong trinh delay
counta EQU 0x21
countb EQU 0x22
;=============================================================================
; CH\u01af\u01a0NG TR\u00ccNH CH\u00cdNH
;=============================================================================
ORG
0x000
GOTO
start
start
; ch\u01b0\u01a1ng tr\u00ecnh ch\u00ednh b\u1eaft\u0111\u1ea7u t\u1ea1i\u0111\u00e2y
;\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010
; Kh\u1edfi t\u1ea1o PORT B
;\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010\u2010

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->