Memory issues

Introduction

All practical microcontroller-based systems require some form of non-volatile code memory (to store the program code) and some form of volatile memory (to store data and the stack).

In many cases, it is possible to create useful applications without adding external memory devices. The first pattern in this chapter (ON CHIP MEMOR Y [page 82]) dis- cusses how to do this by making effective use of the various memory areas available in members of the 8051 family.

In some applications, it is necessary to add external memory: the remaining patterns in this chapter (OFF CHIP DA T A MEMOR Y [page 94] and OFF CHIP CODE MEMOR Y [page 100]) consider how best to add additional memory to your 8051-based application.

Please note that the material in this chapter is concerned primarily with devices using the Standard 8051 memory architecture. Some of the more recent 8051 devices, such as the Dallas 80C390, Analog Devices ADµC812 and Philips 80C51MX, provide support for much larger amounts of external memory than was possible in the origi- nal 8051 device: we briefly consider such extended memory devices in this chapter, but – as each manufacturer has an individual solution – we do not attempt to cover them in detail.

 

The 8051 microcontroller family:EXTENDED 8051

EXTENDED 8051

Context

You are developing a microcontroller-based embedded application and have some flexibility in the choice of hardware platform to be used.

Problem

Should you base your application on an Extended 8051-family microcontroller?

Background

As we have seen in connection with ST ANDARD 8051 [page 30] and SMALL 8051 [page 41], this long-lived microcontroller family continues to thrive partly because it offers a huge variety of ‘standard devices’ (covering the territory of traditional 8-bit microcontrollers) and a range of ‘small devices’ (overlapping with the range of 4-bit controllers, and challenging devices such as the small PIC range).

Both the Standard and Small 8051s are aimed, largely, at low-cost, low-performance application areas where limited memory is required and the three most important con- siderations are ‘cost, cost and cost’. Of course, not all projects take this form.

To develop applications requiring specialized hardware or larger amounts of memory, we can opt to switch to a 16-bit (or 32-bit) microcontroller environment. However, such a move can require a major investment in staff, staff training and development tools. An alternative is to use one of the Extended 8051 devices intro- duced in recent years by a range of manufacturers. Such devices preserve the investment in the 8051 range and, at the same time, open up new application areas to this microcontroller family.

In general, the extended 8051s offer the widest range of features available in 8051 devices. For example, the Infineon C505C and C515C include a useful range of on- chip hardware components (including in this case support for the CAN3 bus) that have led to these devices being used in the vast automotive market.

The C505C and C515C both retain the memory limitations of the Standard 8051. By contrast, other Extended 8051s, such as the Dallas 80C390 (Figure 3.6) and the Analog Devices ADµC812 (Figure 3.7) can access much larger amounts of memory, in a linear address space.

Compared to many 16-bit microcontrollers, the Extended 8051s are, usually, com- paratively inexpensive: however, they are inevitably more expensive than either the Standard 8051 or Small 8051 alternatives.

The 8051 microcontroller family-0081

Solution

Should you use an Extended 8051 microcontroller in your application?

Performance issues

The Extended 8051s have good levels of performance. For example, as we have previ- ously noted, the performance of the Dallas 80C390 is up to 10x higher than the original 8051. In addition, the presence of hardware maths units in several Extended 8051s can significantly improve the speed of maths-intensive programs. Nonetheless, the Dallas 89C420 (a Standard 8051) is more powerful than any of the current Extended 8051 devices.

Memory issues

Some of the Extended 8051s support the use of large amounts of external memory. Of particular note here is the Dallas 80C390, the Analog Devices 80µC812 and the Philips 80C51MX. (See Chapter 6 for details.)

Availability of on-chip hardware components

Some of the on-chip hardware components available on Extended 8051s are as follows:

● Several Extended 8051s have on-chip analog-to-digital converters (typically up to eight channels, 10-bit resolution). We discuss the use of such converters in Chapter 32.

● Several Extended 8051s have hardware support for mathematical operations, ensur- ing that (for example) floating-point maths operations are carried out comparatively rapidly. See, for example, the data sheets for the Infineon C517, C537 and C509 and the Dallas 80C390 (included on the CD).

● Some Extended 8051s have support for the Inter-Integrated Circuit (I2C) bus. We discuss this important serial protocol in Chapter 23.

● Some Extended 8051s have on-chip support for the SPI bus. We discuss this impor- tant serial bus protocol in Chapter 24.

● Some Extended 8051s have support for the Controller Area Network (CAN) bus. We discuss the CAN bus in Chapter 28.

● Some Extended 8051s have on-chip digital-to-analog (D-A) converters. We discuss such converters in Chapter 34.

Pin count

Many Extended 8051s have a very large number of available port pins. For example, the C509 has nine 8-bit ports. Even where external memory is used, six complete 8- bit ports are available.

Power consumption

See ST ANDARD 8051 [page 30] for details of the three main operating modes of the 8051 family. Inevitably, given the large number of on-chip hardware components, the basic current requirements of the Extended 8051s is larger than that of the Standard 8051. In addition, if external memory is used, the current requirements are best deter- mined for the prototype circuit.

As a basic guide, typical current requirements for the various modes of some repre- sentative Extended 8051s are shown in Table 3.3.

The 8051 microcontroller family-0082

Hardware resource implications

The Extended 8051s provide a range of different hardware resources depending on the device chosen:

● In all cases, the core is 8051 compatible.

● In most cases, many additional peripheral devices are included on chip. In most cases, high CPU performance is available.

● In some cases large amounts of external memory may be directly accessed.

Reliability and safety implications

There are no available figures to suggest that the Extended 8051 is any more (or less) reliable than any other microcontroller family. However, it should be noted that many Extended 8051s require the use of external memory: this may reduce the over- all system reliability compared to an otherwise identical system constructed using only internal memory, for reasons discussed in ST ANDARD 8051 [page 30].

Portability

Because of the huge range of different 8051 devices available, designs based on the Extended 8051 are inherently portable. However, as already discussed, the various ‘extended’ 8051s share only the common core and are not pin compatible (by any means). This means that core routines (like schedulers, for example) may be easily ported, but other components will need to be adapted to suit a particular device.

Overall strengths and weaknesses

To summarize, the Extended 8051 has the following strengths and weaknesses:It is based on the 8051 architecture and thus has many of the strengths of the Standard 8051.

It has – in most cases – a large number of external port pins available.

It has – in most cases – a number of additional on-chip hardware compo- nents available.

It has – in many cases – an ability to access large amounts of ROM and RAM memory.

Still, essentially, an 8-bit device: for higher levels of performance, a 32-bit device may be a better option.

Related patterns and alternative solutions We consider three alternative solutions in this section.
Use two (or more) Standard 8051s

Suppose we require a microcontroller with the following specification:

● 60+ port pins

● Six timers

● Two USARTS

