The advent of the microprocessor has made it possible for tremendous advances in all areas of rate controlled by a system clock, which generates a square wave signal usually produced by a crystal oscillator. Modern microprocessor-controlled systems can work at clock speeds in excess of 300 MHz. The microprocessor is the device that controls the computer via the address, data, and control buses. Many vehicle systems use microcontrollers and these are discussed later in this section.
The way in which memory actually works was discussed briefly in an earlier section. We will now look at how it is used in a microprocessor-controlled system. Memory is the part of the system that stores both the instructions for the microprocessor (the program) and any data that the microprocessor will need to execute the instructions
It is convenient to think of memory as a series of pigeon-holes, which are each able to store data. Each of the pigeon-holes must have an address, simply to distinguish them from each other and so that the microprocessor will ‘know’ where a particular piece of information is stored. Information stored in memory, whether it is data or part of the program, is usually stored sequentially.
A computer system requires three buses to communicate with or control its operations. The three buses are the data bus, address bus, and control bus. Each one of these has a particular function within the system.
The data bus is used to carry information from one part of the computer to another. It is known as a bi-directional bus as information can be carried in any direction. The data bus is generally 4, 8, 16 or 32 bits wide. It is important to note that only one piece of information at a time may be on the data bus. Typically, it is used to carry data from memory or an input port to the microprocessor, or from the microprocessor to an output port. The address bus must first address the data that is accessed.
Fetch–execute a sequence
A microprocessor operates at a very high speed by the system clock. Broadly speaking, the microprocessor has a simple task. It has to fetch an instruction from memory, decode the instruction and then carry out or execute the instruction. This cycle, which is carried out relentlessly (even if the instruction is to do nothing), is known as the fetch–execute sequence. Earlier in this section, it was mentioned that most instructions are stored in consecutive memory locations such that the microprocessor, when carrying out the fetch–execute cycle, is accessing one instruction after another from sequential memory locations.
A typical microprocessor
The temporary data register (TDR) is used to hold data, which are to be operated on by the ALU, its output is therefore to an input of the ALU. The ALU carries out additions and logic operations on data held in the TDR and the accumulator. The accumulator (AC) is a register, which is accessible to the programmer and is used to keep such data as a running total.
Testing microcontroller systems
If a microcontroller system is to be constructed with the program (set of instructions) permanently held in ROM, considerable testing of the program is required. This is because, once the microcontroller goes into production, tens if not hundreds of thousands of units will be made. A hundred thousand microcontrollers with a hard-wired bug in the program would be a very expensive error.
The most useful aid for testing and debugging is an in-circuit emulator. The emulator is fitted in the circuit in place of the microcontroller and is, in turn, connected to a general-purpose computer. The microcontroller program can then be tested in conjunction with the rest of the hardware with which it is designed to work. The PC controls the system and allows different procedures to be tested. Changes to the program can easily be made at this stage of development.