บทที่ 9: การรับส่งข้อมูลแบบ...
TRANSCRIPT
![Page 1: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/1.jpg)
บทที่ 9: การรับส่งข้อมูลแบบอนุกรม
ไมโครโพรเซสเซอร์ 1
Sanya Kuankid, Ph.D.http://pws.npru.ac.th/sanya/
![Page 2: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/2.jpg)
บทที ่9 การรบัสง่ขอ้มลูแบบอนกุรม
9.1 บทน า
9.2 พืน้ฐานการรบัสง่ขอ้มลูแบบอนกุรม
9.3 การสือ่สารขอ้มลูแบบอะซงิโครนสั
9.4 เรจสิเตอรท์ีเ่กีย่วขอ้งกบัการท างานของพอรต์อนุกรม
9.5 การท างานของพอรต์อนกุรมในโหมดตา่งๆ
9.6 การค านวณหาคา่อตัราบอดของการสือ่สารขอ้มลูทาง พอรต์อนกุรม
9.7 สรปุ
9.8 แบบฝึกหดัทา้ยบท
![Page 3: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/3.jpg)
9.1 บทน า
![Page 4: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/4.jpg)
9.2 พื้นฐานการรับส่งข้อมูลแบบอนุกรม
![Page 5: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/5.jpg)
9.2 พื้นฐานการรับส่งข้อมูลแบบอนุกรม
ภาพที่ 9.1 รูปแบบการรับส่งข้อมูล (a) แบบขนาน (b) แบบอนุกรม
![Page 6: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/6.jpg)
9.3 การสื่อสารข้อมูลแบบ อะซิงโครนัส
![Page 7: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/7.jpg)
9.3 การสื่อสารข้อมูลอนกุรมแบบอะซงิโครนสั
ภาพที่ 9.2 ล าดับการส่งข้อมูลแบบอะซิงโครนัส
![Page 8: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/8.jpg)
9.4 เรจิสเตอร์ที่เกี่ยวข้องกับการท างานของพอร์ตอนุกรม
![Page 9: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/9.jpg)
9.4.1 เรจิสเตอร์ SBUF เรจิสเตอร์ SBUF (Serial data buffer
register) เป็นเรจิสเตอร์ฟังก์ชันพิเศษมีแอดเดรสอยู่ที่99H ท าหน้าที่เป็นเรจิสเตอร์ส าหรับเก็บข้อมูลที่ส่งออกทางสัญญาณ TxD หรือบิต P3.1 และท าหน้าที่เป็นเรจิสเตอร์ส าหรับเก็บข้อมูลที่รับเข้ามาทางสายสัญญาณ RxD หรือบิต P3.0
![Page 10: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/10.jpg)
9.4.2 เรจิสเตอร์ SCON เรจิสเตอร์ SCON (Serial port control register) มีแอดเดรสอยู่ที่ 98H ท าหน้าที่ควบคุมและระบุสภาวะการท างานของพอร์ตอนุกรม
ภาพที่ 9.3 รายละเอียดบิตต่างๆ ของเรจิสเตอร์ SCON
![Page 11: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/11.jpg)
9.4.2 เรจิสเตอร์ SCON ตารางที่ 9.1 การท างานในบิตต่างๆ ของเรจิสเตอร์ SCON
![Page 12: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/12.jpg)
9.5 การท างานของพอร์ตอนุกรมในโหมดต่างๆ
![Page 13: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/13.jpg)
9.5 การท างานในโหมดของพอร์ตอนุกรมในโหมดต่างๆ
ตารางที่ 9.2 โหมดการท างานของพอร์ตอนุกรม
![Page 14: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/14.jpg)
9.5.1 การท างานของพอร์ตอนุกรมในโหมด 0
การท างานในโหมด 0 จะมีลักษณะการท างานเหมือนกันกับชิฟเรจิสเตอร์ (Shift register) การรับส่งข้อมูลในโหมดนี้จะใช้สายสัญญาณ RxD เป็นทางผ่านของข้อมูล และจะใช้สายสัญญาณ TxD เป็นตัวรับส่งสัญญาณนาฬิกา
![Page 15: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/15.jpg)
9.5.2 การท างานของพอร์ตอนุกรมในโหมด 1
ภาพที่ 9.4 แผนภาพบล็อกแสดงการท างานของ UART ขนาด 8 บิต (a) การส่งข้อมูล
![Page 16: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/16.jpg)
9.5.2 การท างานของพอร์ตอนุกรมในโหมด 1
ภาพที่ 9.4 แผนภาพบล็อกแสดงการท างานของ UART ขนาด 8 บิต (b) การรับข้อมูล
![Page 17: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/17.jpg)
9.5.3 การท างานของพอร์ตอนุกรมในโหมด 2 และโหมด 3
ภาพที่ 9.5 แผนภาพบล็อกแสดงการท างานของ UART ขนาด 9 บิต (a) การส่งข้อมูล
![Page 18: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/18.jpg)
9.5.3 การท างานของพอร์ตอนุกรมในโหมด 2 และโหมด 3
ภาพที่ 9.5 แผนภาพบล็อกแสดงการท างานของ UART ขนาด 9 บิต (b) การรับข้อมูล
![Page 19: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/19.jpg)
9.6 การค านวณหาค่าอัตราบอดของการสื่อสารข้อมูลทาง
พอร์ตอนุกรม
![Page 20: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/20.jpg)
9.6.1 การค านวณหาค่าอัตราบอดของพอร์ตอนุกรมโหมด 0
![Page 21: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/21.jpg)
9.6.4 การค านวณหาค่ารีโหลดของไทม์เมอรเ์พื่อให้ค่าอัตราบอดตามความต้องการ
![Page 22: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/22.jpg)
9.6.4 การค านวณหาค่ารีโหลดของไทม์เมอรเ์พื่อให้ค่าอัตราบอดตามความต้องการ
ตารางที่ 9.3 การก าหนดค่ารีโหลดเพื่อใช้งานพอร์ตอนุกรม
![Page 23: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/23.jpg)
9.7 สรุป
![Page 24: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/24.jpg)
สรุป
ในบทนี้ผู้เรียนได้ท าความเข้าใจเกี่ยวกับการสื่อสารข้อมูลผ่านพอร์ตอนุกรมของไมโครคอนโทรลเลอร์ MCS-51 โดยการใช้งานการสื่อสารผ่านพอร์ตอนุกรม แบบโพลลิง (Polling) ซึ่งเป็นการเขียนโปรแกรมแบบวนรอบเพื่อรอรับข้อมูลที่ผ่านเข้ามาทางขาอินพุตของพอร์ตอนุกรมตลอดเวลา เนื้อหาในบทต่อไปจะได้กล่าวถึงกระบวนการอินเตอร์รัพท์ส าหรับไมโครคอนโทรลเลอร์ MCS-51
![Page 25: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/25.jpg)
9.8 แบบฝึกหัดท้ายบท
![Page 26: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/26.jpg)
9.8 แบบฝึกหัดท้ายบท
![Page 27: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/27.jpg)
เอกสารอ้างอิง
. (2554). 1. : ( - ).
. (2555). MCS-51 C. :
. (2540). . : ( - ).
. (2550). MCS-51 C P89V51RD2. : .
. ( . . .). 1. 1 2557 http://www.it.tl.ac.th/~witsarut/subject_c.html
. (2550). MCS-51 Keil C51 . : .
. (2546). . : .
Architecture and Programming of 8051 MCUS. Retrieved March 1, 2014, from http://www.mikroe.com/products/view/267/architecture-and-programming-of-8051-mcu-s/
ARMKIEL Microcontrollers Tools. Cx51 User’s Guide. Retrieved April 1, 2014, from http://www.keil.com/support/man/docs/c51/
Michael, P. (2001). Patterns for time-triggered embedded systems: Building reliable applications with the 8051 family of microcontrollers. New York: ACM Press Books.
Michael, P. (2002). Embedded C. London: Addison-Wesley Professional.
Microcontroller with 8K Bytes Flash AT89C52. Retrieved March 1, 2014, from http://www.atmel.com/images/doc0313.pdf
Z80 CPU User Manual. Retrieved April 1, 2014, from http://www.zilog.com/appnotes_download.php?FromPage=DirectLink&dn= UM0080&ft=User%20Manual&f=YUhSMGNEb3ZMM2QzZHk1NmFXeHZaeTVqYjIwdlpHOWpjeTk2T0RBdlZVMHdNRGd3TG5Ca1pnPT0=
![Page 28: บทที่ 9: การรับส่งข้อมูลแบบ ...courseware.npru.ac.th/admin/files/20171107112801_27ef...ภาพท 9.4 แผนภาพบล อกแสดงการท](https://reader033.vdocuments.pub/reader033/viewer/2022041607/5e34fd2ded5adb037b63c040/html5/thumbnails/28.jpg)
เอกสารอ้างอิง
. (2554). 1. : ( - ).
. (2555). MCS-51 C. :
. (2540). . : ( - ).
. (2550). MCS-51 C P89V51RD2. : .
. ( . . .). 1. 1 2557 http://www.it.tl.ac.th/~witsarut/subject_c.html
. (2550). MCS-51 Keil C51 . : .
. (2546). . : .
Architecture and Programming of 8051 MCUS. Retrieved March 1, 2014, from http://www.mikroe.com/products/view/267/architecture-and-programming-of-8051-mcu-s/
ARMKIEL Microcontrollers Tools. Cx51 User’s Guide. Retrieved April 1, 2014, from http://www.keil.com/support/man/docs/c51/
Michael, P. (2001). Patterns for time-triggered embedded systems: Building reliable applications with the 8051 family of microcontrollers. New York: ACM Press Books.
Michael, P. (2002). Embedded C. London: Addison-Wesley Professional.
Microcontroller with 8K Bytes Flash AT89C52. Retrieved March 1, 2014, from http://www.atmel.com/images/doc0313.pdf
Z80 CPU User Manual. Retrieved April 1, 2014, from http://www.zilog.com/appnotes_download.php?FromPage=DirectLink&dn= UM0080&ft=User%20Manual&f=YUhSMGNEb3ZMM2QzZHk1NmFXeHZaeTVqYjIwdlpHOWpjeTk2T0RBdlZVMHdNRGd3TG5Ca1pnPT0=