● 128 kbytes of ROM

● 512 bytes of RAM

● A cost of around $2.00 (US)

We can meet many of these requirements with an EXTENDED 8051 : however, this will typically cost five to ten times the $2.00 price we require. By contrast, the ‘micro- controller’ in Figure 3.8 matches these requirements very closely.

Figure 3.8 shows two standard 8051 microcontrollers linked together by means of a single port pin: as we demonstrate in SCI SCHEDULER ( TICK ) [page 554], linking the two processors can be done with a minimal software and hardware load. The result is a flexible environment with 62 free port pins, five free timers, two USARTs and so on. Note that further microcontrollers may be added without difficulty and the commu- nication over a single wire (plus ground) will ensure that the tasks on all processors are perfectly synchronized.

The 8051 microcontroller family-0083

Build your own 8051 device

If none of the available Extended 8051 devices matches your requirements, it is now possible to create your own. Specifically, Xilinx Foundation4 provides a comprehen- sive set of tools for the programming of field-programmable gate arrays (FPGAs) or application-specific ICs (ASICs). Compatible with these tools are a small range of 8051 ‘cores’ which can be purchased from Dolphin Integration.5 These cores are not cheap (around $16,000), but they are efficient (one oscillation per instruction) and the use of such techniques allows you to add hardware components to your specialized microcontroller, to meet your particular requirements.

The creation and use of such 8051 devices is beyond the scope of the present edi- tion of this book, but the WWW sites for the companies concerned will provide further information. To make use of these techniques, you will need some familiarity with VHDL.6 Yalamanchili (2001) provides a good starting point.

4. VHDL stands for VHSIC Hardware Description Language. The acronym VHSIC, in turn, stands for Very High-Speed Integrated Circuit (programme). These terms originated in a (US) Department of Defense programme which had the goal of developing a new generation of high-speed ICs. The first version of VHDL was released in 1985 and the most recent version is an IEEE standard (1076–1993).

It is worth noting that the availability of the 8051 core in this form is another, very useful consequence of the fact that this microcontroller architecture is very mature.

Use an XA-family device

The final alternative to the Extended 8051 which we will consider here is the so- called ‘8051XA’ family, from Philips.

When developing the 251 family (discussed in ST ANDARD 8051 [page 30]), Intel chose to produce a range of devices that was, to a large extent, both (executable) code and hardware compatible with the original 8051. When developing the XA family, Philips opted to follow a different route. The aim was to develop a new, 16-bit ‘8051’ device which preserved source code compatibility with the 8051, but little else.

The XA family has features including dual 16 Mbyte address spaces (code and data) and fast (hardware) multiply and divide facilities. It also includes dual USARTs, an on- chip ADC and hardware support for the I2C bus.

It should be noted that very similar facilities are provided by recent Extended 8051 devices and that – unlike the Extended 8051 – the XA family requires that the devel- opers purchase different software tools (compilers etc). In addition, the XA family has not proved particularly popular, with the result that tools, and development boards, are not very widely available.

Please refer to the Philips WWW site7 for further details of the XA family.

Example: Using the Extended 8051

We give many examples of the use of Extended 8051 devices throughout this book.

Further reading

A collection of data books for a range of Extended 8051 devices is included on the CD-ROM.

 

The 8051 microcontroller family

Introduction

Early in the life-cycle of most embedded projects, an initial choice of microcontroller must be made. While it may become necessary to change the microcontroller as the project develops, the particular hardware platform that is used will have a substantial impact on many later software and hardware design decisions and development costs can be substantially reduced if subsequent changes can be avoided.

In this chapter, three patterns are presented to support this selection process:

Designing embedded systems-0073

Note that using any processor family requires a considerable investment in hard- ware, software and staff training: few firms can afford to select devices on a per-project basis: instead, they tend to specialize in a single family or a small number of families. As we will see, the huge – and growing – range of 8051 devices available can make it an excellent choice for a wide range of projects and, as a result, can frequently justify this investment.

STANDARD 8051

Context

You are developing a microcontroller-based embedded application and have some flexibility in the choice of hardware platform to be used.

Problem

Should you base your application on a standard 8051-family microcontroller?

Background

Taken as a whole, the 8051 family has what is, in the semiconductor world, a very long history. The underlying architecture is derived from that of the Intel 8048 micro- controller (introduced in 1976): the first 8051 was introduced in 1980 (Intel, 1985).

The original 8051 architecture had the following features:

● Up to 12 MHz operating frequency.

● Thirty-two digital input / output pins (arranged as four 8-bit ports).

● Internal data (RAM) memory – 128 bytes.

● Three versions with different program memory options:

– No program memory: all programs needed to be stored in external memory (8031)

– 4K × 8 bits internal mask-programmed ROM (8051)

– 4K × 8 bits UV-eraseable EPROM (8751)

● Two 16-bit timer / counters (Timer 0 and Timer 1).

● Five interrupt sources were provided (two external) with two priority levels.

● One programmable, full-duplex, serial port.

The external interface to the 8051 is illustrated in Figure 3.1.

Shortly after the launch of the 8051, the 8052 was launched (again by Intel). The 8052 differed in several important respects from the earlier device. The 8052 had the following features:

● Internal data (RAM) memory was increased to 256 bytes.

● Two 8052 versions were available with different program memory options:

– No program memory: all programs needed to be stored in external memory (8032)

– 8K × 8 bits internal mask-programmed ROM (8052)

● Three 16-bit timer / counters (Timer 0, Timer 1 and Timer 2).

● Six interrupt sources were provided (two external) with two priority levels.

The 8051 microcontroller family-0074

[Note: that many of the digital I/O pins have alternative functions: for example, in applications involving a UART-based serial interface, Pins 3.0 and 3.1 are used (see Chapter 18). Note also that the alternative functions on pins 1.0 and 1.1 are only provided on 8052- based derivatives.]

The 8052 added useful features to the basic architecture, particularly the additional RAM and ‘Timer 2’. It was also ‘upwardly compatible’ with the 8051: that is, it was pin, and code compatible with the 8051. Because of this, in almost all cases, modern ‘standard’ 8051 devices are based on the 8052 family. Within this text, we will con- sider ‘Standard 8051’ devices to be those which are pin and code compatible with either the 8051 or (more commonly) the 8052 device.

The popular Atmel 89S53 is a representative example of a modern Standard 8051. Listed here is a summary of the main features of the AT89S53:

● Fully static operation: 0–24 MHz operating frequency.

● Thirty-two input / output lines (arranged as four 8-bit ports).

● Internal data (RAM) memory – 256 bytes.

● 12 Kbytes of ‘in circuit programmable’ ROM.

● Three 16-bit timers / counters (Timer 2 with up/down counter feature).

● Nine interrupts (two external) with two priority levels.

● Programmable watchdog timer (see Chapter 12).

