Thiết kế hệ thống nhúng với vi điều khiển 8031 - Balaji Frontline

Tổng hợp sách và giáo trình vi xử lý chất lượng từ cơ bản đến nâng cao. Cung cấp kiến thức về kiến trúc máy tính, tập lệnh và kỹ thuật lập trình.

Trường đại học

Frontline Electronics

Chuyên ngành

Kỹ thuật điện tử

Tác giả

Ẩn danh

Người đăng

Ẩn danh

Thể loại

Sách

2002

100
0
0

Phí lưu trữ

35 Point

Tóm tắt

I. Tổng quan về book vi xử lý trong thiết kế hệ thống nhúng

Hệ thống nhúng hiện diện khắp mọi nơi trong đời sống kỹ thuật số. Thiết bị gia dụng, phương tiện giao thông và máy móc công nghiệp đều vận hành nhờ vi điều khiển. Cuốn sách Embedded System Design Using 8031 Microcontrollers cung cấp kiến thức nền tảng về kiến trúc máy tính và kỹ thuật điều khiển phần cứng. Vi điều khiển họ 8031 là trung tâm xử lý dữ liệu với cấu trúc kinh điển. Dòng chip này tích hợp bộ nhớ RAM nội bộ, các cổng vào ra đa chức năng cùng các khối định thời gian chính xác. Tài liệu trình bày chi tiết phương thức tổ chức không gian nhớ, cơ chế quản lý thanh ghi và nguyên lý vận hành của khối xử lý trung tâm. Các kỹ sư và sinh viên kỹ thuật tiếp cận trực tiếp cấu trúc vi mạch ở mức vật lý. Việc nghiên cứu nền tảng 8031 giúp chuẩn hóa tư duy lập trình phần cứng. Người học nắm vững cách dữ liệu di chuyển qua các thanh ghi chức năng đặc biệt SFR. Nền tảng này tạo bước đệm vững chắc cho việc tiếp cận các họ vi điều khiển nâng cao như ARM hay AVR. Tài liệu kết hợp chặt chẽ giữa lý thuyết hàn lâm và kinh nghiệm thực nghiệm của các kỹ sư đầu ngành.

1.1. Cấu trúc phần cứng và tập thanh ghi của vi điều khiển 8031

Vi điều khiển 8031 sở hữu kiến trúc Harvard kinh điển. Bộ nhớ chương trình và bộ nhớ dữ liệu tách biệt hoàn toàn. Khối CPU quản lý 128 byte RAM nội bộ cùng hệ thống thanh ghi chức năng đặc biệt SFR. Thanh ghi tích lũy Accumulator giữ vai trò then chốt trong hầu hết phép toán logic và số học. Bốn cổng xuất nhập dữ liệu P0, P1, P2, P3 hỗ trợ giao tiếp ngoại vi linh hoạt. Khối định thời Timer và cổng nối tiếp UART tích hợp sẵn trên chip giúp tối ưu hóa phần cứng. Thiết kế này đơn giản hóa việc quản lý tín hiệu và giảm thiểu kích thước bo mạch.

1.2. Hệ thống tập lệnh hợp ngữ và mô hình phân chia bộ nhớ

Tập lệnh hợp ngữ của dòng 8031 được tối ưu hóa cho tác vụ xử lý theo từng bit. Các nhóm lệnh chuyển đổi dữ liệu, thao tác số học và rẽ nhánh điều kiện thực thi rất nhanh chóng. Khi hoạt động với xung nhịp 12MHz, phần lớn chỉ lệnh chỉ mất một chu kỳ máy một micro giây. Không gian địa chỉ hỗ trợ mở rộng tối đa 64KB RAM ngoài và 64KB ROM ngoài qua giao tiếp chân chuyên dụng. Chế độ định địa chỉ gián tiếp qua con trỏ dữ liệu DPTR cho phép truy xuất mảng dữ liệu lớn một cách hiệu quả và chính xác.

II. Phân tích thách thức khi học qua book vi xử lý họ 8031

