Useful Tools

contact us contact tutor/group email to a friend accessibility options report a fault
Microcontrollers

Microcontrollers

Unit 1 - Introduction to Microcontrollers


Unit Information


1.1 Introduction to the microcontroller part of the course

The microcontroller is a very common component in modern electronic systems. Its use is so widespread that it is almost impossible to work in electronics without coming across it.

Microcontrollers are used in a wide number of electronic systems such as:

One could go on adding to this list, but the reader should now be getting the impression that there is a very wide scope for use of microcontrollers.

The next few sections will attempt to answer the following questions:

  1. What is a microprocessor?
  2. What is a microcontroller?
  3. What is the difference between a microprocessor and a microcontroller?

[back to top]



1.2 What is a microprocessor?

A microprocessor is a programmable digital electronic component that incorporates the functions of a central processing unit (CPU) into a single IC package. These functions are:

Microprocessors have been around since the start of the 1970's.  For a brief history about the initial development of the microprocessor :- please click here.

 

[back to top]


1.2.1 Types of Memory can be obtained as either:

Both ROM and EPROM memory are used to hold the program code of a microprocessor used in an embedded system, ie. a microprocessor used in an application where the program code is always the same and is designed to execute every time the system is switched on. Most development work is done using EPROM or EEPROM type memory, ROM memory being used in the final production version (when all the program code has been fully tested).

 

[back to top]


1.2.2 Random Access Memory (RAM)

All microprocessor systems need memory that can be both read from and written to - such memory is RAM. RAM got its name because early read-write memories were sequential, and did not allow random access. RAM memory is used to store dynamic data (that will change during the operation of the program). RAM takes the form of integrated circuits that allow the stored data to be accessed in ANY order — that is, at random and without the physical movement of the storage medium or a physical reading head. The word "random" infers that any piece of data can be returned quickly, and in a constant time, regardless of its actual physical location, in relation to the previous data storage location.
The key benefit of RAM is that retrieval times are short and consistent. The disadvantages of RAM are cost, and the loss of data when power is turned off (volatile).

 

So a typical microprocessor system will contain both ROM (could be EPROM, EEPROM, or ROM) to store the program code, and RAM to store dynamic data.

 

[back to top]


 

1.2.3 The Chip Select Line

When several devices are connected to the same set of input wires (e.g, via a bus), and it is required to send data or commands to each device independently of the others on the bus, we use a chip select line.

When the chip select pin is held in the inactive state, the the chip or device pays no heed to changes in the state of its input pins. When the chip select pin is held in the active state, the chip or device assumes that any input changes it "hears" are meant for it, and responds as if it is the only device on the bus.

In summary, the chip select is an input-enable switch. "ON" means the chip or device responds to changes on its input pins, while "OFF" tells the chip or device to ignore everything.

Figure 1, below, illustrates the basic connections between the microprocessor and external memory.

Fig 1 : Basic connections between the microprocessor and its memory devices

Figure 1

In figure 2, we see the addition of address decoding logic to identify a particular range of address values to activate the chip select signal. This way, the memory device can only be selected within a particular range of addresses. The chip select line allows the memory to be either selected (/CS = 0, sometimes referred to as enabled) or not selected (/CS = 1, sometimes referred to as disabled).

Fig 2 Address decoding logic is added to generate a "Chip Select" signal for the memory device

Figure 2

The address decoding logic is simply a decoder that can be used to decode the particular combination of address inputs and activate one (of a number of) chip select outputs. See TTL data book for possible devices such as the 74138 and the 74139.

Example of Address Decoding Logic

Derive logic to select any addresses in the range A000 hex to AFFF hex.  The bit pattern is illustrated here:

A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
1 0 1 0 x x x x x x x x x x x x

In the example shown in figure 3, the chip select signal is active low when the input signal (A15, A14, A13, A12) is 1010. At all other times the chip select signal is logic 1 (disabled).

Fig 3  Example of chip select signal

Figure 3

The address decoding logic can be used to generate a chip select signal for a number of memory devices. Each chip select output signal responds to a different address value, as in figure 4.

Fig 4 Three different Chip Select signals

Figure 4

The address decoding logic is usually used to select more than one memory chip since most microprocessor systems use a number of memory chips to make up a complete system. Only one chip select line will be enabled at any one time. This means that the microprocessor sees only one memory device connected to the data bus at any one time, i.e. when the particular memory device is selected.

When no memory device is selected (as will be the case when the microprocessor is performing internal operations when memory access is not required), the data bus is placed into a mode called tri-state. This tri-state mode places an open circuit condition between the microprocessor and memory, thus disconnecting the data bus between memory and microprocessor. In fact, when the address decoding logic selects a particular memory device to be connected to the microprocessor, the other memory devices in the system are disconnected from the microprocessor. In this way, only one memory device can be connected to the microprocessor at any one time, the one selected by the address decoding logic.
 