● SPI interface (see Chapter 24).

● Low-power idle and power-down modes.

● 4V to 6V operating range.

clip_image005Modern Standard 8051 devices like the AT89S53 are now generally packaged in 40- pin DIP, 44-pin PLCC or 44-pin MQFP cases. Examples of each type of package are shown in Figure 3.2.

The 8051 microcontroller family-0075

What’s in a name?

It should be noted that the naming of various members of the ‘8051’ family is a source of considerable confusion to new developers. For example, the 8031, 8751, 8052, 8032, C505c, C515, C509, 80C517, 83C452, ADµC812, and the 80C390 are all members of the 8051 family. The names of the devices provide little or no indica- tion of the family connections.

Originally, there were some basic conventions used to identify the features of differ- ent variants of a particular 8051 device. For example, the standard 8051 had mask ROM, the 8031 had no ROM and the 8751 had UV-erasable ROM memory. This basic convention is now rarely observed. In the case of the Infineon C501, for example, dif- ferent suffixes are used to distinguish different C501 versions: C501-1R, C501-1E, and so on.

Solution

The aim of this pattern is to help you decide whether you should use a Standard 8051 in your application. When making such a decision, some or all of the following ques- tions need to be addressed:

1 Is the microcontroller powerful enough to perform the required tasks?

2 Does the microcontroller have sufficient memory ‘on chip’ to store the required code and data? If not, then does the microcontroller allow the use of appropriate external memory?

3 Does the microcontroller have appropriate on-chip hardware components (for example, CAN interface, PWM interface) to support the required tasks?

4 Does the microcontroller have sufficient port pins (or a suitable serial interface) to allow any required external components (such as switches, keypads, LCD displays) to be connected?

5 Is the power consumption of the chosen microcontroller appropriate (a particular concern with battery powered applications)?

We will consider each of these points in turn here.

Performance issues

One of the first question to be asked when considering a microcontroller for a project is whether it has the required level of performance. There are various ways in which such performance may be described: one measure is the number of machine instruc- tions that may be executed in one second, usually expressed in MIPS (million instructions per second).

For example, in an original Intel 8051 microcontroller (and most current members of the 8051 family), a minimum of 12 oscillator cycles are required to execute a machine instruction. As a result, at best, a 12 MHz 8051 has a performance of approximately 1 MIP.

A simple way of improving this performance is to increase the clock frequency. More modern (Standard) 8051 devices allow the use of clock speeds well beyond the 12 MHz limit of the original devices. For example, the Infineon C501 allows clock speeds up to 40 MHz: this raises the performance to around 3 MIPS.

Another way of improving the performance is to make internal changes to the microcontroller so that fewer oscillator cycles are required to execute each machine instruction. The Dallas ‘high speed microcontroller’ devices (87C520 and similar) use this approach, so that only four oscillator cycles are required to execute a machine instruction. These Dallas devices also allow faster clock rates: typically up to 33 MHz. Combined, these changes give a total performance of around 6 MIPS. Similar changes are made in members of the Winbond family of Standard 8051 devices (see the Winbond W77E58, for example) resulting in performance figures of up to 10 MIPS.

Clearly, for maximum performance, we would like to execute instructions at a rate of one machine instruction per oscillator cycle. The Dallas ‘ultra high speed’ 89C420 is the first 8051 device to achieve this: as a result, it runs at 12 times the speed of the original 8051. In addition, the 89C420 can operate at up to 50 MHz, increasing over- all performance to around 40–50 MIPS.

To put these figures in context, the popular Infineon C167 family of (16-bit) microcon- trollers has a modern architecture and performance level of around 10 MIPS. Clearly, therefore, in microcontroller terms, the performance of many 8051 devices is respectable.

Memory issues

The second question you need to ask is whether the microcontroller you are consider- ing supports the memory that your application requires.

The 8051 microcontroller family-0076

The first thing to note is that, for the Standard 8051, a maximum program size of 64 kbytes is directly supported. While it is possible to use larger programs by ‘bank switching’ the memory (a techniques considered in OFF CHIP CODE MEMOR Y [page 100]) this technique is complex, less efficient than a linear address space, and can be error prone. Similarly, the memory available for data is restricted to 64 kbytes. In situ- ations where code or data memory in excess of 64 kbytes is required, use of an EXTENDED 8051 [page 46] is often a better alternative.

The second thing to note is that Figure 3.3 shows the total memory (both internal and external) available on all Standard 8051 devices. Where possible, it is better to use a device with all the required memory on the chip, since this can improve reliability, reduce costs, reduce the application size and reduce power consumption. As discussed in ‘Background’, the original 8051 family had up to 128 bytes of RAM and 4 kbytes of ROM available, from data and code (respectively). More modern Standard 8051s rarely provide more than around 1 kbyte of RAM (usually 256 bytes), but may provide up to 64 kbytes of flash, OTP or mask ROM (see Chapter 6 for further details).

Availability of on-chip hardware components

One of the main reasons for choosing to use a microcontroller is that it integrates most or all of the hardware features you require in your application on a single chip. The 8051 family is particularly impressive in this area. There are numerous variants available which between them meet the needs of a huge number of projects, without having to resort to using large numbers of external components.

Some of the on-chip hardware components available on Standard 8051s are as follows:

● All Standard 8051s have at least one serial port available, supporting RS-232 serial protocols. This makes it easy, for example, to download data to a desktop PC. We discuss the linking of embedded and desktop systems in Chapter 18.

● All Standard 8051s have two or three timers.

● Many Standard 8051s have on-chip ‘watchdog timers’. Use of such components is discussed in Chapter 12.

● Some Standard 8051s have on-chip support for the SPI bus. We discuss this impor- tant serial bus protocol in Chapter 23.

● Some Standard 8051s have on-chip support for the I2C bus. We discuss this important serial bus protocol in Chapter 24.

Note that many more features are available in the EXTENDED 8051 [page 46] devices.

Despite this variation, the core architecture remains the same and software for one variant can generally be used without major alteration on another.

Pin count

All Standard 8051s have four 8-bit ports available, allowing a number of external devices to be added.

Please note:

● Port 0, Port 2 and part of Port 3 are required to support external memory (if used).

Use of external memory therefore has a dramatic impact on the number of spare port pins (see Chapter 6 for details).

● The availability of new ‘serial bus’ standards, like I2C and SPI (see Chapter 23 and Chapter 24), means that many peripherals may be connected to a device, by shar- ing a bus requiring a small number of port pins.

Power consumption

All modern implementations of Standard 8051s have at least three operating modes:

● Normal mode

● Idle mode

● Power-down mode

The ‘idle’ and ‘power-down’ modes are intended to be used to save power at times when no processing is required. Typical current requirements for the various modes are shown in Table 3.1.

The 8051 microcontroller family-0077