Quá trình tiếp cận kỹ thuật nhúng từ sách chuyên khảo thường đối mặt với nhiều rào cản kỹ thuật. Việc nắm bắt tập lệnh Assembly đòi hỏi tư duy logic trừu tượng cao. Người học dễ gặp khó khăn trong việc quản lý thời gian thực thi của từng câu lệnh. Cấu hình các thanh ghi định thời Timer hoặc ngắt ngoài đòi hỏi độ chính xác tuyệt đối. Việc kết nối phần cứng thực tế thường phát sinh hiện tượng nhiễu tín hiệu hoặc sụt áp nguồn. Thiếu thốn thiết bị đo lường chuyên dụng như máy hiện sóng hay máy phân tích logic gây cản trở kiểm tra lỗi mạch. Ngoài ra, việc viết mã cho các quy trình ngắt Interrupt Service Routine dễ dẫn đến xung đột dữ liệu nếu không lưu trữ trạng thái thanh ghi cẩn thận. Dòng vi điều khiển 8031 không tích hợp sẵn bộ nhớ Flash ROM nội bộ. Yếu tố này buộc người thiết kế phải kết nối thêm chip nhớ ngoài phức tạp. Sự sai lệch trong căn thời gian truy xuất bộ nhớ ngoài có thể khiến toàn bộ hệ thống tê liệt. Việc phân tích thấu đáo các vấn đề này là điều kiện tiên quyết trước khi bước vào giai đoạn thiết kế mạch.

2.1. Khó khăn trong gỡ lỗi phần cứng và đồng bộ tín hiệu thời gian

Gỡ lỗi trên hệ thống phần cứng vi điều khiển 8031 tiềm ẩn nhiều rủi ro sai sót. Các xung nhiễu điện từ ngoài môi trường công nghiệp dễ làm sai lệch tín hiệu điều khiển. Việc đồng bộ hóa bus dữ liệu và bus địa chỉ khi ghép nối RAM ngoài đòi hỏi tính toán trễ đường truyền nghiêm ngặt. Thiếu mạch nạp nạp trực tiếp in-system programming làm chậm chu kỳ thử nghiệm. Kỹ sư phải nhổ vi mạch ra khỏi đế cắm nhiều lần để nạp lại mã nguồn. Thao tác này dễ gây gãy chân linh kiện và làm suy giảm độ tin cậy của toàn bộ mạch mẫu.

2.2. Xung đột tài nguyên thanh ghi trong xử lý ngắt thời gian thực

Hệ thống ngắt của 8031 cung cấp hai mức ưu tiên ngắt cơ bản. Khi chương trình phục vụ ngắt thực thi, việc ghi đè thanh ghi Accumulator hoặc con trỏ dữ liệu sẽ phá hủy luồng tính toán chính. Lỗi này rất khó phát hiện bằng các phương pháp kiểm tra thông thường. Bên cạnh đó, việc phân bổ sai không gian ngăn xếp Stack Pointer dẫn đến hiện tượng tràn bộ nhớ dữ liệu nội bộ. Kỹ sư phải kiểm soát chặt chẽ từng byte bộ nhớ nhằm đảm bảo tính toàn vẹn của dữ liệu trong các tác vụ khẩn cấp.

III. Phương pháp khai thác book vi xử lý vào thiết kế mạch

Tài liệu kỹ thuật cung cấp các giải pháp chuẩn mực để giải quyết triệt để rào cản kỹ thuật. Phương pháp tiếp cận hiện đại bắt đầu bằng việc ứng dụng các phần mềm mô phỏng chuyên nghiệp như Topview Simulator. Môi trường giả lập cho phép quan sát trực tiếp trạng thái các cổng vào ra, thanh ghi nội bộ và chu kỳ xung nhịp. Việc sử dụng các công cụ biên dịch chéo Assembler độc lập giúp tự động hóa khâu chuyển đổi mã nguồn sang mã máy. Đối với phần cứng, việc chuyển đổi sang các biến thể 8031 có Flash như AT89C51 của Atmel mang lại sự tiện lợi vượt bậc. Bộ nhớ Flash cho phép nạp xóa chương trình điện tử hàng nghìn lần mà không cần bộ nhớ ngoài. Giải pháp thiết kế theo khối mô-đun hóa được áp dụng triệt để. Mỗi khối ngoại vi gồm màn hình LED, bàn phím ma trận và bộ chuyển đổi ADC được kiểm tra độc lập trước khi tích hợp. Cách tiếp cận này rút ngắn đáng kể thời gian nghiên cứu và phát triển sản phẩm nhúng.