[back to top]



  

1.3 What is I/O? I/O is input or output (Input/Output)

I/O (input/output) is the collection of interfaces that different functional devices, of any information processing system, use to communicate with each other. Every information transfer is an output from one device and an input into another. For instance, on a computer, a keyboard and mouse are considered input devices while monitors and printers are considered output devices. Typical devices for communication between computers, such as modems and network cards, operate as both input and output devices.

I/O can be:

These are relatively complex sub systems that can be obtained as separate ICs. They are connected to the microprocessor in a similar manner to that of the memory devices.  Indeed, they often contain their own memory to support internal operations (ie. registers).

[back to top]


1.3.1 Digital I/O

A digital I/O port can be realised using a number of D type Flip-Flops.

[back to top]


1.3.2 Output Port

Figure 5 illustrates a four bit output port. The inputs are connected to the data bus whilst the outputs are connected to whatever output interface is to be controlled.

Fig 5 A 4-bit output port

Figure 5

[back to top]


1.3.3 Input Port

The input port, shown in figure 6, allows outside world inputs (left hand side of figure 6) to be stored in the data latches so they can be read by the microprocessor via the data bus (right hand side of figure 6).

Fig 6 A 4-bit input port

Figure 6

The data bus connections must be via tri-state buffers so that the input port is only connected to the data bus when the input port is selected. This is achieved by connecting a chip select signal to the enable input signal line. Note that the tri-state enable is active low. We have covered some of the basic concepts of the microprocessor.  There is of course much more but we can pick up on these later.  We now need to turn our attention to the question what is a microcontroller?
 

[back to top]


1.4 What is a microcontroller?

Basically, a microcontroller is a device which integrates a number of the components of a microprocessor system onto a single chip (IC), with the following common features:

Figure 7 shows an un-expanded microcontroller, which contains a number of commonly used sub-units.

Fig 7 Main components of a microcontroller

Figure 7

Most microcontrollers will also combine other devices such as:

Figure 8 shows a single chip microcontroller and CPU. The CPU is the processing module of the microcontroller.

Fig 8 A single chip microcontroller

Figure 8

The above figure illustrates a typical microcontroller device and the different sub units integrated onto the microcontroller microchip.

Microcontrollers are nowadays brimming with added functionality on this single IC and often include:

 

Before we dive into modern day complexities, lets look at the heart of the microcontroller - the CPU core.  In the past this has traditionally been based on an 8-bit microprocessor unit.  For example, Motorola uses a basic 6800 microprocessor core in their 6805/6808 microcontroller devices.

[link to Summary of the first 20 years of Microprocessor/controller Evolution]

In recent years, microcontrollers have been developed around specifically designed CPU cores for example, the Microchip PIC range of microcontrollers.

[link of current popular microcontroller manufacturers]

[back to top]


Study Task 1

See www.freescale.com and www.microchip.com for their respective products information plus examples of their microcontrollers.

On the Freescale website you will notice:-
8-bit Microcontrollers; 16-bit Microcontrollers; 32-bit Microcontrollers & Processors; Analog and Mixed Signal; ASIC; Digital Signal Processors & Controllers.
Typical applications include Automotive; Consumer Electronics (including power management); Industrial Control (and sensors); Motor Control; Networking, Mobile and various Wireless Connectivity options.

On the Microchip website you will notice:-
8-bit Microcontrollers; 16-bit MCUs and Digital Signal Controllers; Analog and Interface Products; Serial EEPROMS; Battery Management; Radio Frequency Devices.
Typical applications include Automotive; Home Appliance; Mechatronics; Medical Solutions; EMC Design; LCD Solutions; Low Power Solutions; Intelligent Power Supply & Lighting; Motor Control Applications (including Stepper Motor, Brushed DC Motor, AC Induction Motor, Variable Speed Brushless DC Motor, Switched Reluctance Motor, Permanent Magnet Synchronous Motor) via Connectivity options including CAN, LIN, USB, Ethernet, TCP/IP, Zigbee, Infrared & RF.

Familiarise yourself with the microcontroller areas of these websites.

 

[back to top]


1.4.1 Memory in a microcontroller

The amount of memory contained within a microcontroller varies between different microcontrollers.  Some may not even have any integrated memory (eg. Hitachi 6503, now discontinued).  However, most modern microcontrollers will have integrated memory. The memory will be divided up into ROM and RAM, with typically more ROM than RAM.

Figure 9 shows the ROM of a microcontroller which is used to store the application program.

Fig 9 Microcontroller ROM

Figure 9

Typically, the amount of ROM type memory will vary between around 512 bytes and 4096 bytes, although some 16 bit microcontrollers such as the Hitachi H8/3048 can have as much as 128 Kbytes of ROM type memory.

