Title: Microcontrollers : Applications and Architectures
1Microcontrollers Applications and
Architectures
EE1A2
- Sandra I. Woolley
- Electronic, Electrical and Computer Engineering
2Introductory Assembler Exercises
- Let us look at some examples of PIC16F84
microcontroller assembler instructions. What do
these instructions do? -
- At the start, the working register (W) contains
the value 0x1C and the PORTB register contains
the value 0. What values are in W and PORTB
after each instruction? - MOVLW 0X24
- ADDLW 0X02
- ADDLW 0X17
- MOVWF PORTB
- CLRW
- ADDLW 0x05
- MOVWF PORTB
- CLRF PORTB
-
3Contents
- Microcontrollers and Embedded Systems
- Applications
- Architectures
- Von Neuman and Harvard
- CISC vs. RISC
- PIC16F84 Memory
- Assembler Instruction Exercises
4Introduction
- A microprocessor is a programmable logic device
with a designed set of instructions. It contains
three primary components a processing unit,
memory, and, input and output (I/O). -
- A controller is used to control some process or
aspect of the environment. - At one time, controllers were built exclusively
from logic components, and were usually large,
heavy boxes. -
- With the advent of microprocessors entire
controllers could fit on a small circuit board. -
- You can still find controllers powered by one of
the many common microprocessors (e.g., Zilog
Z80). - But most new systems use microcontrollers
robust, low-power, single-chip solutions designed
specifically for the embedded control
environment. -
5Embedded Systems
- Embedded system definition from Wikipedia, the
free encyclopedia. - An embedded system is a special-purpose computer
system, which is completely encapsulated by the
device it controls. - An embedded system has specific requirements and
performs pre-defined tasks, unlike a
general-purpose personal computer. -
6Example Applications of Embedded Microcontrollers
- Households appliances
- microwave ovens
- refrigerators
- televisions and VCRs
- stereos
- Computers and computer equipment
- laser printers
- modems
- disk drives
- Cars
- engine control
- diagnostics
- Environmental control
- greenhouse, factory, home
-
7More on Applications
- Small size and low power consumption also make
microcontroller devices ideal for unattended data
monitoring and recording. - The automotive market an important driving force
in the microcontroller market, especially at its
high end. The systems must operate under extreme
temperatures and be able to withstand vibration,
shock, and EMI. -
Embedded Car Area Network (CAN) Devices
8Smart Card Applications
www.wincoid.com/ ph_smart.htm
9Von Neuman and Harvard Architecture
-
- Von Neuman Architecture
- Program instructions and data are stored in a
common main memory. - Microcontrollers based on the Von-Neuman
architecture have a single bus that is used to
fetch both instructions and data. - Harvard Architecture
- Microcontrollers based on the Harvard
Architecture have separate data and instruction
memories. -
-
10CISC vs. RISC
- CISC (Complex Instruction Set Computer)
- Many modern microcontrollers are based on the
CISC concept. - The typical CISC microcontroller has well over 80
instructions, many very powerful and specialised.
- It is quite common for the instructions to all
behave quite differently. - The advantages of the CISC architecture is that
many of the instructions are macro-like,
allowing the programmer to use one instruction in
place of many. -
- RISC (Reduced Instruction Set Computer)
- The benefits of RISC design simplicity are a
smaller chip, smaller pin count, and very low
power consumption.
11PIC16F84 Memory
-
- There are two memory blocks in the PIC16C84
- program memory and data memory.
- Each block has its own bus, so that access to
each can occur during the same clock cycle. -
- The data memory can be further broken down into
general purpose memory and special purpose
registers
12PIC16F84 Program Memory
13PIC16F84 Data Memory
(This is a simplified memory map that excludes
bank1. Study the memory banks in the Microchip
data sheets).
14PIC16F84 Register-Mapped I/O
When ports are configured as outputs, bits sent
to the PORTA and PORTB registers are
automatically output. When configured as inputs,
any received inputs affect the values of the
corresponding register contents. PORTA is 5
bits wide and PORTB is 8 bits wide. Each port
can be programmed as an input or an output.
(Bit 4 of port A can be used for an external
timer input.) PORTA has pins/bits labelled
RA4RA0 and PORTB has pins/bits labelled RB7RB0
Referencing bits . Bits are numbered 7-0 from
left to right, i.e., msb-lsb. One of the most
common programming errors is incorrect
specification of bit numbers.
15Using I/O Ports
- WRITTEN BY SIW
- DATE 01/01/2004
- FILE SAVED AS TEST.ASM
- DEVICE 16F84
- OSCILLATOR XT (4MHZ)
- WATCHDOG DISABLED
- FUNCTION OUTPUTS THE VALUE 0XF1 TO
8 LEDS CONNECTED TO PORTB - ----------------------- EQUATES
------------------------------------ - PORTB EQU 0X06 ASSIGN THE PORTB
REGISTER TO THE LABEL 'PORTB' - ----------------------- MAIN PROGRAM
------------------------------------ - START ORG 0X00 'ORG' SPECIFIES THE
MEMORY LOCATION OF THE PROGRAM - MOVLW 0X00 MOVE THE VALUE 00, I.E.,
ALL 0'S TO W - TRIS PORTB CONFIGURE PORTB WITH THE
VALUE IN W (THE - WORKING REGISTER)
1INPUT AND 0OUTPUT. - SO 00 (ALL 0'S) MAKES
ALL PORTB LINES OUTPUTS. - CLRF PORTB CLEAR THE PORTB REGISTER
- MOVLW 0XF1 MOVE THE HEX VALUE F1 TO
THE WORKING REGISTER - MOVWF PORTB OUTPUT THE VALUE TO
PORTB - LOOP GOTO LOOP
16Assembler Code Exercises
- What do these instructions do?
- At the start, the working register (W) contains
the value 5 and the PORTB register contains the
value 0. What values are in W and PORTB after
each instruction? - MOVLW 0X13
- ADDLW 0X28
- MOVWF PORTB
- INCF PORTB,1
- INCF PORTB,0
- BCF PORTB,2
- 2. The following equates assign the label F to
1 and W to 0. Why is this useful? - F EQU 1
- W EQU 0
-
- So we can write INCF PORTB,F instead of INCF
PORTB,1 - 3. Why is there no END instruction in the list
of PIC instructions? - Why does our example program end with LOOP
GOTO LOOP -