The Infineon C501 is an example of a Standard 8051 device, which offers power- down modes identical to those available in the 8052 and many other modern devices. The following description of the C501 idle modes, adapted from the user manual, describes these modes in detail. Please note that this description applies equally well to most Standard 8051s.

Idle mode

In the idle mode the oscillator of the C501 continues to run, but the CPU is gated off from the clock signal. However, the interrupt system, the serial port and all timers are connected to the clock. The CPU status is preserved in its entirety.

The reduction of power consumption which can be achieved by this feature depends on the number of peripherals running. If all timers are stopped and the serial interfaces are not running, the maximum power reduction can be achieved: the devel- oper has to determine which peripheral must continue to run and which may be stopped.

The idle mode is entered by setting the flag bit IDLE (PCON.0). Because PCON is not a bit-addressable register, the easiest way to set the IDLE bit is with the following ‘C’ statement:

PCON |= 0x01; // Enter idle mode

The instruction that sets bit IDLE is the last instruction executed before going into idle mode.

There are two ways to terminate idle mode:

● Activate any enabled interrupt. This interrupt will be serviced and the program will continue by executing the instruction following the instruction that sets the IDLE bit.

● Perform a hardware reset.

Power-down mode

In the power-down mode, the on-chip oscillator is stopped. Therefore all functions are stopped; only the contents of the on-chip RAM are maintained.

The power-down mode is entered by setting the flag bit PDE (PCON.1). This is most easily done in ‘C’ as follows:

PCON |= 0x02; // Enter power down mode

The instruction that sets bit PDE is the last instruction executed before going into power down mode. The only exit from power-down mode is a hardware reset.

Hardware resource implications

To summarize, the Standard 8051 provides the following hardware resources:

● A CPU performance of between 1 MIPS and 50 MIPS (approximately).

● Available on-chip memory of up to 64 kbytes for code and (typically) at least 256 bytes for data.

● One ‘RS-232’ serial port.

● Two or three hardware timers.

● Current consumption of around 20 mA in normal operating mode, 5 mA in idle mode, and 50 µA in power-down mode.

Reliability and safety implications

There are no available figures to suggest that the Standard 8051 is any more (or less) reliable than any other microcontroller family. Nonetheless, there are differences

between the facilities provided by the various 8051 family members and the choice of an inappropriate microcontroller can have a detrimental impact on the safety and / or reliability of your application.

These differences arise simply due to the availability of on-chip resources: as we have mentioned, these include – for example – different amounts of memory (RAM and ROM), serial interfaces (SPI and I2C) and analog-to-digital converters. Where pos- sible, the use of on-chip components generally increases application reliability, for the following reasons:

● With external components, each of the soldered joints has a risk of failure, particu- larly in the presence of vibration and / or high humidity: reducing the number of joints reduces this risk.

● External wires act as miniature aerials and increase vulnerability to electromagnetic interference (EMI): as a consequence reduction in external wiring tends to make the application more robust in the presence EMI.

● Without external components, the complexity of the hardware design is reduced, which means there are fewer opportunities for wiring and / or hardware design errors,

As (in almost all cases) the ‘on-chip’ solution will also be both cheaper to produce and physically smaller, the message is clear: you should generally use a microcon- troller with all the on-chip resources you require if at all possible. Note, however, that use of less common on-chip resources will make your design less portable (see next section).

Portability

Because of the huge range of different 8051 devices available, design based on the Standard 8051 are inherently portable. However, if you assume the availability of non-standard components (extra RAM, extra serial interfaces etc.), your design will not be as portable.

Overall strengths and weaknesses

To summarize, the Standard 8051 has the following strengths and weaknesses:

It is a flexible, general-purpose microcontroller suitable for use in many projects. It is a low-cost device.

It has an architecture with which many developers are familiar. It is supported by many development tools.

The family as a whole is available in more than 300 different forms.

It is available from a very wide range of different manufacturers: if one com- pany fails, there will be an alternative source.

Its CPU performance (in some versions) is equal to or greater than many 16-bit devices.

It has limited memory available (compared with 16-bit or 32-bit microcon- trollers).

Its memory architecture is comparatively complex.

Related patterns and alternative solutions

In this section, we consider some alternatives to the Standard 8051 microcontroller.

Smaller alternatives

If your application does not require external memory and you do not require more than (approximately) 15 port pins for input and output, you may find that the Small 8051s are a good option: see SMALL 8051 [page 41].

Extended 8051 alternatives

The Extended 8051s can generally do everything that the Standard 8051 can do. In addition, they usually have a larger number of available port pins and a wider range of on-chip hardware components such as digital-to-analog converters, CAN interfaces, SPI interfaces, I2C interfaces and so on. The Extended 8051s also, in some cases, provide support for large amounts of external memory: up to 16 Mbytes in some cases.

We discuss such devices in EXTENDED 8051 [page 46].

The Intel 80251 family

The Intel MCS-251 is both software and hardware compatible with the Standard 8051 family. This means that, in most cases, you can load your existing code into a 251 and place this (40-pin or 44-pin) device into your existing 8051-based circuit board.

It is claimed that performance can be improved by a factor of 5–15 times by this approach (compared with the original 1-MIP 8051) and that further improve- ments are possible by recompiling and / or rewriting code to take advantage of the new architecture.

To summarize, the key features of the 251 are:

● Software and hardware compatibility with the Standard 8051.

● 5–15 × the performance of the original 8051.

● Large (up to 16 Mbyte) linear address space.

● Additional on-chip RAM compared with the Standard 8051 (up to 1 kbyte).

● Other additional components, such as a watchdog timer and a PWM unit.

● Two serial ports in some versions.

Overall, the main advantage of the 251 family is that can provide a more powerful, drop-in replacement for the original 8051 and that it may be used without purchasing additional tools (such as compilers). However, the 251 family has not proved nearly as popular as the 8051 and it offers little that Standard and Extended 8051 devices cannot now provide.

If you wish to find out more about the 251 family, then Ayala (2000) may be of interest.

Example: Using the Standard 8051

We give many examples of the use of Standard 8051 devices throughout this book.

Further reading

A collection of data books for a range of Standard 8051 devices is included on the CD-ROM.

 

CERAMIC RESONATOR

CERAMIC RESONATOR
Context

● You are developing an embedded application using one or more members of the 8051 family of microcontrollers.

● You are designing an appropriate hardware foundation for your application.

Problem

When and how should you use a ceramic resonator with members of the 8051–family microcontrollers?

Background

A ceramic resonator is, like a quartz oscillator, based on a piezoelectric material. In this case, the material is (as the name suggests) a form of piezoelectric ceramic.

See CR YST AL OSCILLA TOR [page 54] for additional background material.

Solution

The aim of this pattern is to help you decide if you should use a ceramic resonator with your 8051 microcontroller and, if so, how to connect such a device. This section directly addresses these issues.

Stability issues