ROM type memory, as has already been mentioned, is used to store the program code. ROM memory can be either ROM (as in One Time Programmable memory), EPROM, EEPROM, or FLASH.

Figure 10 shows the microcontroller RAM which is used to store data.

Fig 10 Microcontroller RAM

Figure 10

The amount of RAM memory is usually somewhat smaller, typically ranging between 1 Kbytes to 64 Kbytes.

RAM is used for data storage and stack management tasks.  It is also used for register stacks (as in the microchip PIC range of microcontrollers).
 

[back to top]


1.4.2  The I/O Ports

Figure 11 shows microcontroller ports which are used to access the outside world.

Fig 11 Microcontroller ports

Figure 11

The digital I/O ports are the means by which the microcontroller interfaces to the environment.

Digital I/O tends to be grouped into byte wide ports (8 digital bits) that can be configured as either input bits or output bits.  There are some exceptions, such as the microchip PIC 16C54 with one 6-bit RA port and a byte wide RB port.

The number of I/O port bits varies, depending upon the size of the microcontroller.  Some very simple 8 bit microcontroller have as few as 4 bits of I/O, whilst those at the high end range can have as many as 33 bits of I/O (some 16 bit microcontrollers could have around 78 bits of I/O).

A typical interface might look like the one illustrated below in figure 12.

Fig 12 A typical interfacing example

A typical interfacing example

Microcontroller ports can be used to operate LEDs and relays, as well as input the state of switches and logic circuit inputs (not shown in this figure).  Not all microcontroller port outputs are able to drive an LED directly; some need to be interfaced via a buffer such as a 7406 open collector inverting buffer.  In the example above, the relay is driven by such a buffer.

[back to top]


Study Task 2

Look at the following web sites and discover the amount of memory used in both the 8-bit Microchip PIC's, the Freescale 8-bit range of microcontrollers and Atmels 8-bit family of microcontrollers.

 

[back to top]


Self Assessment Questions

In answering these questions, just look for basic answers; don't try to go into too much depth at this stage at this stage.

Question 1

What is the difference between a microprocessor and a microcontroller?

Answer

See section 1.2 for what a microprocessor is.  Section 1.4 indicates what a microcontroller is.  Essentially, a Microprocessor is a central processing unit IC. To make it to work it will need lots of other ICs around it (like ROM, RAM and timers). The microprocessor has the ability to execute a stored set of instructions to carry out user defined tasks. It also has the ability to both 'read data from' and 'write data to' external memory chips. A microcontroller is a device which integrates a number of the components of a microprocessor system onto a single microchip. e.g. A microcontroller combines The CPU core, Memory (both ROM and RAM) and some parallel digital I/O onto the same IC. Modern microcontrollers also contain a wealth of other modules such as Serial I/O, Timers, and Analogue to Digital Converters. There are a large number of specialised devices with additional modules for specific needs. eg. CAN controllers, Serial Peripheral drivers.


Question 2

A microprocessor is to be used in an application requiring 1Kbyte of data memory and a program of 8Kbytes.  What type of memory is required in each case?

a. For a prototype system
b. For a  final product.

Also, how many bits would be required for the address bus?

Answer

1KB memory for data requires the use of RAM memory since the data will change during the execution of the program.

8KB program memory will need ROM/PROM/EPROM/EEPROM memory since the program is static i.e., does not change during the life of the application.

The total amount of memory is 8KB + 1KB (there is no indication of any digital I/O) so the total memory space is 9KB.

To accommodate 9Kbytes of memory space will require an address bus with n bits where

 2n  =  (8192 + 1024) = 9216 = 2400 hex.

2400 hex is 10 0100 0000 0000 in binary which is 14 bits so n = 14.

Put another way,  n = log(9216)/log(2) = 13.17 which round up to 14 bits.

Another way of looking at it is to think of the binary weightings.

8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
1 0 0 1 0 0 0 0 0 0 0 0 0 0

Add all the weightings with a binary one and you get 9216 which is 9Kbyte.


Question 3