3.1. Ứng dụng phần mềm mô phỏng Topview Simulator và bộ gỡ lỗi từ xa

Môi trường mô phỏng Topview Simulator tái hiện trung thực hoạt động của vi điều khiển 8031. Kỹ sư có thể đặt điểm dừng breakpoint, chạy từng bước đơn lệnh và theo dõi biến thiên dữ liệu. Công cụ hỗ trợ giả lập trực quan các thiết bị ngoại vi như LED bảy đoạn, ma trận phím và màn hình LCD. Bộ gỡ lỗi từ xa kết hợp mạch mô phỏng In Circuit Emulator giúp định vị chính xác lỗi mã nguồn trên phần cứng thực. Phương pháp này loại bỏ nguy cơ chập cháy linh kiện trong giai đoạn thử nghiệm đầu tiên.

3.2. Chuẩn hóa quy trình giao tiếp ngoại vi và chuyển đổi tương tự số

Thiết kế giao tiếp ngoại vi đòi hỏi tuân thủ các quy chuẩn cách ly tín hiệu quang điện. Bộ ghép nối analog đa kênh CD4051 kết hợp chip chuyển đổi ADC 12-bit ICL7109 tạo nên hệ thu thập dữ liệu chính xác cao. Cổng nối tiếp UART của vi điều khiển liên kết với máy tính chủ thông qua vi mạch đệm MAX232. Chuẩn RS232 đảm bảo truyền tải dữ liệu tin cậy qua khoảng cách xa. Quy trình chuẩn hóa sơ đồ nguyên lý giúp hệ thống hoạt động ổn định và dễ bảo trì lâu dài.

IV. Ứng dụng thực tiễn của book vi xử lý trong công nghiệp

Cuốn sách vi xử lý mở ra cánh cửa ứng dụng vô tận vào các dự án công nghiệp thực tế. Nền tảng điều khiển 8031 được triển khai thành công trong hệ thống thu thập dữ liệu 8 kênh từ xa. Thiết bị giám sát liên tục các thông số điện áp, nhiệt độ và tự động kích hoạt cảnh báo khi vượt ngưỡng an toàn. Trong lĩnh vực điều khiển tự động, vi điều khiển đảm nhận việc tạo chuỗi xung điều khiển động cơ bước chính xác. Các thiết bị viễn thông công cộng như máy đo xung 16KHz cho buồng điện thoại cũng vận hành bền bỉ dựa trên kiến trúc này. Kinh nghiệm thiết kế từ tài liệu giúp các kỹ sư xây dựng hệ thống tuần tự 8 kênh điều khiển rơ-le công suất lớn. Khả năng làm việc ổn định trong môi trường khắc nghiệt khẳng định giá trị bền vững của dòng chip 8031. Việc nắm vững kiến trúc cơ bản là chìa khóa để làm chủ mọi nền tảng nhúng tiên tiến trong kỷ nguyên tự động hóa thông minh.

4.1. Hệ thống thu thập dữ liệu và giám sát tín hiệu tương tự đa kênh

Hệ thống thu thập dữ liệu 8 kênh sử dụng vi điều khiển AT89C51 vận hành liên tục tại các trạm đo công nghiệp. Chip trung tâm quét tuần tự các cổng vào analog với tốc độ lấy mẫu ổn định. Bộ xử lý tự động tính toán, so sánh giá trị cảm biến với ngưỡng cài đặt và truyền dữ liệu về trung tâm điều khiển. Việc tích hợp thêm mô-đun đồng hồ thời gian thực RTC cho phép gắn nhãn thời gian chính xác cho từng sự kiện nhật ký. Cấu trúc này giải phóng đáng kể tải xử lý cho máy chủ quản trị.