As discussed in CR YST AL OSCILLA TOR [page 54], a key factor in selecting an oscillator for your system is the issue of oscillator stability. Unlike crystal oscillators, which usu- ally have stability measured expressed in parts per million, ceramic resonator stability is usually stated in percentage terms. A figure of 1% stability is common. There are 1,440 minutes in a day and a clock based on a 1% ceramic resonator could expect to gain (or lose) around 14 minutes every day. Clearly, such devices are not suitable for operations requiring accurate timing over a long period. Note, however, that if we require the resonator to form the basis of a 30-second delay, the likely gain or loss is

0.3 seconds: this may not be a problem.

Cost issues

Ceramic resonators cost half the price of a crystal oscillator.

External capacitors

Most ceramic resonators include internal capacitors. They may therefore be directly accessed to the microcontroller without the need for external capacitors. This makes them easy to use and can further reduce costs and the required board size.

Hardware resource implications

Use of a ceramic resonator has no direct implications for the memory requirements in your application.

Note also that the performance of your application is directly related to the res- onator frequency. If your application cannot perform sufficiently rapidly, consider increasing this frequency. Alternatively, consider using a more modern 8051 design, from Dallas or Infineon (for example) that requires fewer clock cycles to carry out each instruction.

Reliability and safety implications

See CR YST AL OSCILLA TOR [page 54] for a general discussion of reliability and safety issues associated with oscillators.

Overall, the ceramic resonator is the most physically robust form of oscillator we consider.

Portability

These techniques can be, and are, used with a wide range of microcontrollers and microprocessors.

Please note that ceramic resonators should not, generally, be used as plug-in replacements for crystal oscillators: different capacitors (if any) are required for each solution.

Overall strengths and weaknesses

Cheaper than crystal oscillators.

Physically robust: less easily damage by physical vibration (or dropped equipment etc.) than crystal oscillator.

Many resonators contain in-built capacitors and can be used without any external components.

Small size. About half the size of crystal oscillator.

Comparatively low stability: not general appropriate for use where accurate timing (over an extended period) is required. Typically ±5000 ppm = ±2500 min per year (up to ~50 minutes / week).

Related patterns and alternative solutions

CR YST AL OSCILLA TOR [page 54] describes the main alternative.

Example: Connecting a ceramic resonator to an 8051 microcontroller Many simple consumer applications, where accurate timing is not required and cost is an issue, make use of ceramic resonators. In most cases, resonators with internal capacitors are used: the same resonator can be used with any member of the 8051 family (Figure 4.7).

Oscillator hardware-0090

capacitors have two pins (like crystals); those with capacitors have a third pin. Where there are three pins, the middle pin should

 

Reset hardware

Introduction

The process of starting any microcontroller is a non-trivial one. The underlying hard- ware is complex and a small, manufacturer-defined ‘reset routine’ must be run to place this hardware into an appropriate state before it can begin executing the user program. Running this reset routine takes time and requires that the microcontroller’s oscillator is operating.

Where your system is supplied by a robust power supply, which rapidly reaches its specified output voltage when switched on, rapidly decreases to 0V when switched off, and – while switched on – cannot ‘brown out’ (drop in voltage), then you can safely use low-cost reset hardware based on a capacitor and a resistor: this form of reset circuit is addressed in RC RESET [page 68].

Where your power supply is less than perfect, and / or your application is safety related, the simple RC solution will not be suitable. ROBUST RESET [page 77] discusses a more reliable alternative.

 

CRYSTAL OSCILLATOR

CRYSTAL OSCILLATOR
Context

● You are developing an embedded application using one or more members of the 8051 family of microcontrollers.

● You are designing an appropriate hardware foundation for your application.

Problem

When and how should you use a quartz crystal to create an oscillator for use with members of the 8051 family of microcontrollers?

Background

Quartz is a common mineral and is the main component of most sand grains. It has the useful quality that it is piezoelectric in nature, which means that if we apply pres- sure to a piece of quartz, it will generate an electric current at a particular frequency. In some materials, the converse is also true: application of an electric field will cause a mechanical deflection in the material.

We can use this behaviour as the basis of a useful oscillator by using an electric field (generated by plating some contacts on the surface of the mineral and applying a cur- rent) to set up mechanical oscillations in the crystal which are, in turn, converted into measurable voltage fluctuations at the surface of the crystal. We can precisely control the frequency of these fluctuations by cutting the quartz to a particular size and shape: a par- ticular form of cut, known as the ‘AT’ cut, is reasonably inexpensive to produce and can create high-frequency crystals with good temperature stability at reasonable cost.

To create a complete oscillator, some further components are required. Figure 4.1 shows how crystals may be used to generate a popular form of oscillator circuit known as a Pierce oscillator.

A variant of the Pierce oscillator is common in the 8051 family. To create such an oscillator, most of the components are included on the microcontroller itself: these components are, together, sometimes referred to as the oscillator inverter. The user of this device must generally only supply the crystal and two small capacitors to com- plete the oscillator implementation. We discuss this further in the solution section of this pattern.

Note that, in some circumstances, it may be preferable to use a complete, self- contained external crystal oscillator module (based on a circuit like that illustrated in Figure 4.1) and use this to drive the microcontroller. We discuss this possibility in ‘Reliability and safety implications’.

Oscillator hardware-0084

The link between oscillator frequency and machine cycle period When selecting an appropriate oscillator for an 8051–family device, the choice of oscillator frequency is really incidental to our real concern: the machine cycle period. That is, we are concerned with the speed at which instructions will execute.

As we discussed in Chapter 3, the various members of the 8051 family have different relationships between the oscillator cycle period and the machine cycle period. For example, in the original members of the 8051 family, the machine cycle takes 12 oscil- lator periods. In later family members, such as the Infineon C515C, a machine cycle takes six oscillator periods; in more recent devices such as the Dallas 89C420, only one oscillator period is required per machine cycle. As a result, the later members of the family operating at the same clock frequency execute instructions much more rapidly.

In general, the improved performance of modern implementations of the 8051 is ‘A Good Thing’: however, in situations where timing is critical, care must be taken to ensure that any timer-related calculations are implemented correctly on a particular device: see HARDW ARE DELA Y [page 194], and CO OPERA TIVE SCHEDULER [page 255] for further details.

Why you should keep the clock frequency as low as possible As a general rule, the speed at which your application runs is directly determined by the oscillator frequency: in most cases, if you double the oscillator frequency, the application will run twice as fast.

In our experience, many developers select an oscillator / resonator frequency that is at or near the maximum value supported by a particular device. For example, the Infineon C505/505C will operate with crystal frequency of 2–20 MHz and many people automatically choose values at or near the top of this range, in order to gain maximum performance.

This can be a mistake, for the following reasons:

● Many applications do not require the levels of performance that a modern 8051 device can provide.

