วารสารปี-40-ฉบับที่-4-resize

การแสดงผลข้อมูลผ่านช่องทางออกแบบขนานของแผงวงจรไมโครคอนโทรลเลอร์เพื่อการเรียนรู้ 144 The Journal of the Royal Society of Thailand Volume 40 Number 4 Oct-Dec 2015 วงจรในรูปที่ ๑๑ ไม่ใช้วงจรรวม 74240 เพื่อประหยัดค่าใช้จ่ายทางฮาร์ดแวร์ สัญญาณออก PB0-PB3 ของวงจรรวม 8255 (1) ใช้ป้อนข้อมูลฐานสิบเข้ารหัสฐานสอง (ตรรกะบวก) ให้แก่วงจรรวม 7447 ซึ่งจะส่งสัญญาณ ผ่านตัวต้านทานขนาด ๓๓๐ โอห์มไปควบคุมการปิดเปิดแสงในตัวแสดงผลแบบ ๗ ส่วนจ� ำนวน ๔ ตัว ต่อขนานกัน ส่วนสัญญาณออก PB4-PB7 (ตรรกะลบ) ของวงจรรวม 8255 (1) ใช้ควบคุมทรานซิสเตอร์ แบบพีเอ็นพีเบอร์ 2N2907 ผ่านทางตัวต้านทานขนาด ๒ กิโลโอห์ม เพื่อต่อตัวแสดงผลแบบ ๗ ส่วนเข้ากับ แหล่งจ่ายแรงดันไฟฟ้า ๕ โวลต์ ครั้งละ ๑ ตัว ถ้าต้องการแสดงผลจ� ำนวนฐานสิบที่ประกอบด้วยตัวเลข มากกว่า ๔ ตัว เราต้องเพิ่มตัวแสดงผลแบบ ๗ ส่วนและเพิ่มสายสัญญาณออกจากวงจรรวม 8255 ให้สอดคล้องกัน ;Prog. SEVEN2.ASM for multiplexed ;display BCD on four 7-seg LEDs ;Created: July 14, 2015 ;Using low nibble of port1b => 74LS47 ;(BCD-to-7-seg decoder) ;Hi nibble of port1b => select each 7-seg ;use Borland’s Turbo Assembler ;assemble: tasm SEVEN2 ;link: tlink /t SEVEN2.OBJ,SEVEN2.BIN ;burn SEVEN2.BIN to 32-KB ROM or ;transfer it to ROM emulator .model tiny .code ;start of ROM address org 8000h ;I/O port addresses **** ( ดูใน LED1.ASM ตามรูปที่ ๓ ) **** main proc ;Initialization part of the prog. **** ( ดูใน LED1.ASM ตามรูปที่ ๓ ) **** ;The box below contains the ;principal part of the program ;-------------------------------- strt: ; call run72 ; jmp strt ; ;-------------------------------- main endp ;********************************** run72 proc ;display BCD on 7-seg via port1b ;show data on port2b LEDs ;1st 7-seg mov bh,01h ;lo nibble is zero mov bl,0 ;next 7-seg module shl bh,1 cmp bh,8 ;4th 7-seg? ;repeat for next three 7-seg modules jbe begin5 ret run72 endp ;*********************************** outport1 proc ;display on LEDs out ppi_port1_a,al out ppi_port2_b,al call delay2 call delay2 ret outport1 endp ;********************************** outport2 proc ;display on LEDs out ppi_port1_b,al out ppi_port2_b,al ;very short delay nop nop nop nop nop ret outport2 endp ;********************************** delay1 proc ;time delay about 160 ms push cx mov cx,4000h delay5: loop delay5 pop cx ret delay1 endp ;**********************************

RkJQdWJsaXNoZXIy NTk0NjM=