Файл: Embedded Controller Hardware Design (Ken Arnold, 2001).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 13.06.2025

Просмотров: 2650

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

194EMBEDDED CONTROLLER

Hardware Design

When multiple simultaneous interrupts occur, the processor must have some way of choosing which interrupt should be processed first. There are two common techniques for resolving the priority of simultaneous interrupts: serial and parallel.

Serial Interrupt Prioritization

When an interrupt occurs, the interrupting device lowers IEO and waits until IEI is high. Each device below it in line lowers its IEO. The device then per­ forms an interrupt cycle. When the ISR is complete an end of interrupt occurs, the interrupting device raises its IEO line, which propagates down the line. This is usually referred to as a daisy chain interrupt priority system. At any given time, the highest priority device in the chain will be serviced first. Figure 9-11 illustrates this process.

Logic

One

Highest

Lowest

IEI IEO

IEI IEO

IEI IEO

IEI IEO

IEI = Interrupt Enable Input

IEO = Interrupt Enable Output

Figure 9-11: Serial “daisy chain” interrupt prioritization.

Parallel Interrupt Prioritization

A parallel priority encoder can also be used to prioritize multiple simulta­ neous interrupt requests. The priority encoder encodes the highest priority active input as a binary value, and that value is used as part of the interrupt vector number. The interrupts could be prioritized using an encoder that is equivalent to a 74x148 style 8:3 line priority encoder.

In most machines, the CPU checks for interrupt requests just after execution of each instruction. When an interrupt is enabled and occurs, the CPU will:

1.Save the PC (program counter) on the stack.

2.Acknowledge the interrupt request and get the vector from interrupt source.


195CHAPTER NINE

Other Interfaces and Bus Cycles

3.Use the vector as an address or as a pointer into the interrupt vector table to fetch the address of the ISR from the vector table.

4.Load the address of ISR into the program counter.

5.CPU executes the ISR until return from interrupt execution at end of ISR.

6.Pop address off stack into program counter.

7.Continue execution where interrupt occurred.

The purpose of the interrupt processing sequence is to allow the processor to temporarily stop an executing program when an external event occurs, call the appropriate interrupt service routine to process the event, and then return to the interrupted program where it left off.

Interrupts provide a very efficient means for the processing of events that occur at unpredictable times with a minimum of delay. This is particularly important when there are a number of things that the processor must handle concurrently. Whole operating systems, usually referred to as real-time operating systems (RTOS), are designed to allow an application programmer to design multiple programs that can run concurrently on a single CPU almost as if they were running on separate processors.


10

CHAPTER TEN

197

Other Useful Stuff

This chapter surveys practical design issues that must be considered in an embedded design. Some of these topics are covered in more detail by the references in Appendix B.

Construction Methods

Embedded controllers can be constructed using any one of several techniques, but the most common method is a printed circuit board (PCB). The PCB is constructed of insulating material, such as epoxy impregnated glass cloth, laminated with a thin sheet of copper. Multiple layers of copper and insulating material can be laminated into a multi-layer PCB. By drilling and plating holes in the material, it is possible to interconnect the layers and provide mounting locations for through-hole components.

In designing the layout, or interconnecting pattern of the PCB, there are many conflicting requirements that must be addressed to make a reliable, costeffective and producible device. For low speed circuits, the parasitic effects can be ignored and are often assumed to be ideal connections. Unfortunately, real circuits are not ideal, and the wires and insulating material have an effect on the circuit, especially for signals with fast signal rise/fall times. The traces, or wires, on the PCB have stray resistance, capacitance, and inductance. At high speeds, these stray effects delay and distort the signals. Special care must be taken when designing a PC board to avoid problems with transmission line effects, noise, and unwanted electromagnetic emissions.


198EMBEDDED CONTROLLER

Hardware Design

Power and Ground Planes

When possible, it is a good idea to use two layers of a four or more layer PCB dedicated to the Vcc and ground signals. These are referred to as power and ground planes. One advantage is that there is a beneficial high frequency parasitic power supply decoupling capacitance, which reduces the power supply noise to the ICs. Power planes also reduce the undesirable emission of electromagnetic radiation that can cause interference, and reduce the circuit’s susceptibility to externally induced noise. The power planes tend to act as a shield to reduce the susceptibility to external noise and radiation of noise from the system.

Ground Problems

While the concept of an ideal circuit ground may seem relatively simple, a great many system problems can be directly traced to ground problems in actual applications. At the least, this can cause undesirable noise or erroneous operation; at the worst, it can result in safety problems, including possibly even death by electrocution. Lest you dismiss the importance of this too quickly, the author has narrowly missed electrocution while testing a device in which the grounding was improperly implemented!

These problems are most often caused by one of the following problems:

Excessive inductance or resistance in the ground circuit, resulting in “ground loops.”

Lack of, or insufficient isolation between, the different grounds in a system: earth, safety, digital and analog grounds.

