[00]Foreword
The world of MCU-based embedded designs can be divided into those that take advantage of existing code and MCUs, and those that require leading edge MCU architectures and implementations.
[01]Introduction to Embedded Systems
An embedded system is an application-specific computer system which is built into a
larger system or device. Using a computer system enables improved performance, more
functions and features, lower cost, and greater dependability. With embedded computer
systems, manufacturers can add sophisticated control and monitoring to devices and other
systems while leveraging the low-cost microcontrollers running custom software.
[02]Microcontroller Concepts, Infrastructure, and Interfacing
Embedded systems consist of computers which are embedded in larger systems. Additional circuitry such as power supplies, clock generators, and reset circuits, are required for the computer to work. Transducers (devices that convert one type of energy into another) are also used to connect microcontrollers to the outside world. There are two classes of transducers: inputs and outputs. Inputs (sensors) include devices such as switches, temperature sensors, keypads, and buttons. Output transducers include devices such as LEDs, motors, and coils.
- Volatile memory is typically used to hold data which changes as the program runs.
- Interface peripherals communicate with external devices to sense the values of input signals and control the output signals.
- Internal peripheral devices provide additional functions without the need for external interfacing.
Power Supply
[待研]
Clock Signal Generation
[待研]
Reset Circuit
[待研]
General Purpose Digital I/O Basics
Embedded systems consist of computers embedded in larger systems. The processor needs to sense the state of the larger system and environment, and control output devices. The most basic way to do this is through one or more discrete signals, each of which can be in one of two states (on or off). General purpose digital I/O ports are the hardware which can be used to read from or write to the system outside the microcontroller.
The RL78 has multiple I/O ports, numbered starting at P0. Each port typically has eight bits, with each bit connected to a specific pin on the MCU package. For most ports, each bit can be configured individually as an input or output, although there are some limited-function port bits which have partial configurability such as input-only.
A port pin may serve several purposes; for example, one might be used as a general purpose I/O pin, as anA/D converter input, or as an interrupt input, based on how it is configured. Depending on the purposes these pins serve, they might have extra registers.
Control Registers
There are multiple registers used to control and monitor ports. We can find the details of these registers in the User's Manual (Renesas Electronics Corporation 2011) chapter on Port Functions.
- The Port Mode register (PM) controls whether a particular port bit is an input (selected with 1) or an output (0).
端口模式寄存器(PM)控制特定端口位是输入(选择1)还是输出(0)。
- The Port register (P) holds the data value for the port. For example, if port 0 is configured as all inputs, then reading from register P0 will indicate what binary input values are present on the pins of port 0. If port 1 is configured as all outputs, writing to register P1 will cause those binary values to appear on the pins of port 1.
端口寄存器(P)存放该端口的数据。例如,如果端口0的所有位全部配置为输入,那么读出寄存器P0将指示出端口0所有引脚上的二进制输入值。如果将端口P1的所有位全部配置为输出,那么写入寄存器P1将使得写入的二进制数值显现在端口1的所有引脚上。
- The Pull-Up resistor option register (PU) controls whether an internal pull-up resistor is connected (selected with 1) to that input bit or not (0).
上拉电阻选择寄存器(PU)控制内部上拉电阻是连接(使用1来选择)还是不连接(0)。
- The Port InputMode register (PIM) controls which type of voltage threshold (TTL or CMOS) is used to determine whether an input is a 1 or a 0. The CMOS thresholds (normal, selected with 0) are proportional to the supply voltage VDD, while the TTL thresholds (1) are fixed voltages.
端口输入模式寄存器(PIM)
The Port OutputMode register (POM) controls whether an output can be driven up or down (push-pull mode, selected with 0), or just down (N-channel open-drain, selected with 1). This is useful for applications such as sharing a bus which may be driven by other devices.
The Port Mode Control register (PMC) controls whether an input is used for analog (selected with 1) or digital (0) purposes.
The Peripheral I/O Redirection register (PIOR) allows certain peripheral signals to be routed to one of two possible port pins, simplifying circuit design.
INTERFACING WITH ANALOG SIGNALS####
The world is not digital; it is analog. Microphones, thermometers, speakers, light sensors, and even video cameras are all analog sensors. As a result, the signals from these sensors must be converted to digital values so that the microcontrollers can process them.