4.2. Bộ điều khiển động cơ bước và thiết bị đo lường viễn thông chuyên dụng

Vi điều khiển 8031 phát huy tối đa hiệu năng trong việc điều khiển góc quay và tốc độ động cơ bước. Chương trình xuất các chuỗi xung logic chính xác theo chu kỳ định trước qua cổng xuất nhập. Bên cạnh đó, thiết bị giám sát xung tính cước 16KHz trên đường dây điện thoại chứng minh khả năng lọc tín hiệu xuất sắc. Hệ thống phát hiện kịp thời các xung tính phí và bảo vệ an toàn cho đường truyền viễn thông. Các dự án này khẳng định tính ứng dụng cao của kiến thức chuyên ngành vi điều khiển.

Tóm tắt và mô tả trên trang này được tạo với sự hỗ trợ của AI. Nếu bạn thấy nội dung không chính xác hoặc có vấn đề, vui lòng Báo lỗi nội dung.

05/06/2026

Trích đoạn nội dung tài liệu

Embedded System Design Using 8031 Microcontrollers Embedded System Design Using 8031 Microcontrollers Balaji, Technical Director, Frontline Electronics, India. Author’s Note It is my great pleasure in introducing this eBook to your eyes. It covers many steps that should go into an Embedded System Design. Frontline Electronics has about 15 years of experience using 8031 microcontrollers and I was happy to be with 8031 in all these years.

The contents of this eBook has been derived from our team’s vast hands-on experience. Along the way, you may find the discussion about Frontline Electronics’ software tools. I am sure that these discussions should give you many useful information that will help you in finishing your target design fast. As an author, I am eagerly looking forward to get your feedback on this eBook.

Any suggestion is most welcome. If I get enough feedback, I may include the source code for all the projects in the next edition. You can freely distribute this eBook to the fellow designers or any one interested in embedded electronics. Welcome to the Embedded world.!!! Balaji Technical Director Frontline Electronics India.2002 Email : Balaji@frontlinemail.com CopyRight : Frontline Electronics Private Limited, India, 2002.

Contents Chapter 1: Introduction To Embedded Systems Introduction .2 Central Processing Unit .3 Input / Output Ports .7 Common Memory Space .3 Register Indirect Addressing .1 Data Transfer Instructions .2 Data Transfer In External RAM .6 Program Control - Jumps, Calls, and Returns .8 Conditional Jump Instructions .9 Operate and Branch Instructions. 24 57 Embedded System Design Using 8031 Microcontrollers Chapter 3: 8031 Derivatives 3.2 Why Atmel Devices? .29 Chapter 4: Real Life Projects 4.1 16KHz Monitor for the Public Call Office .2 Telephone Line Interface .3 16KHz Metering Pulse Detection .4 Stepper Motor Controller .6 8 Channel Data Acquisition System .7 8 Channel Sequential Controller .50 Chapter 5: Project Tools 5.2 Stand Alone Device Assemblers .3 Stand Alone Remote Debugger .5 In Circuit Emulators .56 Chapter 6: Topview Simulator 6.1 Plain Point LEDs .2 Seven Segment Displays .71 58 Embedded System Design Using 8031 Microcontrollers 6.7 Code Generation Facilities .1 Internal Peripheral Functions .2 External Peripheral Modules .1 LED Display Functions .2 LCD Module Selection. 80 Chapter 7: Topview Debugger 7.82 Chapter 8: Topview Programmer 8. 90 Chapter 9: Contact Frontline Electronics 9.1 Contact Frontline Electronics .93 59 Embedded System Design Using 8031 Microcontrollers Chapter 1 - Introduction To Embedded Systems l Introduction 1 Embedded System Design Using 8031 Microcontrollers Chapter 1 - Introduction To Embedded Systems Introduction We are living in the Embedded World.

You are surrounded with many embedded products and your daily life largely depends on the proper functioning of these gadgets. Television, Radio, CD player of your living room, Washing Machine or Microwave Oven in your kitchen, Card readers, Access Controllers, Palm devices of your work space enable you to do many of your tasks very effectively. Apart from all these, many controllers embedded in your car take care of car operations between the bumpers and most of the times you tend to ignore all these controllers. In recent days, you are showered with variety of information about these embedded controllers in many places.

