Download presentation
Presentation is loading. Please wait.
Published byえいじろう いまいだ Modified over 5 years ago
1
Microprocessors and Programming Department of Mechatronics Engineering
Lecture 1 1 Microprocessors and Programming Dr. Kadir ERKAN Department of Mechatronics Engineering Fall : 2017 10/4/2019
2
What is a Microcontroller???
• Microprocessor: refers to LSI circuit implementation of a CPU • Microcomputer: microprocessor + memory + I/O • Microcontroller: Microcomputer on single chip 10/4/2019
3
Criteria for Choosing a Microcontroller
10/4/2019
4
Criteria for Choosing a Microcontroller
The main criteria in selecting a microcontroller are given below in the order of importance; A. System Requirement; Design should start with a blank sheet of paper specifying the application needs, if the system requires a single chip MCU or additional peripherals are to be used with it. Selection process starts with a decision of choosing either the 4-bit, 8-bit, 16-bit or 32-bit microcontroller required by the application.. To develop code for 4-bit architectures is harder and handling 4-bit instructions and data widths can limit arithmetic capabilities. Most of the embedded applications are implemented using 8-bit microcontroller as the technology has been around a long time and huge number of controllers is available in the market. B. Memory Architecture This is very important factor while designing any microcontroller based system. Three different types of memory play an important role in the selection process are program memory i.e. Flash, OTP, ROM and ROM less components, (b) Data memory i.e. on-chip SRAM or external SDRAM and (c) Non volatile Memory i.e. EEPROM or Flash. Whether the memory is on-chip or off-chip and how much the size is required may be a key factor defines cost of building the system and speed of operation. 10/4/2019
5
Criteria for Choosing a Microcontroller
C. Availability Before going to implement the system, the availability of the device should be checked. The criteria in choosing microcontroller is its ready availability in needed quantities both now and future. If sufficient quantities are available with bright future then no need to be worried about the failure of the project. D. Size If IC of 15 I/O pins is required to develop the system there is no need to use 40 pin IC with 32 I/O pins. In this way the size of the IC can be reduced and thus physical space required to implement the system is also reduced. So, physical size of IC may well be critical factor for specific applications. E. Compatibility The function of a system can be changed or upgraded by changing the software or replacing one IC with another one without incurring heavy additional cost. The new one will be pin compatible as well as function compatible. F. Functionality Testing To check the function of the implemented system correctly the function of the MCU should be checked within the test circuit designed earlier before going to develop the overall system 10/4/2019
6
Criteria for Choosing a Microcontroller
G. Power Management Most microcontrollers have the features of power down, idle & sleep modes and consideration needs to be given to maximize the use of intelligent power management systems to reduce power consumption. H. Manufacturer’s Track Record Manufacturers should ensure the stability, good performance, better throughput, Reliability; better Serviceability, software support, correctness, wide and timely availability of their products. For an example product of Intel, Freescale, Zilog, and Microchip Technology are stable, mature and single sourced. I. Manufacturer’s Support During the step by step implementation of the system if the design engineer faces any kind of problem he/she may communicate with the marketing/sales, field application engineers. The manufacturers should have some facilities like a help line, toll free number, fax number, after-sales support, sufficient knowledgeable and helpful expertise support personnel 10/4/2019
7
Criteria for Choosing a Microcontroller
J. Availability of Development Support Here the key consideration includes Assembler, Debugger, a code efficient C compiler, emulator, technical support. Trend towards programming in high level language like C is increasing day by day. This language allows using of some portability of code and libraries. This provides more practical consideration using different microcontroller family. Choosing the appropriate Hardware and software development tools is also important while selecting MCU. K. Cost This is the most important factor. If the system is to be implemented within the limit of the budget calculated earlier the cost of each and every component (selected MCU along with supporting ICs) used to build the system should be minimized tactfully to fulfill the requirements. On chip features will trade with inventory and assembly cost of using extra supporting external components. They can also cut development time and effort by providing a ready integrated solution. 10/4/2019
8
Criteria for Choosing a Microcontroller
Choosing a microcontroller from a number of different microcontrollers is a very critical decision for the designers. Three are the vital major criteria for selecting them. These are; wide availability and reliable sources (b) meeting the requirements efficiently and cost effectively (c) Availability of the software development tools like compilers, Assemblers and debuggers etc. The following steps should be followed during selection of the MCU. 10/4/2019
9
PIC Microcontrollers PIC:PERIPHERAL INTERFACE CONTROLLER (Çevresel arabirim denetleyicisi) dir. First PIC mC was released to the market in 1994 by the manufacturer MICROCHIP INC. PIC mCs were designed firstly to help and lighten pheripheral processing work of microprocessors… 10/4/2019
10
Why PIC Microcontroller
a-) Cost effective b-) high performance for arithmetic and as well as logic operations c-) quick access to data and program memory by using separate bus systems d-) the family of PIC microcontrollers includes 4-bit, 8-bit, 16-bit and 32-bit mC e-) availability of runnig in high clock frequencies g-) in sleep mode 1μA electrik current is required h-) primitive oscillator architecture is supoorted such as 2 cap. + 1 res. i-) high and low level progmmability; (C – Basic – JAL, … and PIC Assembly ) j-) based on Harvard arcthitecture by reduced instruction set… k-) MPLAB PIC assembly compiler is free of charge l-) from 6 to 80 pin I/O model is supported… 10/4/2019
11
Why PIC 16FXXX Microcontroller
10/4/2019
12
PIC 16FXXX Microcontroller
10/4/2019
13
PIC 16FXXX Microcontroller
Simplified internal block diagram of PIC 16FXXX mC; 10/4/2019
14
PIC 16FXXX Microcontroller
Simplified internal block diagram of PIC 16FXXX mC; Program Hafızası CPU Özel Amaçlı Kaydedici (SFR) VeriHafızası (RAM EEPROM) 8 BİT 13 BİT 14 BİT KOMUT PROGRAM ADRESİ KAYITÇI VERİ 10/4/2019
15
PIC 16FXXX Microcontroller
10/4/2019
16
PIC 16FXXX Microcontroller
There are three memory blocks in each of the PIC16F87XA devices. The program memory and data memory have separate buses so that concurrent access can occur. The PIC16F87XA devices have a 13-bit program counter capable of addressing an 8K word x 14 bit program memory space. The PIC16F876A/877A devices have 8K words x 14 bits of Flash program memory. The Reset vector is at 0000h and the interrupt vector is at 0004h. 10/4/2019
17
PIC 16FXXX Microcontroller
The data memory is partitioned into multiple banks which contain the General Purpose Registers and the Special Function Registers. Bits RP1 (Status<6>) and RP0 (Status<5>) are the bank select bits. Each bank extends up to 7Fh (128 bytes). The lower locations of each bank are reserved for the Special Function Registers. Above the Special Function Registers are General Purpose Registers, implemented as static RAM. All implemented banks contain Special Function Registers. Some frequently used Special Function Registers from one bank may be mirrored in another bank for code reduction and quicker access. 10/4/2019
18
PIC 16FXXX Microcontroller
General-Purpose Registers General-Purpose registers are used for storing temporary data and results created during operation. For example, if the program performs a counting (for example, counting products on the assembly line), it is necessary to have a register which stands for what we in everyday life call “sum”. Since the microcontroller is not creative at all, it is necessary to specify the address of some general purpose register and assign it a new function. A simple program to increment the value of this register by 1, after each product passes through a sensor, should be created. Therefore, the microcontroller can execute that program because it now knows what and where the sum which must be incremented is. Similarly to this simple example, each program variable must be preassigned some of general-purpose register. 10/4/2019
19
PIC 16FXXX Microcontroller
10/4/2019
20
PIC 16FXXX Microcontroller
SFR Registers Special-Function registers are also RAM memory locations, but unlike general-purpose registers, their purpose is predetermined during manufacturing process and cannot be changed. Since their bits are physically 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. For example, by changing the TRISA register, the function of each port A pin can be changed in a way it acts as input or output. Another feature of these memory locations is that they have their names (registers and their bits), which considerably facilitates program writing. Since high-level programming language can use the list of all registers with their exact addresses, it is enough to specify the register’s name in order to read or change its contents. The Special Function Registers can be classified into two sets: core (CPU) and peripheral. 10/4/2019
21
PIC 16FXXX Microcontroller
10/4/2019
22
PIC 16FXXX Microcontroller
10/4/2019
23
PIC 16FXXX Microcontroller
10/4/2019
24
PIC 16FXXX Microcontroller
Status Register The STATUS register contains: the arithmetic status of the W register, the RESET status and the bank select bits for data memory. One should be careful when writing a value to this register because if you do it wrong, the results may be different than expected. For example, if you try to clear all bits using the CLRF STATUS instruction, the result in the register will be 000xx1xx instead of the expected Such errors occur because some of the bits of this register are set or cleared according to the hardware as well as because the bits 3 and 4 are readable only. For these reasons, if it is required to change its content (for example, to change active bank), it is recommended to use only instructions which do not affect any Status bits (C, DC and Z). Refer to “Instruction Set Summary”. 10/4/2019
25
PIC 16FXXX Microcontroller
10/4/2019
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.