1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu LẬP TRÌNH HỢP NGỮ AVR potx

34 326 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 34
Dung lượng 1,03 MB

Nội dung

    !" #$  $%&'()*+,   -"&./#00 -"  "$  #1",2$ 3  4567 4 8889:;:<=>?@ &A3  )*+  #$  $%&'()*+,   B  ;=>@C B  ;=>@C         2 2 8889:;:<=>?@ &A3  )*+  #$  $%&'()*+,   6.1 GIỚI THIỆU TẬP LỆNH AVR 6.1 GIỚI THIỆU TẬP LỆNH AVR    !"#$%&'&()'*#+*,-)./01*23 !"#$%&'&()'*#+*,-)./01*23 2 2 4'&(#1*#,#56#)7&6-(%8(#%9&:$*#3 4'&(#1*#,#56#)7&6-(%8(#%9&:$*#3 0 0   4'&(#1*#,#56 4'&(#1*#,#56 ; ;   4<*,=>-56?3@&A(#B:C;B%(#D&#<*, 4<*,=>-56?3@&A(#B:C;B%(#D&#<*, = =   4<*,=>-56?3@&A(#B:C;B%(#D&#<*, 4<*,=>-56?3@&A(#B:C;B%(#D&#<*,     4<*,=>-56E3@&A(#B:C;B%(#D&#<*, 4<*,=>-56E3@&A(#B:C;B%(#D&#<*, ! !   4<*,=>-563@&A(#B:C;B%(#D&#<*, 4<*,=>-563@&A(#B:C;B%(#D&#<*, F F 4<*,=>-2G,'(0H(%8(#%9&:$*#3@&A(#B:C;B%(#D& 4<*,=>-2G,'(0H(%8(#%9&:$*#3@&A(#B:C;B%(#D& #<*, #<*, I I   4<*,=>-563@&A(#B:C;B%(#D&#<*, 4<*,=>-563@&A(#B:C;B%(#D&#<*, 3 3 8889:;:<=>?@ &A3  )*+  #$  $%&'()*+,   J KLM J KLM N*#O)'*#+*,PQ(G N*#O)'*#+*,PQ(G #R&#$* #R&#$*   S S :)&F :)&F •   2@0 2@0 9*,F#Q*,*#O 9*,F#Q*,*#O 2T2U0 2T2U0 V@@@@ V@@@@   •   2@0 2@0 9*,&A*#O 9*,&A*#O 2T2U0U 2T2U0U V@@@@ V@@@@   • W W 2@! 2@! U,'(0H(D&(#S U,'(0H(D&(#S 2U42T2U42U! 2U42T2U42U! V@@@ V@@@   • X X 2@0 2@0 0YF#Q*,*#O 0YF#Q*,*#O 2T2Z0 2T2Z0 V@@@@ V@@@@   • X X 2@! 2@! 0Y,'(0H(D&(#S 0Y,'(0H(D&(#S 2T2Z! 2T2Z! V@@@@ V@@@@   • X X 2@0 2@0 0Y&A&S*#O 0Y&A&S*#O 2T2Z0Z 2T2Z0Z V@@@@ V@@@@   • X X 2@! 2@! 0Y(D&(#S&A*#O 0Y(D&(#S&A*#O 2T2Z!Z 2T2Z!Z V@@@@ V@@@@   • XW XW 2@! 2@! Z(D&(#S(#/)(Y Z(D&(#S(#/)(Y 2U42T2U426! 2U42T2U426! V@@@ V@@@   •   2@0 2@0 ),& ),& 2T20 2T20 V@@ V@@   •   2@! 2@! [O=>(D&(#S [O=>(D&(#S 2T2! 2T2! V@@ V@@   •   2@0 2@0 ),&1: ),&1: 2T20 2T20 V@@ V@@   •   2@! 2@! [O=>(D&(#S [O=>(D&(#S 2T2! 2T2! V@@ V@@   •   2@0 2@0 \&:%=[/ \&:%=[/ 2T2]0 2T2]0 V@@ V@@   • P P 2 2 X^ X^ 2T_``Z2 2T_``Z2 V@@@ V@@@   •   2 2 X^ X^ 2T_55Z2 2T_55Z2 V@@@@ V@@@@   • X X 2@! 2@! a.;((0)*,(,# a.;((0)*,(,# 2T2[! 2T2[! V@@ V@@   • X X 2@! 2@! ]A1;((0)*,(,# ]A1;((0)*,(,# 2T21*2-_``#Z!3 2T21*2-_``#Z!3 V@@ V@@   •   2 2 b*, b*, 2T2U 2T2U V@@ V@@   •   2 2 Gc Gc 2T2Z 2T2Z V@@ V@@   •     2 2 !(01d/0)#)7&ec !(01d/0)#)7&ec 2T21*22 2T21*22 V@@ V@@   •   2 2 ]A1(#1*#,# ]A1(#1*#,# 2T2\)02 2T2\)02 V@@ V@@   •   2 2 a.(#1*#,# a.(#1*#,# 2T_`` 2T_`` )*/ )*/   • P P 2@0 2@0 #e*F#Q*,2f% #e*F#Q*,2f% @5T2\0 @5T2\0       4 4 8889:;:<=>?@ &A3  )*+  #$  $%&'()*+,   • gP gP F F #Gh(ij*,k> #Gh(ij*,k> TUFU TUFU )*/ )*/   • gP gP *#Gh,'*(l.-V3 *#Gh,'*(l.-V3 TV TV )*/ )*/   • gP gP F F #GhF#Q*,km%F$* #GhF#Q*,km%F$* TF TF )*/ )*/   • F F n&(0o*#&)*(k> n&(0o*#&)*(k> TUFU TUFU )*/ )*/   •   n,'*(l.-V3 n,'*(l.-V3 TV TV )*/ )*/   •   F F n&#ij*,(0o*#&)* n&#ij*,(0o*#&)* TF TF )*/ )*/ p p •   q%1h[m(Y&(0o*#&)* q%1h[m(Y&(0o*#&)* T ! T ! )*/ )*/ p p •   q%1h[m(Y*,r( q%1h[m(Y*,r( T ! T !   p p •     2@0 2@0 )='*#[C5*#GhF#;<*, )='*#[C5*#GhF#;<*, s-2t03TU)0 s-2t03TU)0 )*/EE )*/EE •   2@0 2@0 )='*# )='*# 2Z0 2Z0 V@@@@ V@@@@   •   2@0 2@0 )='*#&A&S*#O )='*#&A&S*#O 2Z0Z 2Z0Z V@@@@ V@@@@   •   2@! 2@! )='*#[O=>(D&(#S )='*#[O=>(D&(#S 2Z! 2Z! V@@@@ V@@@@   • X X 0@; 0@; 5*#GhF#;(t5- F.3 5*#GhF#;(t5- F.3 s-0-;3t53TU)0 s-0-;3t53TU)0 )*/EE )*/EE • X X 0@; 0@; 5*#Gh*l%;(t 5*#Gh*l%;(t s-0-;3t3TU)0 s-0-;3t3TU)0 )*/EE )*/EE • X X @; @; 5*#Gh*l%;(Et5 5*#Gh*l%;(Et5 s-E-@;3t53TU)0 s-E-@;3t53TU)0 )*/EE )*/EE • X X @; @; 5*#Gh*l%;(Et 5*#Gh*l%;(Et s-E-@;3t3TU)0 s-E-@;3t3TU)0 )*/EE )*/EE • XX XX =@Fu*#'*#F#&S(0+*,(#'ts- -=3t3(#/*TUFU)*/E =@Fu*#'*#F#&S(0+*,(#'ts- -=3t3(#/*TUFU)*/E • XX XX =@Fu*#'*#F#&S(0+*,(#'t5s- -=3t53(#/*TUFU)*/E =@Fu*#'*#F#&S(0+*,(#'t5s- -=3t53(#/*TUFU)*/E 5 5 JvJ JvJ 8889:;:<=>?@ &A3  )*+  #$  $%&'()*+,   • Xq Xq F F u*#'*#*l%;<*, u*#'*#*l%;<*, s-Vt3(#/*TUFU s-Vt3(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%F#Q*,;<*,s-Vt53(#/*TUFU u*#'*#*l%F#Q*,;<*,s-Vt53(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%`t u*#'*#*l%`t s-t3(#/*TUFU s-t3(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%`t5 u*#'*#*l%`t5 s-t53(#/*TUFU s-t53(#/*TUFU )*/ )*/ E E • X  X  F F u*#'*#*l%w#)7&t u*#'*#*l%w#)7&t s-t53(#/*TUFU s-t53(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%*#x#j* u*#'*#*l%*#x#j* s-t3(#/*TUFU s-t3(#/*TUFU )*/ )*/ E E • XP XP F F u*#'*#*l%ec u*#'*#*l%ec s-t3(#/*TUFU s-t3(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%2ij*, u*#'*#*l%2ij*, s-t53(#/*TUFU s-t53(#/*TUFU )*/ )*/ E E • X X F F u*#'*#w#)7&t@&A2f% u*#'*#w#)7&t@&A2f% s-\)0t53(#/*TUFU s-\)0t53(#/*TUFU )*/ )*/ E E • X X F F u*#'*#y#)7&t@&A2f% u*#'*#y#)7&t@&A2f% s-\)0t3(#/*TUFU)*/ s-\)0t3(#/*TUFU)*/ E E • X X F F u*#'*#*l%`t u*#'*#*l%`t s-t3(#/*TUFU s-t3(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%`t5 u*#'*#*l%`t5 s-t53(#/*TUFU s-t53(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%`t u*#'*#*l%`t s-t3(#/*TUFU s-t3(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%`t5 u*#'*#*l%`t5 s-t53(#/*TUFU s-t53(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%`t u*#'*#*l%`t s-t3(#/*TUFU s-t3(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%`t5 u*#'*#*l%`t5 s-t53(#/*TUFU s-t53(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%`t u*#'*#*l%`t s-t3(#/*TUFU s-t3(#/*TUFU )*/ )*/ E E • X X F F u*#'*#*l%`t u*#'*#*l%`t s-t53(#/*TUFU s-t53(#/*TUFU )*/ )*/ E E 6 6 JvJ JvJ 8889:;:<=>?@ &A3  )*+  #$  $%&'()*+,   • P P 2@0 2@0 #z.(#1*#,# #z.(#1*#,# 2T0 2T0 )*/ )*/   •   2@! 2@! +.,'(0H(D&(#S +.,'(0H(D&(#S 2T! 2T! )*/ )*/   •   2@F 2@F +.(0R&(l.(Y P +.(0R&(l.(Y P 2T-F3 2T-F3 )*/ )*/   •   2@] 2@] +.,'*(l. +.,'*(l. 2T-]3 2T-]3 )*/ )*/   •   2@]U 2@]U +.,'*(l.[C(b*, +.,'*(l.[C(b*, 2T-]3@]T]U 2T-]3@]T]U )*/ )*/   •   2@Z] 2@Z] Gc[C*+.,'*(l. Gc[C*+.,'*(l. ]T]Z@2T-]3 ]T]Z@2T-]3 )*/ )*/   •   2@{ 2@{ +.,'*(l. +.,'*(l. 2T-{3 2T-{3 )*/ )*/   •   2@{U 2@{U +.,'*(l.[C(b*, +.,'*(l.[C(b*, 2T-{3@{T{U 2T-{3@{T{U )*/ )*/   •   2@Z{ 2@Z{ Gc[C*+.,'*(l. Gc[C*+.,'*(l. {|T{Z@2T-{3 {|T{Z@2T-{3 )*/ )*/   •   2@{UI 2@{UI +.,'*(l.[Ok92S +.,'*(l.[Ok92S 2T-{UI3 2T-{UI3 )*/ )*/   •   2@V 2@V +.,'*(l. +.,'*(l. 2T-V3 2T-V3 )*/ )*/   •   2@VU 2@VU +.,'*(l.[C,Gc +.,'*(l.[C,Gc 2T-V3@VTVU 2T-V3@VTVU )*/ )*/   •   2@ZV 2@ZV Gc[C*+.,'*(l. Gc[C*+.,'*(l. VTVZ@2T-V3 VTVZ@2T-V3 )*/ )*/   •   2@VUI 2@VUI +.,'*(l.[Ok92S +.,'*(l.[Ok92S 2T-VUI3 2T-VUI3 )*/ )*/   •   F@0 F@0 i%(0D&(l.[C) P i%(0D&(l.[C) P -F3T0 -F3T0 )*/ )*/   •   ]@0 ]@0 i%,'*(l. i%,'*(l. -]3T0 -]3T0 )*/ )*/   7 7 J{} J{} 8889:;:<=>?@ &A3  )*+  #$  $%&'()*+,   •   ]U@0 ]U@0 i%,'*(l.[C,Gc i%,'*(l.[C,Gc -]3T0@]T]U -]3T0@]T]U )*/ )*/   •   Z]@0 Z]@0 Gc[C:i%,'*(l. Gc[C:i%,'*(l. ]T]Z@-]3T0 ]T]Z@-]3T0 )*/ )*/   •   {@0 {@0 i%,'*(l. i%,'*(l. -{3T0 -{3T0 )*/ )*/   •   {U@0 {U@0 i%,'*(l.[C(b*, i%,'*(l.[C(b*, -{3T0@{T{U -{3T0@{T{U )*/ )*/   •   Z{@0 Z{@0 Gc[C:i%,'*(l. Gc[C:i%,'*(l. {T{Z@-{3T0 {T{Z@-{3T0 )*/ )*/   •   {UI@0 {UI@0 i%,'*(l.[Ok92S i%,'*(l.[Ok92S -{UI3T0 -{UI3T0 )*/ )*/   •   V@0 V@0 i%,'*(l. i%,'*(l. -V3T0 -V3T0 )*/ )*/   •   VU@0 VU@0 i%,'*(l.[C(b*, i%,'*(l.[C(b*, -V3T0@VTVU -V3T0@VTVU )*/ )*/   •   ZV@0 ZV@0 Gc[C:i%,'*(l. Gc[C:i%,'*(l. VTVZ@-V3T0 VTVZ@-V3T0 )*/ )*/   •   VUI@0 VUI@0 i%,'*(l.[Ok92S i%,'*(l.[Ok92S -VUI3T0 -VUI3T0 )*/ )*/   • P P +.(Y;9*#O&#ij*,(0o*# +.(Y;9*#O&#ij*,(0o*# 5T-V3 5T-V3 )*/ )*/   •   2@ 2@ ~n&&•*,[C)01 ~n&&•*,[C)01 2T 2T )*/ )*/   •   @0 @0 #&•*,[C)01 #&•*,[C)01 T0 T0 )*/ )*/   •     0 0 +.(#1*#,#[C)k€*#=(1&F +.(#1*#,#[C)k€*#=(1&F !T0 !T0 )*/ )*/   •   2 2 fhk€*#=(1&F01(#1*#,# fhk€*#=(1&F01(#1*#,# 2T ! 2T ! )*/ )*/   8 8 J{} J{} 8889:;:<=>?@ &A3  )*+  #$  $%&'()*+,   •     2H&#(0':),&2-*U3T2-*3@2-53T5@T2-?3 2H&#(0':),&2-*U3T2-*3@2-53T5@T2-?3 V@@@@ V@@@@ •     2H&#.#G:),&2-*3T2-*U3@2-?3T5@T2-53 2H&#.#G:),&2-*3T2-*U3@2-?3T5@T2-53 V@@@ V@@@   •   2q%1h(0'I%1`2-53T@2-*U3T2-*3@T2-?3 2q%1h(0'I%1`2-53T@2-*U3T2-*3@T2-?3 V@@@@ V@@@@ •   2q%1h.#GI%1`2-?3T@2-*3T2-*U3@T2-53 2q%1h.#GI%1`2-?3T@2-*3T2-*U3@T2-53 V@@@ V@@@   •     2H&#.#G=>#n& 2H&#.#G=>#n& 2-*3T2-*U3@*t5 2-*3T2-*U3@*t5 V@@@ V@@@   • W2#%hB*k•;;:/= W2#%hB*k•;;:/= 2-53 2-?p3 2-53 2-?p3   )*/ )*/   • X  X  = = a.&S a.&S -=3T -=3 -=3T -=3   • X X = = ]A1&S ]A1&S -=3T5 -=3T5 -=3 -=3   • X X @; @; a.;(E a.;(E E-@;3T E-@;3T )*/ )*/ • X X @; @; :/10X(*E/,=(/0 :/10X(*E/,=(/0 E-@;3T5 E-@;3T5 )*/ )*/   • X  X  0@; 0@; X( ()0/s0)c/,=(/0() X( ()0/s0)c/,=(/0() T0-;3 T0-;3     • X X 2@; 2@; X(:)12s0)c()/,=(/0 X(:)12s0)c()/,=(/0 2-;3T 2-;3T )*/ )*/   •   a.` a.` T T     •   ]A1` ]A1` T5 T5     •   a.` a.` T T     •   :/10/,1([/`:1, :/10/,1([/`:1, T5 T5     • V V a.V` a.V` VT VT V V   • V V ]A1V` ]A1V` VT5 VT5 V V     9 9 J!•PX J!•PX 8889:;:<=>?@ &A3  )*+  #$  $%&'()*+,   •   #).#z.*,r((•*, #).#z.*,r((•*, T T   •   fc*,r(&•*, fc*,r(&•*, T5 T5     •   a.&SFBc(012f% a.&SFBc(012f% T T   •   ]A1&SFBc(012f% ]A1&SFBc(012f% T5 T5   •   a.&S(0C*;^ a.&S(0C*;^ T T   •   ]A1&S(0C*;^ ]A1&S(0C*;^ T5 T5     •   a.(0)*,  a.(0)*,  T T   •   ]A1(0)*,  ]A1(0)*,  T5 T5     •   a.&S`(0)*,  a.&S`(0)*,  T T   •   ]A1&S`(0)*,  ]A1&S`(0)*,  T5 T5     •   !#Q*,#n1(k9*, !#Q*,#n1(k9*, )*/ )*/   •   ,‚ ,‚ )*/ )*/   • W W W1(&#2),/=/( W1(&#2),/=/( )*/ )*/   10 10 J!•PX J!•PX [...]... BYTE Đặt byte cho biến CSEG Đoạn mã lệnh DB Định nghĩa các byte hằng DEF Đặt tên ký hiệu cho thanh ghi DEVICE Chỉ định CPU sử dụng DSEG Đoạn dữ liệu DW Định nghĩa các từ (word) hằng ENDMACRO EQU Kết thúc macro Đặt một ký hiệu bằng một biểu thức ESEG Đoạn dữ liệu EEPROM EXIT Thoát từ tập tin www.ptit.edu.vn KỸ THUÂÊT VI XỬ LÝ GIẢNG VIÊN: THS PHẠM THẾ DUY BÔÊ MÔN: ĐIỀU KHIỂN VÀ XỬ LÝ TÍN HIÊÊU... VÀ XỬ LÝ TÍN HIÊÊU 18 6.2.2 Cú pháp các chỉ thị của assembler (tt) • Chỉ thị DEVICE: Chỉ định CPU sử dụng • Cú pháp: DEVICE TênCPU • Ví dụ: DEVICE ATMEGA16 • Chỉ thị DSEG: Cho biết bắt đầu đoạn dữ liệu • Cú pháp: DSEG • Ví dụ: DSEG var1: BYTE 1 table: BYTE tab_size www.ptit.edu.vn KỸ THUÂÊT VI XỬ LÝ ; Start data segment ; reserve 1 byte to var1 ; reserve tab_size bytes GIẢNG VIÊN: THS PHẠM... pháp các chỉ thị của assembler (tt) • Chỉ thị EQU: Gán một giá trị • Cú pháp: EQU label = expression • Ví dụ: EQU io_offset = 0x23 EQU porta = io_offset + 2 • Chỉ thị ESEG: Xác định bắt đầu của đoạn dữ liệu EEPROM • Cú pháp: ESEG • Ví dụ: DSEG ; Start data segment vartab: BYTE 4 ; Reserve 4 bytes in SRAM ESEG eevar: DW 0xff0f ; Initialize one word in EEPROM www.ptit.edu.vn KỸ THUÂÊT VI XỬ LÝ GIẢNG .  2 2 8889:;:<=>?@ &A3  )*+  #$  $%&'()*+,   6.1 GIỚI THIỆU TẬP LỆNH AVR 6.1 GIỚI THIỆU TẬP LỆNH AVR    !"#$%&'&()'*#+*,-)./01*23 !"#$%&'&()'*#+*,-)./01*23 2 2 4'&(#1*#,#56#)7&6-(%8(#%9&:$*#3 4'&(#1*#,#56#)7&6-(%8(#%9&:$*#3 0 0   4'&(#1*#,#56 4'&(#1*#,#56 ; ;   4<*,=>-56?3@&A(#B:C;B%(#D&#<*, 4<*,=>-56?3@&A(#B:C;B%(#D&#<*, = =   4<*,=>-56?3@&A(#B:C;B%(#D&#<*, 4<*,=>-56?3@&A(#B:C;B%(#D&#<*,     4<*,=>-56E3@&A(#B:C;B%(#D&#<*, 4<*,=>-56E3@&A(#B:C;B%(#D&#<*, ! !   4<*,=>-563@&A(#B:C;B%(#D&#<*, 4<*,=>-563@&A(#B:C;B%(#D&#<*, F F 4<*,=>-2G,'(0H(%8(#%9&:$*#3@&A(#B:C;B%(#D& 4<*,=>-2G,'(0H(%8(#%9&:$*#3@&A(#B:C;B%(#D& #<*, #<*, I I   4<*,=>-563@&A(#B:C;B%(#D&#<*, 4<*,=>-563@&A(#B:C;B%(#D&#<*, 3 3 8889:;:<=>?@ &A3  )*+  #$  $%&'()*+,   J. dụng DSEG Đoạn dữ liệu DW Định nghĩa các từ (word) hằng ENDMACRO Kết thúc macro EQU Đặt một ký hiệu bằng một biểu thức ESEG Đoạn dữ liệu EEPROM EXIT Thoát

Ngày đăng: 23/02/2014, 23:20

TỪ KHÓA LIÊN QUAN

w