Danh mục

Giao tiếp giữa KIT vi xử lý 8086 và máy tính Nguồn, chương 12

Số trang: 28      Loại file: pdf      Dung lượng: 70.45 KB      Lượt xem: 14      Lượt tải: 0    
10.10.2023

Phí tải xuống: 9,000 VND Tải xuống file đầy đủ (28 trang) 0
Xem trước 3 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Trong thực tế có 2 phương pháp truyền thông tin kiểu nối tiếp: truyền đồng bộ và truyền không đồng bộ.Trong phương pháp truyền đồng bộ, dữ liệu dữ liệu được truyền theo từng mảng với tốc độ xác định. Mảng dữ liệu trước khi được truyền đi sẽ được gắn thêm ở đầu và ở cuối mảng các byte hoặc một nhóm bit định dấu đặc biệt.
Nội dung trích xuất từ tài liệu:
Giao tiếp giữa KIT vi xử lý 8086 và máy tính Nguồn, chương 12 Chương 12: CHÖÔNG TRÌNH TRUYEÀN DÖÕ LIEÄU TREÂN MAÙY TÍNH; TERMINAL.ASM; STACKstack segment stack db 300 dup(?)stack ends; DATAdata segment prompt db File name:$ filename db 30 dup(0) buffer db 512 dup(0) buffrr db 512 dup(0) handle dw ? openerr db 0dh,0ah,OPEN ERROR - COPDE errcode db 30h,$;messagesMENU_MS db **TERMINALPROGRAM**,0dh,0ah db to redisplay this MENU,0dh,0ah db to set communications protocol,0dh,0ah db to display protocol installed,0dh,0ah db to open file.hex and trasnmit,0dh,0ah db to exit the TERMINAL program,0dh,0ah db All character typed are transmitter,0dh,0ah db All character receiver are display,0dh,0ah db 0dh,0ah,$PROT_MS db * Installed communicationsprotocol,0dh,0ah db Baud rate:Baud% db 2400,0dh,0ah db Parity:Par% db Even,0dh,0ah db Stop bit:Stop% db 1,0dh,0ah db Word length:Word% db 8,0dh,0ah,0ah,$Baud$$ db 110 150 300 600 1200 2400 4800 9600Par$$ db odd nonevenbaud_menu db 0dh,0ah,**New communicationparameter db rs input **,0dh,0ah db baud rate:,0dh,0ah db 1 = 110,0dh,0ah db 2 = 150,0dh,0ah db 3 = 300,0dh,0ah db 4 = 600,0dh,0ah db 5 = 1200,0dh,0ah db 6 = 2400,0dh,0ah db 7 = 4800,0dh,0ah db 8 = 9600,0dh,0ah db Select: $par_menu db 0dh,0ah,Pariry:,0dh,0ah db 1 = odd,0dh,0ah db 2 = none,0dh,0ah db 3 = even,0dh,0ah db Select: $Stop_menu db 0dh,0ah,Stop bit:,0dh,0ah db 1 = 1 stop bit,0dh,0ah db 2 = 2 stop bit,0dh,0ah db Select: $Word_menu db 0dh,0ah,Word length:,0dh,0ah db 1 = 7 bit,0dh,0ah db 2 = 8 bit,0dh,0ah db Select: $err1_ms db 0dh,0ah,*** cannot transmit ***,0dh,0ahcard_base dw 02f8h ;address of RS 232 cardinT_num db 0chsetup_byte db 0bbh ;;OriginO_int_seg dw 0000h ;segmentO_int_off dw 0000h ;offset;circular buffer and pointer:circ_buf db 20 dup(00h) dw 0data_in dw 0 ;input pointerdata_out dw 0 ;output pointer data ends;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CODExxxxxxxxxxxxxxxxxxcode segment assume CS:codestart: mov ax,data mov ds,ax assume ds:data mov es,ax assume es:data;display MENU at cursor mov dx,offset menu_ms ;messages call show_message;hardware type push ds mov dx,0f000h mov ds,dx mov al,ds:[0fffeh] ;code to AL;get addr of the RS232 card from BIOS data area mov dx,0 mov ds,dx mov cx,ds:0400h pop ds mov card_base,cx;determine interrupt number:; 0bh IRQ4 all other cmp al,0fdh jne set_address mov int_num,0bh;save/install interruptset_address: mov ah,53 mov al,int_num int 21h mov o_int_seg,es mov o_int_off,bx mov ah,37 mov al,int_num mov dx,offset cs:rs232_int push ds push cs pop ds int 21h pop ds;set protocol mov al,10111011b mov ah,0 mov dx,0 int 14h call comm_on call flush ;monitor: mov ah,1 int 16h jz ser_imp jmp char_typedser_imp: sti ;interrupt on mov cx,50delay: nop nop loop delay;test for new data received cli mov bx,data_out cmp bx,data_in jne new_data sti jmp monitor;process charchar_typed: mov ah,0 int 16h;test for ,,, and keys cmp ax,3b00h jne test_f2 jmp show_menu ;F1 key pressedtest_f2: cmp ax,3c00h jne test_f3 jmp set_protocol ;F2 key pressedtest_f3: cmp ax,3d00h jne test_f4 jmp show_protocol ;F3 key pressedtest_f4: cmp ax,3e00h jne test_f9 jmp tran_file ;F4 key pressedtest_f9: cmp ax,4300h je dos_exit jmp show_and_send ;F2 key presseddos_exit: call comm_off mov ah,37 mov al,int_num mov dx,o_int_off mov ax,o_int_seg mov ds,ax int 21h;exit mov ah,76 mov al,0 int 21h;redisplay menushow_menu: mov dx,offset menu_ms call show_message jmp monitor;new data receivernew_data: lea si,circ_buf mov bx,data_out add si,bx mov al,byte ptr[si];update output pointer inc bx cmp bx,20 jne ok_out_ptr mov bx,0ok_out_ptr: mov data_out,bx sti call tty jmp monitorset_protocol: call comm_offbaud_rates: mov dx,offset baud_menu call show_message call get_key call tty cmp al,1 jc baud_rates cmp al,9 jnc baud_rates sub al,30h ;ascii to binary sub al,1 ;to range 0 to 7 push ax mov cl,4 mul cl mov si,offset baud$$ mov ah,0 add si,ax mov di,offset baud% mov cx,4 cld push ds pop es rep movsb pop ax mov cl,5 shl al,cl mov setup_byte,alparity: mov dx,offset par_menu call show_message call get_key call tty;valid input range is 1 to 3 cmp al,1 jc parity cmp al,4 jnc parity;input is valid range sub al,30h push ax;select 4 byte parity me ...

Tài liệu được xem nhiều: