microprocessor and microcontroller based systems

21
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical Engineering Department م ي ح ر ل ا ن م ح ر ل ه ا ل ل م ا س بEELE 4315 — Fall 2010 Lecture 9

Upload: truong

Post on 10-Jan-2016

48 views

Category:

Documents


1 download

DESCRIPTION

بسم الله الرحمن الرحيم. The Islamic University of Gaza Faculty of Engineering Electrical Engineering Department. Microprocessor and Microcontroller Based Systems. EELE 4315 — Fall 2010. Instructor: Eng.Moayed N. EL Mobaied. Lecture 9. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Microprocessor and Microcontroller Based Systems

Microprocessor and Microcontroller Based Systems

Instructor: Eng.Moayed N. EL Mobaied

The Islamic University of GazaFaculty of EngineeringElectrical Engineering Department

الرحمن الله بسمالرحيم

EELE 4315 — Fall 2010

Lecture 9

Page 2: Microprocessor and Microcontroller Based Systems

Almost any embedded system needs to transfer digital data between its CPU and the outside world. This transfer falls into a number of categories, which can be summarised as:

Direct user interface, including switches, keypads, light emitting diodes (leds) and displays;

Input measurement information, from external sensors, possibly being acquired through an analog to digital converter;

Output control information, for example to motors or other actuators;

Bulk data transfer to or from other systems or sub-systems, moving in serial or parallel form, for example sending serial data to an external memory.

How can we provide the required interface between the microcontroller core and the outside world? More precisely, how do we get the data onto or off the data bus at the right moment?

Why Digital Input/Output?

Digital Input/Output and the 16F84A

Page 3: Microprocessor and Microcontroller Based Systems

Parallel Output

We could apply a circuit like this for output.

Here a pulse on the Port Select line captures data on the bus at that instant, and transfers it to the external pin.

Data Bus

External Pin

Port Select

QD

Two lines of

External PinQD

Read/Write

Flip-flop latches data bus value onto

external pin, when memory location

is selected, AND Write is activehigh wheneverport address is selected

Digital Input/Output and the 16F84A

Page 4: Microprocessor and Microcontroller Based Systems

Parallel Input

Data Bus

External Pin

Port Select

Two lines of

buffer transfers logic value on external pin

onto data bus line, when memory location

is selected, AND Read is active

External Pin

Read/Write

Or we could apply a circuit like this for input.

Here a pulse on the Port Select line transfers data on the external pin at that instant to the data bus.

Digital Input/Output and the 16F84A

Page 5: Microprocessor and Microcontroller Based Systems

A Bi-Directional Port Pin Driver Circuit

Or, we could combine both circuits into one multi-function circuit, like this. You don’t need to grasp all the detail of this circuit, although it’s neat if you can.

There is now an extra flip-flop, labelled “Direction”. The state of this decides in which direction data will flow.

The two flip-flops shown can each form one bit in an SFR, which can be controlled from the CPU.

A group of these bits, each driven by a circuit like this, is called a “port

D Q

D Q

"Direction"

"Data" I/O Pin

Read/Write

Port Select

Direction Select

Data Bus

(bit n of an 8-bit port)

(bit n)

Output Buffer

Input Buffer

Alternate Input Function

"Data" SFR

"Direction" SFR

Read Port

WritePort

WriteDDR

buffer, enabledwhen pin is output

determines whether portbit is input or output

8 of these flip-flops form the "Data Direction" SFR

8 of these

the "Data" SFR

holds bitoutput value

flip-flops form

D Q

D Q

"Direction"

"Data" I/O Pin

Read/Write

Port Select

Direction Select

Data Bus

(bit n of an 8-bit port)

(bit n)

Output Buffer

Input Buffer

Alternate Input Function

"Data" SFR

"Direction" SFR

Read Port

WritePort

WriteDDR

buffer, enabledwhen pin is output

determines whether portbit is input or output

8 of these flip-flops form the "Data Direction" SFR

8 of these

the "Data" SFR

holds bitoutput value

-flip-flops form

Digital Input/Output and the 16F84A

Page 6: Microprocessor and Microcontroller Based Systems

Holds output data

Value held determines data direction

Output buffer

0 on this line enables output buffer

From Option Register

Decoded address lines

Digital Input/Output and the 16F84A

Page 7: Microprocessor and Microcontroller Based Systems