● In most modern (CMOS-based) 8051s, there is an almost linear relationship between the oscillator frequency and the power supply current. As a result, by using the lowest frequency necessary it is possible to reduce the power require- ment: this can be useful in many applications.

● When accessing low-speed peripherals (such as slow memory or LCD displays), programming and hardware design can be greatly simplified – and the cost of peripheral components, such as memory latches, can be reduced – if the chip is operating more slowly.

● The electromagnetic interference (EMI) generated by a circuit increases with clock frequency.

In general, you should operate at the lowest possible oscillator frequency compatible with the performance needs of your application.

0 MHz operating frequencies?

Several modern 8051 family members can be operated at speeds down to 0 Hz: for example, the Atmel 89C52 device has an operating range from 0 to 24 MHz. This facility can allow significant power savings, through operating the system at very low frequencies (in kiloHertz or even Hertz, rather than in megaHertz). We make use of these features in ONE YEAR SCHEDULER [page 919].

In some applications, even 0 Hz can be useful. At first glance, this may not make sense: at 0 Hz, the device is not operating and no code will execute. However, in devices designed for low-frequency operation, the system state will be maintained even if the clock frequency is reduced. This means that the clock frequency can be reduced to 0 to save power. In addition it means that, if the clock temporarily fails (for what- ever reason) and then recovers, your system has a better chance of recovering, too.

Solution

The aim of this pattern is to help you decide if you should use a quartz crystal with your 8051 microcontroller and, if so, how to connect such a device. This section directly addresses these issues.

Stability issues

A key factor in selecting an oscillator for your system is the issue of oscillator stability. In most cases, oscillator stability is expressed in figures such as ‘±20 ppm’: ‘20 parts per million’.

To see what this means in practice, consider that there are approximately 32 mil- lion seconds in a year.8 In every million seconds, your crystal may gain (or lose) 20 seconds. Over the year, a clock based on a 20 ppm crystal may therefore gain (or lose) about 32 × 20 seconds, or around ten minutes.

Standard quartz crystals are typically rated from ±10 to ±100 ppm and so may gain (or lose) from around 5 to 50 minutes per year. Note that this figure also applies to external oscillator modules. If you require greater accuracy than this, refer to ‘Related patterns’.

Cost issues

Crystals cost around twice the price of a ceramic resonator, with prices linked to the crystal stability.

How to connect a crystal to a microcontroller

Basic connections for a crystal oscillator are given in Figure 4.2.

The values of the capacitors will vary, depending on the microcontroller and the crystal frequency. We will provide examples of recommended capacitor values for a range of different 8051 devices in the examples that follow; please refer to the data sheet describing your chosen microcontroller for further information. In the absence of specific information, a capacitor value of 30 pF will perform well in most circumstances.

Hardware resource implications

Use of a crystal oscillator has no direct implications for the CPU or memory require- ments in your application in most cases. However, if you choose to make temperature measurements in order to increase the stability of your oscillator (see ‘Reliability and safety issues’), this will have a CPU and memory overhead.

Note also that, as discussed in the background section, the performance of your application is directly related to the crystal frequency. If your application cannot per- form sufficiently rapidly, consider increasing the oscillator frequency. Alternatively, consider using a more modern 8051 design, from Dallas or Infineon (for example) that uses fewer clock cycles to carry out each instruction.

Oscillator hardware-0085

1. (365 days) × (24 hours) × (60 minutes) × (60 seconds) = 31,536,000 seconds.

Reliability and safety implications

We consider some reliability and safety issues related to the use of crystal oscillators in this section.

System heartbeat

The oscillator forms the ‘heartbeat’ of any digital computer. If this heartbeat stops, your system will stop. If this heartbeat varies, timing loops, delays, generated wave- forms etc. will vary too. Correct operation of your embedded system relies therefore on the provision of a robust and regular clock input.

Heart of glass

Quartz is similar to glass in some physical characteristics: in particular, it is fragile.

If you require an oscillator that will operate in an environment where there is sig- nificant vibration, then quartz may not be the ideal choice. If you use a quartz crystal in these circumstances, you will need to package your application to avoid vibration influencing the operation of your system.

Time taken for oscillator to start

If the start of the (crystal) oscillator in your circuit is delayed, then the reset cycle may be completed before the oscillation begins. If this happens, the chip will not be reset.9 The time taken for a crystal oscillator to start operating depends on its being mounted correctly and having appropriate capacitors. Typical start-up times are 0.1 to

10 ms (Mariutti, 1999).

Using an external crystal oscillator module

As we noted in ‘Background’, it is possible to use a self-contained external crystal oscillator module (based on a circuit like that illustrated in Figure 4.1) to drive the microcontroller. This technique has the considerable advantage that the oscillator is guaranteed to start. This can make it a good solution if your system must operate very reliably.

Connecting an oscillator module is very straightforward. Figure 4.3 shows a circuit that will work with all members of the 8051 family. Note that, as shown in the figure, pin XTAL1 should be driven, while XTAL2 is left unconnected.

Particularly where higher clock frequencies (> 12 MHz) are being used, then modules may improve your system reliability. However, oscillator modules do have several drawbacks:

● Oscillator modules cost around twice the price of a crystal oscillator and four times as much as a ceramic resonator.

● Oscillator modules typically draw currents comparable to that of an 8051 micro- controller: 15–35 mA. This may represent a very significant power drain in battery-powered applications.

2. See RC RESET [page 68] for further details.

Oscillator hardware-0086

● Oscillator modules are not always easy to obtain in ‘odd’ frequencies, such as

11.059 MHz. This frequency is very useful in 8051-based designs involving a serial interface, as discussed in ‘Related patterns and alternative solutions’.

Improving the stability of a crystal oscillator

As we have discussed, typical crystal oscillators have a stability of around ±20–100 ppm. If we use this device to control a real-time clock we may gain or lose up to 50 mins per year: that is, up to ~1 minute / week. This result is not specific to the 8051 family: the result of this behaviour is evident even in expensive servers for desktop computer networks. By contrast, most ‘quartz’ wristwatches use crystal oscillators, cost very little and keep very good time. This is because they have a sophisticated temperature control system attached, which keeps them operating at a temperature of 35°C for about 16 hours every day. The temperature control system is your wrist (and attached biological mechanisms).

If you want a general crystal-controlled embedded system to keep accurate time, you can choose to keep the device in an oven (or fridge) at a fixed temperature and fine-tune the software to keep accurate time. This is, however, rarely practical. Instead, ‘temperature compensated crystal oscillators’ (TCXOs) are available that pro- vide – in an easy-to-use package – a crystal oscillator and circuitry that compensates for changes in temperature. Such devices provide stability levels of up to ±0.1 ppm (or more): in a clock circuit, this should gain or lose no more than around 1 minute every 20 years. Such levels of accuracy are adequate for all but the most demanding of applications. However, there is a catch. TCXOs can cost in excess of $100.00 per unit and may even cost several times this amount. This price puts them well out of reach of most embedded projects.

