Embedded Systems 简明教程
Embedded Systems - Tools & Peripherals
Compilers and Assemblers
Compiler
编译器是一个计算机程序(或一组程序),它将用编程语言(源语言)编写的源代码转换为另一种计算机语言(通常是二进制格式)。转换的最常见原因是创建可执行程序。“编译器”一词主要用于将源代码从高级程序语言翻译成低级语言(例如汇编语言或机器代码)的程序。
A compiler is a computer program (or a set of programs) that transforms the source code written in a programming language (the source language) into another computer language (normally binary format). The most common reason for conversion is to create an executable program. The name "compiler" is primarily used for programs that translate the source code from a highlevel programming language to a low-level language (e.g., assembly language or machine code).
Cross-Compiler
如果已编译的程序可以在具有与编译器编译程序时计算机不同的 CPU 或操作系统的计算机上运行,那么该编译器称为交叉编译器。
If the compiled program can run on a computer having different CPU or operating system than the computer on which the compiler compiled the program, then that compiler is known as a cross-compiler.
Decompiler
能够将程序从低级语言翻译成高级语言的程序称为反编译器。
A program that can translate a program from a low-level language to a high-level language is called a decompiler.
Language Converter
一个能翻译用不同高级语言编写的程序的程序通常称为语言翻译器,源到源翻译器或语言转换器。
A program that translates programs written in different high-level languages is normally called a language translator, source to source translator, or language converter.
编译器可能会执行以下操作:
A compiler is likely to perform the following operations −
-
Preprocessing
-
Parsing
-
Semantic Analysis (Syntax-directed translation)
-
Code generation
-
Code optimization
Assemblers
汇编器是一个接受基本计算机指令(称为汇编语言)并将其转换为计算机处理器可用于执行其基本操作的比特模式的程序。汇编器通过将汇编指令助记符转换成操作码,将符号名解析成存储器位置来创建目标代码。汇编语言使用助记符表示每个低级机器操作(操作码)。
An assembler is a program that takes basic computer instructions (called as assembly language) and converts them into a pattern of bits that the computer’s processor can use to perform its basic operations. An assembler creates object code by translating assembly instruction mnemonics into opcodes, resolving symbolic names to memory locations. Assembly language uses a mnemonic to represent each low-level machine operation (opcode).
Debugging Tools in an Embedded System
调试是一个有条理的过程,用于查找和减少计算机程序或电子硬件块中的错误数量,以便其按预期工作。当子系统紧密耦合时,调试很困难,因为一个子系统中的一个小改动可能会在另一个子系统中产生错误。嵌入式系统中使用的调试工具在开发时间和调试功能方面差异很大。我们将在下面讨论以下调试工具:
Debugging is a methodical process to find and reduce the number of bugs in a computer program or a piece of electronic hardware, so that it works as expected. Debugging is difficult when subsystems are tightly coupled, because a small change in one subsystem can create bugs in another. The debugging tools used in embedded systems differ greatly in terms of their development time and debugging features. We will discuss here the following debugging tools −
-
Simulators
-
Microcontroller starter kits
-
Emulator
Simulators
代码通过在用于代码开发的主机计算机上模拟它来测试 MCU / 系统。模拟器尝试在软件中模拟完整微控制器的行为。
Code is tested for the MCU / system by simulating it on the host computer used for code development. Simulators try to model the behavior of the complete microcontroller in software.
Functions of Simulators
模拟器执行以下功能:
A simulator performs the following functions −
-
Defines the processor or processing device family as well as its various versions for the target system.
-
Monitors the detailed information of a source code part with labels and symbolic arguments as the execution goes on for each single step.
-
Provides the status of RAM and simulated ports of the target system for each single step execution.
-
Monitors system response and determines throughput.
-
Provides trace of the output of contents of program counter versus the processor registers.
-
Provides the detailed meaning of the present command.
-
Monitors the detailed information of the simulator commands as these are entered from the keyboard or selected from the menu.
-
Supports the conditions (up to 8 or 16 or 32 conditions) and unconditional breakpoints.
-
Provides breakpoints and the trace which are together the important testing and debugging tool.
-
Facilitates synchronizing the internal peripherals and delays.
Microcontroller Starter Kit
微控制器入门套件包括:
A microcontroller starter kit consists of −
-
Hardware board (Evaluation board)
-
In-system programmer
-
Some software tools like compiler, assembler, linker, etc.
-
Sometimes, an IDE and code size limited evaluation version of a compiler.
与模拟器相比,这些套件的一大优点是它们可在实时环境中工作,从而便于验证输入/输出功能。但是,入门套件完全足够,并且是最节省成本的开发简单微控制器项目的选项。
A big advantage of these kits over simulators is that they work in real-time and thus allow for easy input/output functionality verification. Starter kits, however, are completely sufficient and the cheapest option to develop simple microcontroller projects.
Emulators
仿真器是一个硬件套件或软件程序,或二者兼有,它在另一个与第一个不同的计算机系统(主机)中模拟一个计算机系统(来宾)的功能,从而模拟行为与真实系统(来宾)的行为非常相似。
An emulator is a hardware kit or a software program or can be both which emulates the functions of one computer system (the guest) in another computer system (the host), different from the first one, so that the emulated behavior closely resembles the behavior of the real system (the guest).
模拟是指电子设备中的计算机程序模拟(仿效)另一个程序或设备的能力。模拟专注于重新创建一个原始计算机环境。仿真器有能力保持与数字对象真实性的更紧密连接。仿真器帮助用户在一个平台上的任何类型的应用程序或操作系统中工作,类似于软件在其原始环境中运行的方式。
Emulation refers to the ability of a computer program in an electronic device to emulate (imitate) another program or device. Emulation focuses on recreating an original computer environment. Emulators have the ability to maintain a closer connection to the authenticity of the digital object. An emulator helps the user to work on any kind of application or operating system on a platform in a similar way as the software runs as in its original environment.
Peripheral Devices in Embedded Systems
嵌入式系统通过其外围设备与外部世界通信,如下所示:
Embedded systems communicate with the outside world via their peripherals, such as following &mins;
-
Serial Communication Interfaces (SCI) like RS-232, RS-422, RS-485, etc.
-
Synchronous Serial Communication Interface like I2C, SPI, SSC, and ESSI
-
Universal Serial Bus (USB)
-
Multi Media Cards (SD Cards, Compact Flash, etc.)
-
Networks like Ethernet, LonWorks, etc.
-
Fieldbuses like CAN-Bus, LIN-Bus, PROFIBUS, etc.
-
imers like PLL(s), Capture/Compare and Time Processing Units.
-
Discrete IO aka General Purpose Input/Output (GPIO)
-
Analog to Digital/Digital to Analog (ADC/DAC)
-
Debugging like JTAG, ISP, ICSP, BDM Port, BITP, and DP9 ports
Criteria for Choosing Microcontroller
在选择微处理器时,请确保它满足手头任务并具有成本效益。我们必须判断 8 位、16 位或 32 位微处理器能否最佳地处理任务的计算需求。此外,在选择微处理器时应牢记以下几点:
While choosing a microcontroller, make sure it meets the task at hand and that it is cost effective. We must see whether an 8-bit, 16-bit or 32-bit microcontroller can best handle the computing needs of a task. In addition, the following points should be kept in mind while choosing a microcontroller −
-
Speed − What is the highest speed the microcontroller can support?
-
Packaging − Is it 40-pin DIP (Dual-inline-package) or QFP (Quad flat package)? This is important in terms of space, assembling, and prototyping the end-product.
-
Power Consumption − This is an important criteria for battery-powered products.
-
Amount of RAM and ROM on the chip.
-
Count of I/O pins and Timers on the chip.
-
Cost per Unit − This is important in terms of final cost of the product in which the microcontroller is to be used.
此外,请确保您准备好该微处理器随附的工具,例如编译器、调试器和汇编器。最重要的是,您应从可靠的来源购买微处理器。
Further, make sure you have tools such as compilers, debuggers, and assemblers, available with the microcontroller. The most important of all, you should purchase a microcontroller from a reliable source.