microcontrollers
DESCRIPTION
Microcontrollers. Lecture L12.2 Section 12.2. Microcontrollers. Microcontrollers vs. Microprocessors Two standard architectures PIC microcontroller 68HC12 Microcontroller BASIC Stamp Jstamp What’s the Difference. Microcontrollers. Microprocessor - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/1.jpg)
Microcontrollers
Lecture L12.2
Section 12.2
![Page 2: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/2.jpg)
Microcontrollers
• Microcontrollers vs. Microprocessors
• Two standard architectures
• PIC microcontroller
• 68HC12 Microcontroller
• BASIC Stamp
• Jstamp
• What’s the Difference
![Page 3: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/3.jpg)
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
![Page 4: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/4.jpg)
Microcontrollers
CPU
GeneralPurpose
Microprocessor
Single Chip
RAM ROMI/OPort
TimerSerialCOMPort
Data Bus
Address Bus
CPU RAM ROM
I/O TimerSerialCOMPort
Single Chip
(a) General Purpose Microprocessor System
(b) Microcontroller
![Page 5: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/5.jpg)
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
![Page 6: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/6.jpg)
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
![Page 7: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/7.jpg)
Microcontrollers
• PIC controllers have a Harvard Architecture
DataMemory
CPUProgramMemory
CPU
ProgramandData
Memory
Harvard von-Neumann
Architecture used forDesktop personal computers
![Page 8: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/8.jpg)
Microcontrollers
• What do you think are some advantages/disadvantages of these architectures?
DataMemory
CPUProgramMemory
CPU
ProgramandData
Memory
Harvard von-Neumann
![Page 9: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/9.jpg)
PIC
![Page 10: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/10.jpg)
PIC
368 Bytes of Memory forData
8 KB of MemoryFor Programs
14-bit programwords
![Page 11: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/11.jpg)
PIC
Similar to Lab 10
![Page 12: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/12.jpg)
PIC
TheInstruction
Set
![Page 13: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/13.jpg)
3Types of
instructions
![Page 14: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/14.jpg)
Byte-oriented instructions
• fff 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 fff ffff.
![Page 15: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/15.jpg)
Byte-oriented instructions
If ADDWF is encoded as machine code:000111 0 0001010 d = 0 memory location = 0A
d
Memory address
![Page 16: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/16.jpg)
Byte-oriented instructions
If ADDWF is encoded as machine code:000111 0 0001010 d = 0 memory location = 0A
W reg is added to RF[0A] and the answer is placed in W reg
OPCODE = 070A
![Page 17: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/17.jpg)
Byte-oriented instructions
If ADDWF is encoded as machine code:000111 1 0001010 d = 1 memory location = 0A
W reg is added to RF[0A] and the answer is placed in RF[0A]
OPCODE = 078A
![Page 18: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/18.jpg)
Byte-oriented instructions
For ADDWF, we have seen type machine codes:
070A – add RF[0A] to W reg and place answer in W reg078A – add RF[0A] to W reg and place answer in RF[0A]
… and there are many more where that came from…
![Page 19: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/19.jpg)
Bit-oriented instructions
bbb – selects the bit that will be operated onffffff – selects the memory location of the data to be operated on
For example, BCF encoded as the machine code:
0100 111 0001011
Bit #
Memory address
![Page 20: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/20.jpg)
Bit-oriented instructions
bbb – selects the bit that will be operated onffffff – selects the memory location of the data to be operated on
For example, BCF encoded as the machine code:
0100 111 0001011
Bit 7 (MSB) of the Byte in RF[0B] is cleared to zero
OPCODE = 138B
![Page 21: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/21.jpg)
Literal and Control instructions
X – means don’t careK’s – the literal
Literal means ‘inline data’ like in the 8086 when we usedMOV AX, 0FFFF to move FFFF into AX, FFFF was theLiteral or inline data.
![Page 22: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/22.jpg)
Literal and Control instructions
X – means don’t careK’s – the literal
For example, if ADDLW is encoded as machine code:
111110 00001111
Inline Data
![Page 23: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/23.jpg)
Literal and Control instructions
X – means don’t careK’s – the literal
For example, if ADDLW is encoded as machine code:
111110 00001111
0F is added to the value in W reg and the sum is put in W reg
OPCODE = 3E0F
![Page 24: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/24.jpg)
Development Tools for PIC
There is a WindowsDevelopmentEnvironmentfor the PICController
![Page 25: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/25.jpg)
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
![Page 26: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/26.jpg)
BASIC Stamp
![Page 27: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/27.jpg)
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
![Page 28: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/28.jpg)
JStamp
Directly executes Java bytecodes
![Page 29: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/29.jpg)
JStamp
RAM
JSTAMPCPU
FLASHRAM
DUALUARTS SPI
JSTAMP
TIMERS
![Page 30: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/30.jpg)
The Java Processing Core
32-bitALU
MuxMux
Mux
Shifter
Shifter
Instr. Reg
Mux
RegisterFile
Data Reg
DATA
ADDRESS
ProcessorBus
![Page 31: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/31.jpg)
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
![Page 32: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/32.jpg)
Considerations
• Cost– Prototype– Mass Production
• Inputs– Correct # of inputs– Digital / Analog
![Page 33: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/33.jpg)
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
![Page 34: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/34.jpg)
Considerations
• Memory– Programs
– Data
– Enough internal memory and/or can address enough external memory
• Ports– Correct ports for communicating with other devices
• Parallel
• Serial
![Page 35: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/35.jpg)
Considerations
• Support– Online Forums
• Free source code
• Frequently Asked Questions (FAQs)
– Support from Vendor– Pre-developed software
• Availability– Volumes – lead time
![Page 36: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/36.jpg)
Considerations
• Extensibility– Future growth– Avoid changing microcontrollers in future
releases
• Development Tools– Language (C / BASIC / Java)– Development Environment
• Debugging
![Page 37: Microcontrollers](https://reader035.vdocuments.net/reader035/viewer/2022062421/56812ada550346895d8ec078/html5/thumbnails/37.jpg)
Considerations
• Other technical requirements– Power Consumption
• Portable applications
– Operating Voltage• Compatible with other circuits