Non-ideal grounding paths, resulting in the currents flowing in one circuit inducing a voltage in another circuit.

The solutions to these problems vary, depending upon the type of problem, and the frequency range in which they occur. Usually they can be simplified to reducing the currents flowing in common impedances of circuits which need to remain isolated using a single point ground, and the prudent applica­ tion of shields and insulation to prevent unwanted parasitic signal coupling.

199CHAPTER TEN

Other Useful Stuff

Electromagnetic Compatibility

Electromagnetic compatibility (EMC) issues have become much more significant now that there are a large number of electronic devices which unintentionally radiate electromagnetic energy in the same frequency ranges used for commu­ nication, navigation, and instrumentation. Regulatory agencies—such as the Federal Communications Commission (FCC) in the United States, the Depart­ ment of Communications (DOC) in Canada, and similar organizations in Europe—have defined limits to the amount of energy such electronic devices are allowed to emit at various frequencies. Even more stringent requirements are placed on life critical equipment, such as aircraft navigation and life support equipment, because of the sensitive nature of the applications. Among other things, these devices are required to provide a minimum level of immunity to externally induced noise (radiated and conducted susceptibility).

In solving an EMC problem, the first step is to identify the source of the noise, the path to the problem area, and the destination where the problem manifests itself. Once these three characteristics of an EMC problem are identified, the engineer can evaluate the relative merits of eliminating the noise at its source, breaking the path using shielding and similar techniques, and reducing the sensitivity of the affected circuit. There are several useful resources, including publications, seminars, test labs, and consultants who specialize in solving EMC problems. The best solution is usually to begin testing a new design at the earliest possible point in the prototype phase to determine where the potential problem areas are so they can be addressed with the least cost and schedule impact.

Electrostatic Discharge Effects

Electrostatic discharge (ESD) is an important design consideration in embedded applications because of the potential for failure and erroneous operation in the presence of external electric fields. ESD voltages are commonly impressed on embedded interfaces—on the order of tens of thousands of volts—when some­ one walks across a floor in a low humidity environment before touching an electronic device. One of the most common places where this becomes an issue is in the keyboard or user input device, which comes in direct contact with the


200EMBEDDED CONTROLLER

Hardware Design

outside world. This effect can cause immediate damage or upset, or may cause latent failures that show up months after the ESD event. Designers most often use shielding and grounding techniques similar to those used for safety and emission reduction techniques to minimize the effects of ESD. The same resources which are available for EMC problems are also generally of use for ESD problems.

Fault Tolerance

Increasingly, fault tolerance has become a requirement in embedded systems as they find their way into applications where failure is simply unacceptable. Many hardware and software solutions have been developed to address this need.

In order to understand how to deal with these faults, we must first identify and understand the types and nature of each type of fault. Every fault can be categorized as a “hard” or “soft” fault. Hard faults cause an error that does not go away—for example, pushing reset or powering down does not result in recovery from the fault condition. Soft faults are due to transient events or, in some cases, program errors.

Self-test and diagnostic programs may be able to identify and diagnose the failure if it is not too severe. Depending upon what type of fault occurs and which device(s) are affected, it may be possible to design a system to detect the fault, possibly even isolating the location of the fault to some degree. In the event of a soft failure, it may be possible for the designer to make the system recover from the fault automatically.

A built in self test program can be written for an embedded processor that will be able to detect faults in the following types of devices:

Processor (if the fault is not too severe)

Memory

ROM

RAM

E/EEPROM

Peripheral devices

Note that it is difficult, if not impossible, to detect faults in the control circuits or “glue logic” in a system. Other devices, such as memories, lend themselves to diagnostic methods.

201CHAPTER TEN

Other Useful Stuff

The data contents of ROM devices can be tested for errors using one or more of the following techniques:

Parity

Checksum

Cyclic redundancy check (CRC)

RAM memories and the integrity of information stored in RAM by the proces­ sor can be tested for proper operation using one of the following techniques:

Hardware error detection and correction

Data/address pattern tests

Data structure integrity by checking stack limits and address range validity

Additionally, the integrity of the program and proper execution sequence by the CPU can be checked using one or more of the following techniques:

Hardware parity error detection

Duplicate, redundant hardware and cross checking or voting

“Watch dog” timer that operates the CPU chip’s reset line

Diagnostics that run constantly, when the CPU has nothing else to do

Hardware Development Tools

There are two general classes of hardware development tools available to the embedded developer: passive analysis tools which allow looking at the opera­ tion of the system, and active tools which allow the designer to intrude on the operation of the system while it’s running (even making changes to the system’s configuration and software while it is under test). The system under test is usually referred to as the “target” system, and the computer that is used to develop, edit, compile, assemble, and download the code to the target system is called the “host” system.

Passive tools include:

logic probes to look at static logic levels and detect pulses

oscilloscopes to look at signal waveforms

logic analyzers, with processor specific probes

software to assist hardware development, scope loops