Port Input Characteristics

When designing with microcontroller digital I/O one needs to have an understanding of their electrical characteristics.

16F84A Input CharacteristicsThe input of a logic gate or port pin requires the voltage to be below a certain maximum in order to be recognised as a logic 0, or above a certain minimum to be recognised as a logic 1.

Minimum Input High Voltage, VIH 2.4V (TTL buffer inputs)Maximum Input Low Voltage, VIL 0.8V (TTL buffer inputs)Input Leakage Current, IIL +1A

PIC 16F84A Port Input Characteristics (5V power supply)

Digital Input/Output and the 16F84A

Page 8: Microprocessor and Microcontroller Based Systems

Simple Digital Interfacing – connecting to switches

Vi

VS

RVi

VS

R

Vi

VS

Digital Input/Output and the 16F84A

Page 9: Microprocessor and Microcontroller Based Systems

Light Emitting Diodes (leds) - Review

High Efficiency Red Yellow

Digital Input/Output and the 16F84A

Page 10: Microprocessor and Microcontroller Based Systems

a) Gate Output Sourcing b) Gate Output Sinking Current to LED Current from LED

Driving LEDs from Logic Gates (and hence Port Bit Outputs)

I

R

D

I

R

VD

D

VS

VD

current flows out of the gateand lights led when output is at logic 1

current flows into gateand lights led when output is at logic 0

Digital Input/Output and the 16F84A

Page 11: Microprocessor and Microcontroller Based Systems

PIC Microcontrollers Families

PIC controllers are roughly classified by Microchip into three groups: baseline, mid-range, and high performance.

Within each of the groups the PICs are classified based on the first two digits of the PIC’s family type.

However, the sub classification is not very strict, since there is some overlap.

For this reason we find PICs with 16X designations that belong to the baseline family and others that belong to the mid-range group.

Page 12: Microprocessor and Microcontroller Based Systems

Baseline PIC Family

This group includes members of the PIC10, PIC12, and PIC16 families.

The devices in the Baseline group have 12-bit program words and are supplied in 6- to 28-pin packages.

The microcontrollers in the baseline group are described as being suited for battery-operated applications since they have low power requirements.

The typical member of the Baseline group has a low pin count, flash program memory, and low power requirements.

Page 13: Microprocessor and Microcontroller Based Systems

Baseline PIC Family “PIC 10 Devices”

Page 14: Microprocessor and Microcontroller Based Systems

Baseline PIC Family “PIC 12 Devices”

Page 15: Microprocessor and Microcontroller Based Systems

Baseline PIC Family “PIC 12 Devices”

Page 16: Microprocessor and Microcontroller Based Systems

Mid-range PIC Family

The mid-range PIC family includes members of the PIC12 and PIC16 groups.

According to Microchip, the mid-range PICs all have 14-bit program words with either flash or OTP program memory.

Those with flash program memory have EEPROM data memory and support interrupts.

Some members of the mid-range group have USB, I2C, and converters A/D.

Page 17: Microprocessor and Microcontroller Based Systems

Mid-range PIC Family

Implementations range from 8 to 64 pins.

This is by far the most extensive PIC family.

Currently, over 80 versions of the PIC16 are listed in production by Microchip.

The Microchip website has more detailed information on these devices.

Page 18: Microprocessor and Microcontroller Based Systems

Mid-range PIC Family

Page 19: Microprocessor and Microcontroller Based Systems

High-Performance PIC Family

The high-performance PICs belong to the PIC18 group.

They have 16-bit program words, flash program memory, a linear memory space of up to two Mbytes, and protocol-based communications facilities.

They all support internal and external interrupts and have a much larger instruction set than members of the baseline and mid-range families.

Page 20: Microprocessor and Microcontroller Based Systems

High-Performance PIC Family

The PIC18 family is also a large one, with over 70 different variations currently in production.

The PIC18 family uses 16-bit program words and are furnished in 18 to 80 pin packages.

Microchip describes the PICs in this family as high-performance with integrated A/D converters.

They have 32-level stacks and support interrupts.

The instruction set is much larger and starts at 79 instructions.

The PICs in this family have flash program memory, a linear memory space of up to 2 Mbytes, 8-by-8 bit hardware multiplier, and communications peripherals and protocols.

Page 21: Microprocessor and Microcontroller Based Systems

High-Performance PIC Family