One practical alternative is to determine the temperature-frequency characteristics for your chosen crystal and include this information in your application. For the cost of a small temperature sensor (around $2.00), you can keep track of the temperature and adjust the timing as required. This is the basis of ST ABLE SCHEDULER [page 932].

Another alternative is to use an atomic clock. For example, a caesium beam clock uses atomic transitions as the reference for a crystal oscillator and can provide accu- racy at a level of a few parts per million million (that is, around 1 in 1012). This translates into an accuracy of around 1 minute every million years. Use of such a device may sound like an outlandishly expensive solution, but you can now access the atomic clocks in various satellites using global positioning system (GPS) receivers or GPS chip sets. This is the approach increasingly used by the mobile phone (cell phone) companies that include such technology on their base stations.

Portability

These techniques can be, and are, used with a wide range of microcontrollers and microprocessors.

Note that, as discussed in the ‘Solution’ section, the value of capacitors to be used depends on both the crystal frequency and the microcontroller used. The manufac- turer’s data sheet for the microcontroller will provide recommended values.

Overall strengths and weaknesses

Crystal oscillators are stable. Typically ±20–100 ppm = ±50 mins per year (up to ~1 minute / week).

The great majority of 8051-based designs use a variant of the simple crystal- based oscillator circuit presented here: developers are therefore familiar with crystal-based designs.

Quartz crystals are available at reasonable cost for most common frequencies. The only additional components required are usually two small capacitors. Overall, crystal oscillators are more expensive than ceramic resonators.

Crystal oscillators are susceptible to vibration. The stability falls with age.

Related patterns and alternative solutions
An alternative solution

The main alternative to an external crystal oscillator is an external ceramic resonator: see CERAMIC RESONA TOR [page 64].

Using an on-chip oscillator

As we saw in Chapter 3, Small 8051 devices, such as the popular Atmel 89C4051, are designed as flexible, cost-effective replacements to discrete circuits (assembled from transistors, resistors, capacitors etc.). However, these devices still require external oscillator (and reset) circuits. As the oscillator and reset components can, together, cost as much as these small microcontrollers and greatly increase the board size, it

would seem sensible to include oscillator (and reset) circuits within the microcon- troller itself.

This is now possible, with 8051-family devices such as the Philips 87LPC764. This 20-pin device includes an on-board reset circuit (see Chapter 5). It also includes an on-chip resistor-capacitor (RC) oscillator. It can therefore be used without any exter- nal components.

Increasingly, RC oscillators (also known as ‘relaxation oscillators’) are becoming available as on-chip components. A simple implementation of such an oscillator is illustrated in Figure 4.4.

Other implementations of this simple oscillator are possible using, for example, small numbers of logic gates. However – whatever the implementation – the problem with the RC solution is that the oscillator can never be very stable, largely due to the variation of the resistor values with temperature. This is apparent in many practical implementations: for example, the RC oscillator on the 87LPC764 (and similar devices) has a stability of only ±25%. This is not sufficient for many applications: for instance, if used to generate baud rates for a serial interface, this level of stability would mean that the communication was unlikely to be effective.

Oscillator hardware-0087

Timing issues

Do not assume that just because your microcontroller will operate over a wide range of frequencies that you are free to choose any frequency in this range. The choice of oscilla- tor frequency will have a major impact on any time-related aspects of your application.

For example, you will see numerous designs for 8051-based systems which use crys- tal frequencies of 11.0592 MHz. The reason why this frequency is used is that, with standard 8051 devices, this crystal frequency may be easily used to generate standard baud rates (such as 9600 baud) from the built-in serial port: with other frequencies

(e.g. 10 MHz, 12 MHz) it is more difficult to produce these standard baud rate values. This issue is discussed in greater depth in Chapter 18.

Similarly, the oscillator frequency dictates the rate at which the hardware timers in your application will be incremented. If you need, for example, to schedule a task to run precisely every one minute, this can be difficult to achieve if you have selected an inappropriate oscillator frequency. (See Chapter 14 for further details.)

Note that such peculiar numbers are not restricted to the 8051 family. ‘Quartz’ dig- ital wristwatches use a frequency of 32.768 kHz, since, by dividing this frequency by 215, you obtain a 1 Hz ‘tick’ (215 = 32,768).

Example: Attaching a crystal to an Atmel 89C2051

Recommended capacitor values for connecting most quartz crystals to an Atmel 89C2051 are shown in Figure 4.5.

Oscillator hardware-0088

Example: Attaching a crystal to dual-processor board

It should be noted that most crystals or oscillator modules will drive more than one (typically up to five) microcontrollers. The data sheet will specify this ‘fan out’ value. This can be useful where a multiprocesor design is planned, not least because this means that both microcontrollers (assuming they are both 8051s) will always be ‘in step’ (see Part F for further details).

Figure 4.6 illustrates how the two boards should be connected to the same crystal. Note that the same approach can be applied to any combination of microcontrollers: if the two boards require different capacitor values, then select a mid-range value.

Oscillator hardware-0089

Further reading

Refer to the manufacturer’s data sheet for your chosen microcontroller to ensure you use the required capacitor values in your crystal oscillator circuit.

 

Designing embedded systems:Conclusions

Conclusions

In this second brief introductory chapter, we have argued that developers of embedded applications can benefit from pattern-driven design techniques not least because many embedded projects require the developer to have both knowledge of software design and from a range of related technical and engineering fields.

Four points should be made as we conclude this chapter:

● Software patterns should not be seen as an attempt to produce a panacea or what Brooks (1986) calls a ‘silver bullet’ for the problems of embedded software design or implementation. Software development is a multifaceted activity, requiring intelligence and creativity: the solutions to such problems come from intelligent and creative individuals, and there are no ‘miracle cures’ or ‘silver bullets’ waiting to be uncovered.

● For similar reasons, use of the patterns in this book does not guarantee that your system will be reliable. Thus, for example, the first time you get on a plane and the pilot announces, reassuringly, that the flight control software was designed by engi- neers who used the latest set of ‘time-triggered software patterns’, this may mean that the software is more reliable than it would have been if the designers and pro- grammers had not been exposed to a set of patterns like those presented in this book. However, it can never mean that the flight software is fault free.

● At best, ‘the pattern solution’ will be a partial one. For example, it is not feasible to provide all software engineers or their managers, irrespective of background or training, with sufficient knowledge of relevant fields to ensure that they can, for example, create appropriate designs for aircraft flight control systems or fault diagnosis systems based on sliding-mode observers. However, what we may be able to achieve is to make software managers, and the teams they manage, better able to recognize projects in which it would be advisable to appoint (say) an artificial intel- ligence, signal processing or control expert from within the company on the project team or to employ an outside consultant to fulfil such a rôle.