All kinds of magazines and journals regularly dish out details about latest technologies, new devices, fast applications which make you believe that your basic survival is controlled by these embedded products. Now you can agree to the fact that these embedded products have successfully invaded into our world. You must be wondering about these embedded controllers or systems. What is this Embedded System? The computer you use to compose your mails, or create a document or analyze the database is known as the standard desktop computer.

These desktop computers are manufactured to serve many purposes and applications. You need to install the relevant software to get the required processing facility. So, these desktop computers can do many things. In contrast, embedded controllers carryout a specific work for which they are designed.

Most of the time, engineers design these embedded controllers with a specific goal in mind. So these controllers cannot be used in any other place. Theoretically, an embedded controller is a combination of a piece of microprocessor based hardware and the suitable software to undertake a specific task. These days designers have many choices in microprocessors/microcontrollers.

Especially, in 8 bit and 32 bit, the available variety really may overwhelm even an experienced designer. Selecting a right microprocessor may turn out as a most difficult first step and it is getting complicated as new devices continue to pop-up very often. In the 8 bit segment, the most popular and used architecture is Intel’s 8031. Market acceptance of this particular family has driven many semiconductor manufacturers to develop something new based on this particular architecture.

You can find this 8031 in a variety of configurations, flavour and definitely you cannot see this kind of variations with any other architecture. Even after 25 years of existence, semiconductor manufacturers still come out with some kind of device using this 8031 core. 2 Embedded System Design Using 8031 Microcontrollers Chapter 2 - 8031 Microcontrollers l Intel’s 8031 Architecture l Instruction Set l Central Processing Unit l Data Transfer Instructions l Input / Output Ports l Data Transfer In External RAM l Timers / Counters l Lookup Tables l Serial Port l Arithmetic Instructions l Memory Organization l Logical Instructions l Common Memory Space l Program Control-Jumps, Calls and Returns l Interrupts l Jump Instructions l Addressing Modes l Conditional Jump Instructions l Register Addressing l Operate and Branch Instructions l Direct Addressing l Boolean Instructions l Register Indirect Addressing l Immediate Addressing l Index Addressing 3 Embedded System Design Using 8031 Microcontrollers Chapter 2 - 8031 Microcontrollers 2.1 - Intel’s 8031 Architecture The generic 8031 architecture sports a Harvard architecture, which contains two separate buses for both program and data. So, it has two distinctive memory spaces of 64K X 8 size for both program and data.

It is based on an 8 bit central processing unit with an 8 bit Accumulator and another 8 bit B register as main processing blocks. Other portions of the architecture include few 8 bit and 16 bit registers and 8 bit memory locations. Each 8031 device has some amount of data RAM built in the device for internal processing. This area is used for stack operations and temporary storage of data.

This base architecture is supported with onchip peripheral functions like I/O ports, timers/counters, versatile serial communication port. So it is clear that this 8031 architecture was designed to cater many real time embedded needs. The following list gives the features of the 8031 architecture: l Optimized 8 bit CPU for control applications. l Extensive Boolean processing capabilities.

l 64K Program Memory address space. l 64K Data Memory address space. l 128 bytes of onchip Data Memory. l 32 Bi-directional and individually addressable I/O lines.

l Two 16 bit timer/counters. l Full Duplex UART. l 6-source / 5-vector interrupt structure with priority levels. l Onchip clock oscillator.

Now you may be wondering about the non mentioning of memory space meant for the program storage, the most important part of any embedded controller. Originally this 8031 architecture was introduced with onchip, ‘one time programmable’ version of Program Memory of size 4K X 8. Intel delivered all these microcontrollers (8051) with user’s program fused inside the device. The memory portion was mapped at the lower end of the Program Memory area.