After looking at the Microchip web site you should gather that there are four families of 8-bit PIC devices (10, 12, 16 & 18 families) spread over three performance ranges (baseline, mid range and high performance).  What are the main differences between these three ranges of microcontrollers in terms of device physical size, memory, digital I/O, size of address bus and data bus, and the number of peripheral devices they contain (don't worry too much about what they are at present)?

Answer

BASELINE ARCHITECTURE The Baseline Architecture includes the PIC10 family and portions of the PIC12 and PIC16 families. These devices utilize a 12-bit program word architecture with 6 to 28-pin package options. A range of low operating voltages makes this architecture ideal for small battery-operated applications. Typically, the PIC12 family utilises RISC-based 12-bit program word architecture, have low pin count and small form factor (8-pin DIP or SOIC packages), use flexible Flash program memory, have low power capability, are cost sensitive and are easy to use. The BASE LINE with ROM/EPROM memory from 512 to 2KB, between 25-72 bytes of RAM and a Timer module.

MID-RANGE ARCHITECTURE The Mid-Range Architecture includes members of the PIC12 and PIC16 families that feature a 14-bit program word architecture. These families are available in packages from 8 to 64-pin options. Microchip's Mid-Range PIC's feature 14-bit program word architecture and are available in higher pin count packages (also with Flash and OTP program memory options). The Flash devices offer an operating voltage range of 2.0V to 5.5V, small package footprints, have low power capability, interrupt handling, have a deeper hardware stack, a selection of A/D channels and EEPROM data memory. They also have a Rich peripheral set and have an operating performance of 5 MIPS. The Mid-Range line contains between 1 and 4KB of program memory (ROM/EPROM) and 25 to 128 bytes of RAM. They all contain a Timer unit, but some also contain a serial port or an Analogue to Digital converter. The amount of digital I/O ranges from 13 bits to 33 bits.

HIGH PERFORMANCE ARCHITECTURE The High Performance Products (centering around Microchip's PIC18 MCUs) feature 16-bit program word architecture and are designed for applications requiring 10-16 MIPS performance, with a pin count from 18 to 100. The High-Performance Range contains between 1 and 128KB of program memory (ROM/EPROM) and from 256 to 3968 bytes of RAM and can have between 16-70 I/O pins. The PIC18 Microcontrollers also contain such features as:- Industry leading peripheral set including advanced communication peripherals and protocols (CAN, USB, ZigBeeT, TCP/IP) with socket, software and peripheral compatibility, providing scalability for complex embedded designs.


Question 4

Which of the Microchip PIC devices can be used to input analogue voltages.

Answer

From the Microchip homepage website follow each one of the four leads below from the Microchip home page to see the answers:- "8-bit microcontroller - Product Family - PIC10MCU" to see that PIC10F220 and PIC10F222 have 8-bit AtoD on these 6 pin devices. "8-bit microcontroller - Product Family - PIC12MCU" to see that PIC12F675, PIC12F683, PIC12F615 have 10-bit AtoD and the PIC12F510 has 8-bit AtoD, all in 8 pin packages. "8-bit microcontroller - Product Family - PIC16MCU" to see that there are lots of devices that contain Analogue to Digital. Within the PIC16 family, look at the C7X, C9X, F64X, F67X, F68X, F69X, F7X, F81X, F87X, F88, F88X and F9X ranges of microcontrollers. "8-bit microcontroller - Product Family - PIC18MCU" to see that ALL the 18 family have AtoD.


Question 5

After looking at the Freescale web site, what is the range of memory size for program memory and data memory for the HC05 (Legacy) range of microcontrollers?

Answer

From the freescale.com homepage click on the link to 8-bit microcontrollers, then select the HC05 (legacy) link. The Motorola HC05 (Legacy) range of microcontroller has a very wide range of different devices, each of which supports a number of internal function modules (you will cover module types in unit 2). Program memory can include, up to 32768 bytes of ROM, up to 8192 EEPROM and up to 528 bytes of RAM.


Question 6

What are the significant features of the Freescale HC08 family of microcontrollers?

Answer

URL:- http://www.freescale.com then follow the links to HC08 via the 8-bit microcontrollers link. The HC08 Products are small, general purpose, low-power, feature rich. Highly integrated, general purpose devices with ADC, analog comparator, multiple communications options, timers, and on-chip ICE (In circuit emulation). Memory comes in Flash or ROM, from 1 KB to 60 KB, and are packaged from tiny 8 pin QFN to 64-pin quad flat packages. This family of devices features peripherals such as 8 or 10-bit A/D converters, CAN, LIN, J1850, multichannel timers, SCI/ESCI/SLIC supporting LIN protocol, SPI and EEPROM, as well as industry-leading in-circuit reprogrammable FLASH. Additionally there are many application-specific devices, for example LIN, motor control, and RF. All MCUs in the family use the enhanced M68HC08 central processor unit (CPU08) and are available with a variety of modules, memory sizes and types, and package types.

 

[back to top]


1.5 Conclusion

From your first browse of the above web sites you should now have a "feel" for the range of microcontroller products currently available.  It is clear that these devices can be applied to many embedded system designs from the simple hardware control applications up to Signal Processing applications. The choice and selection of devices available today is vast.

Note: Intel also produce a range of microcontroller devices.  The Intel 8-bit microcontroller family can be browsed at:   http://intel.com/design/mcs51   You don't need to look at this site in much detail just yet, but simply to be aware of it and keep the website URL handy.

Also see the list of current popular microcontroller manufacturers.
 

[On to the start of Module 2] 

[back to top]


updated 24.11.10 KS

Site Search

Powered by Google
Site Map