● No useful pattern collection is ever ‘finished’: further patterns will gradually be added and existing patterns can always be improved. This collection is certainly no exception. As discussed in the preface, your comments and feedback on this collec- tion would be very much appreciated.

Designing embedded systems-0072

 

 

Oscillator hardware

Introduction

All digital computer systems are driven by some form of oscillator circuit. This circuit is the ‘heartbeat’ of the system and is crucial to correct operation. For example, if the oscillator fails, the system will not function at all; if the oscillator runs irregularly, any timing calculations performed by the system will be inaccurate.

As a consequence, choice of an appropriate oscillator circuit is an important part of any hardware design. For most microcontroller-based systems, there are two main oscillator options, each of which is represented by a pattern in this chapter:

CR YST AL OSCILLA TOR [page 54]

CERAMIC RESONA TOR [page 64]

 

The 8051 microcontroller family:SMALL 8051

SMALL 8051

Context

You are developing a microcontroller-based embedded application and have some flexibility in the choice of hardware platform to be used.

Problem

Should you base your application on a Small 8051-family microcontroller?

Background

The desktop microprocessor market is characterized by constant demands for increased power. As a result, processors become obsolete after two or three years in production. By contrast, the 8051 architecture is more than 20 years old, yet the family is growing in both size and popularity.

This only makes sense because, as we saw in Chapter 1, the driving forces behind the embedded market are rather different from those of the desktop. In the embedded market, the trend is to exploit the flexibility of low-cost microcontrollers in an ever wider range of applications: indeed, as prices fall, these devices are finding their way into applications that would have involved a small number of discrete components (transistors, diodes, resistors, capacitors) a few years ago, but which are now imple- mented with microcontrollers.

To emphasize the very different nature of the embedded market, some of the more recent 8051 devices – far from being more powerful and having more features than the original – generally have fewer features.

Most immediately obvious is the fact that these Small 8051 devices typically have 20 or 24 pins and only some 15 I/O pins. In addition to their small physical size, the other common feature linking the Small 8051s is that they do not support external memory. For example, in the case of the popular AT89C1051, AT89C2051 and AT89C4051, Port 0 and Port 21 from the original device are omitted entirely (along with the ALE and PSEN pins, and some pins on Port 3), allowing the number of exter- nal pins to be reduced, in these cases to 20 pins. Similar changes are made in the Philips 87LPC764 and Philips 80c751 devices (see Figure 3.4).

The 8051 microcontroller family-0078

Performance issues

Most Small 8051s provide a CPU performance of 1–2 MIPS (see ST ANDARD 8051

[page 30]).

Memory issues

A key feature of the Small 8051s is that they do not support a standard external data and address bus. As a result, the memory map of a typical Small 8051 looks like that shown in Figure 3.5.

Availability of on-chip hardware components

The on-chip hardware components on Small 8051s vary greatly between devices. The popular Atmel range has few on-chip hardware components, while the Philips devices tend to have a very wide range of features, including ADCs and pulse width modulator (PWM)2 units. For example, the Philips 87LPC768 is a low-cost, 20-pin, 8051-based microcontroller with 4 kB OTP ROM memory, an 8-bit ADC and a PWM unit.

The 8051 microcontroller family-0079

[Note: that the 89C2051 and 89C4051 are similar, but have more RAM and 2 kbytes or 4 kbytes, respectively, of flash memory.]

Where external components must be added, either consider using a Standard 8051 as a replacement microcontroller. Alternatively, consider using a serial bus (e.g. I2C: see Chapter 23) to connect the external devices.

Power consumption

A Standard 8051 (typically) has a narrow operating voltage range: around 4.5V to 5.5V. One important feature of the Small 8051 devices is that they have a very wide operating voltage range: typically around 3V to around 7V. This wide operating volt- age range makes it very easy to create low-cost, battery-powered applications.

In addition, like most Standard 8051s, the Small 8051s have three operating modes: normal, idle and power down. Typical current requirements for the various modes are shown in Table 3.2. Note also that the power supply is assumed to be 5V.

The 8051 microcontroller family-0080

Hardware resource implications

The Small 8051 provides the following hardware resources:

● A CPU performance of between 1 MIPS and 3 MIPS (approximately).

● Available internal memory (typical) of up to 4 kbytes for code and 256 bytes for data. No support for external memory.

● Usually one, full duplex (‘RS-232’) serial port.

● Two or three hardware timers.

● Current consumption of around 10 mA in normal operating mode, 5 mA in idle mode, and 10 µA in power-down mode.

Additional features are also available on some devices.

Reliability and safety implications

There are no available figures to suggest that the Small 8051 is any more (or less) reliable than any other microcontroller family.

Portability

Please note that the Small 8051s have a core architecture based on the 8051 family. However, as is apparent from Figure 3.4, the various Small 8051s are in no sense pin compatible and vary greatly in features and functionality. As a result, code written for a particular Small 8051 is less portable than code written for a Standard 8051.

Overall strengths and weaknesses

To summarize, the Standard 8051 has the following strengths and weaknesses:

It is based on the core 8051 architecture and thus has many of the strengths of the Standard 8051.

It has a small physical size. It is a low-cost device.

It has limited on-chip RAM and ROM memory and no support for external memory. Designs based on Small 8051s are less easy to port than designs based on Standard

8051s, due to the diverse nature of this branch of the microcontroller family Related patterns and alternative solutions

The main alternative to a Small 8051 (considered in this text) is the ST ANDARD 8051

Alternatively, consider one of the microchip family of PIC devices, such as the (8-pin) PIC12CE673; these have similar capabilities to the Small 8051 devices, albeit with a completely different architecture.

Example: Using the Small 8051

We give many examples of the use of Small 8051 devices throughout this book.

Further reading

A collection of data books for a range of Small 8051 devices is included on the CD-ROM.

 

Designing embedded systems using patterns:Patterns for time-triggered embedded systems

Patterns for time-triggered embedded systems

We found the software patterns described by Gamma et al. (1995) to be useful. However, they were insufficiently specialized for use with time-triggered embedded systems. We therefore began to assemble a collection of patterns based on our experience with the development of applications for the 8051 and other families of micro- controllers.

The first version of these patterns were used ‘in house’, primarily for teaching and training purposes. We then began to publish and discuss the next versions of the pat- terns more widely, not just at pattern workshops (see, for example, Pont et al., 1999a; Pont, in press) but also at more general technical conferences (see, for example, Pont, 1998; Pont et al., 1999b). Through this process we obtained a great deal of useful feed- back on the project, and refined the collection again. The end result was the set of pat- terns described in detail throughout this book.

The structure of the final version of the patterns is illustrated in Figure 2.10. The patterns are grouped by chapter, and the book is further divided into sections. This arrangement is intended to make it easy for you to find the information you require.