Microcontrollers Lecture L 11 2 Microcontrollers Microcontrollers vs

  • Slides: 35
Download presentation
Microcontrollers Lecture L 11. 2

Microcontrollers Lecture L 11. 2

Microcontrollers • • Microcontrollers vs. Microprocessors Two standard architectures PIC microcontroller 68 HC 12

Microcontrollers • • Microcontrollers vs. Microprocessors Two standard architectures PIC microcontroller 68 HC 12 Microcontroller BASIC Stamp Jstamp What’s the Difference

Microcontrollers • Microprocessor – Performs computing function for different architectures of memory, input/output ports,

Microcontrollers • Microprocessor – Performs computing function for different architectures of memory, input/output ports, devices, and communication ports • Microcontroller – Performs computing functions and contains onchip memory, input/output ports, devices, and communication ports. – Resources are limited

Microcontrollers

Microcontrollers

Microcontrollers • Desktop Computers – Different architectures/configurations of memory, devices, and ports – Microprocessor

Microcontrollers • Desktop Computers – Different architectures/configurations of memory, devices, and ports – Microprocessor is a general purpose computing machine • Embedded Systems – Includes coffee makers, burglar alarms, TV remote controls, simple robots, etc… – Easier to use a microcontroller with limited functionality and onchip resources • No need to select/design a board with memory, etc… • Ready to program

The PIC Microcontroller • Very common microcontroller • Made by Microchip Technology • Over

The PIC Microcontroller • Very common microcontroller • Made by Microchip Technology • Over 180 different microcontrollers • Available in different configurations of on-chip resources • Timers, Drivers for writing to Liquid Crystal Displays, USB and TCP/IP interfaces, temperature sensors, and more • Packaged in 8 - to 84 -pin configurations • Contains from 1 KB to 128 KB memory • Available in 8 and 16 bits

Microcontrollers • PIC controllers have a Harvard Architecture used for Desktop personal computers

Microcontrollers • PIC controllers have a Harvard Architecture used for Desktop personal computers

Microcontrollers • What do you think are some advantages/disadvantages of these architectures?

Microcontrollers • What do you think are some advantages/disadvantages of these architectures?

PIC

PIC

PIC 368 Bytes of Memory for Data 8 KB of Memory For Programs 14

PIC 368 Bytes of Memory for Data 8 KB of Memory For Programs 14 -bit program words

PIC Similar to Lab 10

PIC Similar to Lab 10

PIC The Instruction Set

PIC The Instruction Set

3 Types of instructions

3 Types of instructions

Byte-oriented instructions • ffff – the 7 -bit address for which location in the

Byte-oriented instructions • ffff – the 7 -bit address for which location in the register file (memory) contains the data of interest • d – if d = 0, then the answer will be stored in the W register, otherwise if d = 1, then the answer will be stored in the memory location selected by ffff.

Byte-oriented instructions If ADDWF is encoded as machine code: 000111 0 0001010 d =

Byte-oriented instructions If ADDWF is encoded as machine code: 000111 0 0001010 d = 0 memory location = 0 A Memory address d

Byte-oriented instructions If ADDWF is encoded as machine code: 000111 0 0001010 d =

Byte-oriented instructions If ADDWF is encoded as machine code: 000111 0 0001010 d = 0 memory location = 0 A OPCODE = 070 A W reg is added to RF[0 A] and the answer is placed in W reg

Byte-oriented instructions If ADDWF is encoded as machine code: 000111 1 0001010 d =

Byte-oriented instructions If ADDWF is encoded as machine code: 000111 1 0001010 d = 1 memory location = 0 A OPCODE = 078 A W reg is added to RF[0 A] and the answer is placed in RF[0 A]

Byte-oriented instructions For ADDWF, we have seen type machine codes: 070 A – add

Byte-oriented instructions For ADDWF, we have seen type machine codes: 070 A – add RF[0 A] to W reg and place answer in W reg 078 A – add RF[0 A] to W reg and place answer in RF[0 A] … and there are many more where that came from…

