Professional Documents
Culture Documents
Lecture 4 - MicC-vs-CPU-PIC18
Lecture 4 - MicC-vs-CPU-PIC18
Microcontrollers
Lecture 4
Microcontrollers – types and features
1
Microprocessors vs Microcontrollers
• General-purpose microprocessors:
• Examples: (most famous)
• intel 8080 (very old….), 8086, 80x86, Pentium, i3, i5, i7, i9
• AMD (Athlon, Ryzen)
• These contain no RAM, no ROM, and no I/O ports on the chip itself.
• They do have Cache memory though
2
3
A Comparison
• A Microprocessor:
• Needs external RAM, ROM, and I/O ports …
• Advantage: enable the designer to decide on the amount of RAM, ROM, and I/O ports needed to fit the task at hand.
• Disadvantage: makes these systems bulkier and much more expensive
• A Microcontroller:
• Has a CPU (a microprocessor) + RAM, ROM, I/O ports, timers
• all embedded together on one chip;
• the designer cannot add any external memory, I/O, or timer to it.
• Good for applications in which cost and space are critical.
• In many applications, for example a TV remote control, there is no need for
4
Criteria for Choosing a microcontroller
• Meets computational needs efficiently and cost-effectively
• Available support (Software and hardware)
• Market availability
5
Meeting computational needs
• Speed. What is the highest speed (MIPS) that the microcontroller supports?
• Packaging. (important in terms of space, assembling, and prototyping the end product)
• What pin configuration it comes with? 40-pin DIP (dual inline package) QFP (quad flat package)? other?
• Power consumption. (important for battery-powered products)
• RAM and ROM (need is based on data to be processed: images? Sensors? ..
• I/O pins and timer
• Ease of upgrade
• Cost per unit
6
Software and hardware support
• Software development tools:
• IDE (integrated development environment)
• Efficient Compiler (some high level language like C)
• Language Debugger
• Assembler
• Simulator
7
Software and hardware support
• Hardware tools:
• Emulator
• Ready-to-use compatible peripherals and sensors (Wifi, USB-ready, …)
• FPGA- compatibility
• Technical support (by manufacturer or third party)
• Documentation! (manuals, architecture, …)
8
Main features of PIC
(Programmable Intelligent Computer)
(used to be Peripheral Interface Controller)
• All current models use flash memory for program storage
• Program memory and data memory are separated.
• Data memory is 8-bit, 16-bit, or 32-bit wide.
• Program instructions: 12, 14, 16, or 24 bits long.
• dsPIC models have instructions for digital signal processing functions
• Packaging: 6-pin SMD, 8-pin DIP chips up to 144-pin SMD chips,
9
SMD Packaging
(surface
mount
device)
QFP
(quad flat
pack)
DIP
(dual in-line
packaging)
10
Main features of PIC
(Programmable Intelligent Computer)
• I/O pins, ADC and DAC modules,
• communications ports such as UART, I2C, CAN, USB
• UART: universal asynchronous receiver-transmitter: hardware device for asynchronous serial
communication in which the data format and transmission speeds are configurable
• manufacturer supplies MPLABX (computer software for development), assemblers and
C/C++ compilers, ..
• Third party and some open-source tools are also available.
• Low cost, wide availability, large user base, extensive collection of application notes
• serial programming, and re-programmable flash-memory capability.
11
8-bit PIC
• 8-bit (works with 8 bit data bus)
• l0xxx, 12xxx, 14xxx, 16xxx, 17xxx, and 18xxx
• PIC18xxx family: highest performance among above 8-bit
• Available in 18-pin to 80-pin packages
• If the design requires smaller packaging, use a lower PIC family
12
13
Program Memory
• some PIC versions have OTP (one-time programmable)ROM
• PIC18 family has Flash Program Memory
• EEPROM (Electrically erasable programmable read-only-memory)
• 2MBytes program memory available for PIC18
14
Data Memory
(Data RAM)
• Up to 4096 (4K) Bytes in PIC18
• Divided into two parts:
• GPR (general purpose RAM)
• Used to read/write, data manipulation
• divided into banks of 256 bytes each
• SFR (Special Function Registers)
15
16
17
Registers
• Places inside the microcontroller to hold information temporarily
• Data to be processed (addition, logic operations, data transfer, …)
• Address locations pointing to the data
• Most registers here are 8-bit
• Data types are up to the programmer (signed, unsigned, logical, char, …)
MSB LSB
18
WREG
• Working Register WREG: most widely used inside PIC
• Usually in CPUs it is called “Accumulator”
• Performs all arithmetic and logic operations
19