🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Module2_PIC_Architecture.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Embedded Systems Design PIC Architecture Dr. Bilal Arain Based on slides from Dr. Bassel Soudan Components for a typical control system What is a Microcontroller? A microcontroller is a single-chip system that contains: A simple processor. Memory to hold...

Embedded Systems Design PIC Architecture Dr. Bilal Arain Based on slides from Dr. Bassel Soudan Components for a typical control system What is a Microcontroller? A microcontroller is a single-chip system that contains: A simple processor. Memory to hold the data and the program. Input and Output interfaces. Timers. Internal and external interrupt handling mechanism. all integrated into a single chip. Block Diagram of a typical Microcontroller The microcontroller operates on data that is fed in through its serial or parallel input ports controlled by the software stored in the on-chip memory. Microcontroller It contains timers for time intervals Registers It contains counters to count events I/O It contains complex interrupt circuits to Memory Ports allow performing multiple tasks ALU in parallel Timing & Interrupt Counters Control Circuits Definition of a Microcontroller The microcontroller is a programmable device that receives values from sensors, performs simple arithmetic or logical operations according to the program and data stored in memory and then produces directives to the rest of the system as a result. Programmable Device Let's expand each of the underlined words: Programmable device: A microcontroller can perform different sets of operations on the data it receives depending on the sequence of instructions supplied in the given program. By changing the program, the microcontroller manipulates different types of data in different ways. Instructions: Each microcontroller is designed to execute a specific group of operations. This group of operations is called an instruction set. This instruction set defines what the microcontroller can and cannot do. PIC Microcontroller PIC microcontrollers can be classified into three major categories: 8-bit microcontrollers, 16-bit microcontrollers, and 32-bit microcontrollers. Each category is further subdivided into product families as shown in the following table: The PIC Microcontrollers The PIC Microcontrollers PIC10 through PIC14 families are considered low-end microcontrollers. PIC16 and PIC18 families are considered mid-level microcontrollers, while 16-bit and 32-bit PICs are considered high-end microcontrollers The majority of students and projects will require mid-level microcontrollers. The most popular PIC used in senior design projects is the PIC16F877. You need to understand what your application will need so you can choose the microcontroller with the proper features. Microcontroller Features Microcontrollers will have all or part of these features: – On-chip RAM – On-chip ROM – Special instructions (multiply, divide, etc.) – Internal / External interrupts – Counters – Timers – Analog comparator – Analog to digital converter – Digital to analog converter – Serial Communication – different protocols are available – USB connectivity – Capture/Compare PWM – LCD Driver The PIC16F877 The Microcontroller and Memory To reduce the physical size of the system, a microcontroller integrates a CPU and a “reasonable” amount of memory into the same chip. – The definition of “reasonable” depends on the application. Members of the 8051 microcontroller family have from 0K to 4K of memory on-chip. Members of the PIC microcontroller family have from 4K to 1M of memory on-chip. – Based on how large your program will be, you choose a microcontroller with the right amount of memory. The Microcontroller and the External Memory Some microcontrollers allow Other microcontroller designs interfacing external memory to don't have an interface for expand the memory space of the external memory microcontroller Limits the size of the program The PIC Microcontroller’s Memory Organization PIC Microcontrollers use a Harvard Architecture Von Neumann Architecture Fetches instructions and data from a single memory space Typical of microprocessors Harvard Architecture Uses two separate memory spaces for program instructions and data Typical of microcontrollers The PIC Microcontroller’s Memory Organization Memory on PIC microcontrollers is split into two types: Program Memory and Data Memory. Instructions are stored in program memory, which is non-volatile (contents are retained when power is lost). The PIC architecture can support up to 1M x 16 (2M bytes) of program memory. Data currently in use is kept in RAM data memory, also known as the file registers, which is volatile (contents are lost when power is lost). Some members of the PIC family may contain EEPROM data memory. Used for data that needs to be kept for a long time such as initialization values. EEPROM data memory is non-volatile. Memory Memory - RAM Memory – RAM - DRAM Memory – RAM - SRAM Memory - ROM Memory - PROM Memory - EPROM Memory - EEPROM Memory – Flash Memory Program Memory Program Memory Different members of the PIC family contain different amounts of program memory. – The PIC 16F873/16F874 contain 4K words of program memory – The PIC 16F876/16F877 contain 8K words of program memory So, choose the appropriate PIC family member that supports the size of your program. Keep in mind that program memory in the PIC is measured by “words”. – These are “instruction words” – Instruction words are: 12-bit wide for PIC12 series 14-bit wide for PIC16 series 16-bit wide for PIC17 and PIC18 series. Program memory (8K words) is divided into four 2k×14 pages Linear code execution crosses page boundaries The PIC16F877 without problems Page select bits need to Program be programmed when Memory jumping to code on a different page using “CALL” or “GOTO” instructions This is all taken care of when using high- level programming languages such as C/C++, etc. Data Memory PICs have a set of registers that function as general-purpose RAM. They are registers, but each of them has an address and the registers are accessed through this address. Data Memory Some PIC models have as few as 32 bytes of RAM while others can reach up to 4K bytes. – PIC16F877 has 512 bytes of internal RAM, divided into 4 banks. – Data memory is not expandable by external memory. While the PIC16 has a relatively large internal RAM, it is not all accessible at the same time. – Internal RAM in the PIC is broken down into “banks” – The number of banks and the number of registers in each bank depend on the PIC model. PIC 16 has 4 banks each of which containing 128 registers. PIC 18 has 16 banks each of which containing 256 registers. Data Memory RAM/Data Memory The contents of RAM are cleared when the power goes off. It consists of two parts: general-purpose registers and special-function registers (SFR). All these registers are divided into four memory banks, each 128 bytes 368 are general-purpose registers, and the remaining are special function registers or reserved. Data Memory Registers General-purpose registers are used for storing temporary data and results created during operation. Special-function registers are also RAM memory locations and their purpose is predetermined during manufacturing process and cannot be changed. Since SFR bits are connected to particular circuits on the chip (A/D converter, serial communication module, etc.), any change of their contents directly affects the operation of the microcontroller or some of its circuits. RAM Memory Banks The 512 bytes of internal RAM in the PIC 16 are broken down into 4 banks. Each bank contains 128 registers The address of the 1st register is 000H and that of the last register is 1FFH Two bits in the STATUS register determine the bank currently in use Special Function Registers The Special Function Registers are registers used by the CPU and peripheral modules for controlling the desired operation of the device. The Special Function Registers can be classified into two sets: Core (CPU) and, Peripheral. Special Function Registers Status Register Status Register Numbers Numbers A byte consists of eight bits grouped together. The greatest value has the leftmost bit called the most significant bit (MSB). The rightmost bit has the least value and is therefore called the least significant bit (LSB). Data Types Data Types BCD Representation Meanings of Data

Use Quizgecko on...
Browser
Browser