But, after getting devices, customers couldn’t change any thing in their program code, which was already made available inside during device fabrication. 4 Embedded System Design Using 8031 Microcontrollers Chapter 2 - 8031 Microcontrollers Intel’s 8031 Architecture EXTERNAL INTERRUPTS 4K ROM TIMER 1 COUNTER INTERRUPT (8051) 128 BYTES CONTROL RAM INPUTS TIMER 0 CPU BUS SERIAL OSC 4 I/O PORTS CONTROL PORT TXD RXD P0 P2 P1 P3 ADDRESS/DATA Figure 1 - Block Diagram of the 8031 Core So, very soon Intel introduced the 8031 devices (8751) with re-programmable type of Program Memory using built-in EPROM of size 4K X 8. Like a regular EPROM, this memory can be re-programmed many times. Later on Intel started manufacturing these 8031 devices without any onchip Program Memory.

Now I go ahead giving more information on the important functional blocks of the 8031.0/RXD 10 31 VDD/EA P3.1/TXD 11 30 PROG/ALE P3.0 Figure 2 - 8031 Microcomputer Pinout Diagram 5 Embedded System Design Using 8031 Microcontrollers Chapter 2 - 8031 Microcontrollers Intel’s 8031 Architecture VSS VCC RST/VPD XTAL1 PORT0 XTAL2 EA/VDD PSEN ALE/PROG 8031 PORT1 RXD TXD INT0 INT1 PORT3 T0 T1 PORT2 WR RD Figure 3 - 8031 Microcomputer logic symbol 2.2 - Central Processing Unit The CPU is the brain of the microcontrollers reading user’s programs and executing the expected task as per instructions stored there in. Its primary elements are an 8 bit Arithmetic Logic Unit (ALU), Accumulator (Acc), few more 8 bit registers, B register, Stack Pointer (SP), Program Status Word (PSW) and 16 bit registers, Program Counter (PC) and Data Pointer Register (DPTR). The ALU (Acc) performs arithmetic and logic functions on 8 bit input variables. Arithmetic operations include basic addition, subtraction, multiplication and division.

Logical operations are AND, OR, Exclusive OR as well as rotate, clear, complement and etc. Apart from all the above, ALU is responsible in conditional branching decisions, and provides a temporary place in data transfer operations within the device. B register is mainly used in multiply and divide operations. During execution, B register either keeps one of the two inputs and then retains a portion of the result.

For other instructions, it can be used as another general purpose register. Program Status Word keeps the current status of the ALU in different bits. 6 Embedded System Design Using 8031 Microcontrollers Chapter 2 - 8031 Microcontrollers Central Processing Unit Stack Pointer (SP) is an 8 bit register. This pointer keeps track of memory space where the important register information are stored when the program flow gets into executing a subroutine.

The stack portion may be placed in any where in the onchip RAM. But normally SP is initialized to 07H after a device reset and grows up from the location 08H. The Stack Pointer is automatically incremented or decremented for all PUSH or POP instructions and for all subroutine calls and returns. Program Counter (PC) is the 16 bit register giving address of next instruction to be executed during program execution and it always points to the Program Memory space.

Data Pointer (DPTR) is another 16 bit addressing register that can be used to fetch any 8 bit data from the data memory space. When it is not being used for this purpose, it can be used as two eight bit registers.3 - Input / Output Ports The 8031’s I/O port structure is extremely versatile and flexible. The device has 32 I/O pins configured as four eight bit parallel ports (P0, P1, P2 and P3). Each pin can be used as an input or as an output under the software control.

These I/O pins can be accessed directly by memory instructions during program execution to get required flexibility. These port lines can be operated in different modes and all the pins can be made to do many different tasks apart from their regular I/O function executions. Instructions, which access external memory, use port P0 as a multiplexed address/data bus. At the beginning of an external memory cycle, low order 8 bits of the address bus are output on P0.

The same pins transfer data byte at the later stage of the instruction execution. Also, any instruction that accesses external Program Memory will output the higher order byte on P2 during read cycle. Remaining ports, P1 and P3 are available for standard I/O functions. But all the 8 lines of P3 support special functions: Two external interrupt lines, two counter inputs, serial port’s two data lines and two timing control strobe lines are designed to use P3 port lines.

Nội dung được bảo vệ bản quyền — Tải xuống đầy đủ