Bit-oriented instructions bbb – selects the bit that will be operated on ffffff –

Bit-oriented instructions bbb – selects the bit that will be operated on ffffff – selects the memory location of the data to be operated on For example, BCF encoded as the machine code: 0100 111 0001011 Memory address Bit #

Bit-oriented instructions bbb – selects the bit that will be operated on ffffff –

Bit-oriented instructions bbb – selects the bit that will be operated on ffffff – selects the memory location of the data to be operated on For example, BCF encoded as the machine code: 0100 111 0001011 OPCODE = 138 B Bit 7 (MSB) of the Byte in RF[0 B] is cleared to zero

Literal and Control instructions X – means don’t care K’s – the literal Literal

Literal and Control instructions X – means don’t care K’s – the literal Literal means ‘inline data’ like in the 8086 when we used MOV AX, 0 FFFF to move FFFF into AX, FFFF was the Literal or inline data.

Literal and Control instructions X – means don’t care K’s – the literal For

Literal and Control instructions X – means don’t care K’s – the literal For example, if ADDLW is encoded as machine code: 111110 00001111 Inline Data

Literal and Control instructions X – means don’t care K’s – the literal For

Literal and Control instructions X – means don’t care K’s – the literal For example, if ADDLW is encoded as machine code: 111110 00001111 OPCODE = 3 E 0 F 0 F is added to the value in W reg and the sum is put in W reg

Development Tools for PIC There is a Windows Development Environment for the PIC Controller

Development Tools for PIC There is a Windows Development Environment for the PIC Controller

BASIC Stamp • Based on 8 -bit PIC • 14 -pin microcontroller • Can

BASIC Stamp • Based on 8 -bit PIC • 14 -pin microcontroller • Can be programmed using the BASIC language – It has a BASIC language interpreter built-in

BASIC Stamp

BASIC Stamp

Online Interpreter • Most microcontrollers do not have a built-in interpreter of any kind

Online Interpreter • Most microcontrollers do not have a built-in interpreter of any kind • Usually source code written in higher level languages are compiled to a microcontrollers machine code • BASIC Stamp is inexpensive and easy to program for small applications

JStamp Directly executes Java bytecodes

JStamp Directly executes Java bytecodes

What’s the Difference • When selecting a microcontroller there are several factors that need

What’s the Difference • When selecting a microcontroller there are several factors that need to be considered • There are many microcontrollers available • Each brings advantages and disadvantages

Considerations • Cost – Prototype – Mass Production • Inputs – Correct # of

Considerations • Cost – Prototype – Mass Production • Inputs – Correct # of inputs – Digital / Analog

Considerations • Outputs – Correct # of Outputs – Digital / Analog • Processing

Considerations • Outputs – Correct # of Outputs – Digital / Analog • Processing Speed and Function – Adequate Computational Power – Upgrading a processor due to choosing the incorrect processor can be costly • Rework of written programs

Considerations • Memory – Programs – Data – Enough internal memory and/or can address

Considerations • Memory – Programs – Data – Enough internal memory and/or can address enough external memory • Ports – Correct ports for communicating with other devices • Parallel • Serial

Considerations • Support – Online Forums • Free source code • Frequently Asked Questions

Considerations • Support – Online Forums • Free source code • Frequently Asked Questions (FAQs) – Support from Vendor – Pre-developed software • Availability – Volumes – lead time

Considerations • Extensibility – Future growth – Avoid changing microcontrollers in future releases •

Considerations • Extensibility – Future growth – Avoid changing microcontrollers in future releases • Development Tools – Language (C / BASIC / Java) – Development Environment • Debugging

Considerations • Other technical requirements – Power Consumption • Portable applications – Operating Voltage

Considerations • Other technical requirements – Power Consumption • Portable applications – Operating Voltage • Compatible with other circuits