What is PIC MCU? What are the advantages and disadvantages?

2021-11-29 17:02:29 hongling

PIC MCU was developed by microchip in 1993. Pic represents peripheral interface controller. Initially, it was developed to support PDP computer to control its peripheral devices, so it is called peripheral device interface device. Compared with other microcontrollers, these microcontrollers are very fast and easy to execute programs. PIC MCU architecture is based on Harvard architecture. PIC MCU is very popular because of its easy programming, high availability, easy interface transmission with other peripherals, low cost, huge user group and serial programming ability.

We know that MCU is an integrated chip, which is composed of CPU, ram, ROM, timer and counter. In the same way, PIC MCU architecture consists of ram, ROM, CPU, timer and counter, and supports such as SPI, can and UART for interfacing with other peripherals. At present, PIC MCU is widely used for industrial purposes because of its low power consumption, high performance and easy-to-use supporting hardware and software tools (such as compiler, debugger and simulator).

1、 What is PIC MCU?

Pic (programmable interface controller) single chip microcomputer is the smallest single chip microcomputer in the world. It can be programmed to perform various tasks. These microcontrollers can be found in many electronic devices, such as telephone, computer control system, alarm system, embedded system and so on.

Each PIC MCU architecture consists of some registers and stacks, in which the registers are used as random access memory (RAM), and the stack stores the return address. The main functions of PIC MCU are ram, flash memory, timer / counter, EEPROM, I / O port, USART, CCP (capture / compare / PWM module), SSP, comparator, ADC (analog-to-digital converter), PSP (parallel slave port), LCD and ICSP (online serial programming). According to the internal architecture, 8-bit PIC MCU is divided into four types, such as baseline pic, mid-range pic, Enhanced mid-range pic and PIC18.

2、 Architecture of PIC Single Chip Microcomputer

PIC MCU architecture includes CPU, I / O port, memory organization, a / D converter, timer / counter, interrupt, serial communication, oscillator and CCP module, which will be discussed in detail below.

What is PIC MCU? What are the advantages and disadvantages?


1. CPU (central processing unit)

It is no different from other MCU CPUs. PIC MCU CPU is composed of ALU, Cu, Mu and accumulator. Arithmetic logic unit is mainly used for arithmetic operation and logical decision-making. The memory is used to store processed instructions. In order to control the internal and external peripherals, a control unit connected to the CPU is used, and an accumulator is used to store the results and further processing.

2. Memory classification

The memory module in PIC MCU architecture is composed of RAM (random access memory), ROM (read only memory) and stack.

Random access memory (RAM)

Ram is an unstable memory used to temporarily store data in its registers. RAM memory is divided into two storage areas, each of which is composed of many registers. Ram registers are divided into two types: special function register (SFR) and general purpose register (GPR).

(1) General purpose register (GPR)

These registers are for general purposes only, as the name suggests. For example, if you want to use PIC MCU to multiply two numbers. Typically, we use registers to multiply numbers and store them in other registers. Therefore, these registers do not have any special functions, and the CPU can easily access the data in the registers.

(2) Special function register

These registers are for special purposes only, as the name SFR implies. These registers will be executed according to the functions assigned to them and cannot be used as ordinary registers. For example, if you cannot use status registers to store data, these registers are used to display the operation or status of the program. Therefore, the user cannot change the function of SFR.

(3) Read only memory (ROM)

Read only memory is a stable memory used to permanently store data. In the PIC microcontroller architecture, the architecture ROM stores instructions or programs according to the programs executed by the microcontroller. ROM is also called program memory, in which the user will write a program for the microcontroller and save it permanently. Finally, the program is executed by the CPU. The performance of the microcontroller depends on instructions, which are executed by the CPU.

(4) Electrically erasable programmable read only memory (EEPROM)

In the ordinary ROM, we can only write the program once, but can't use the single chip microcomputer many times. However, in EEPROM, we can program ROM many times.

(5) Flash flash

Flash memory is also a programmable read only memory (PROM), in which we can read, write and erase programs thousands of times. Usually, PIC MCU uses this type of ROM.

3. Stack

When an interrupt occurs, the PIC MCU must first execute the interrupt and the existing process address. The executing is then stored on the stack. After completing the execution of the interrupt, the MCU calls the process with the help of the address of the address stored in the stack and executes the process.

4. I / O port

The PIC16 series contains five ports, such as port a, port B, port C, port D and port E.

Port a is a 16 bit port that can be used as an input or output port according to the status of the trisa (TRADOC intelligence support activity) register.

Port B is an 8-bit port that can be used as input and output ports.

Port C is 8 bits, and the input of output operation is determined by the state of trisc register.

Port D is an 8-bit port used as a slave port connected to the microprocessor bus.

Port e is a 3-bit port used to provide additional functions of control signals to the analog-to-digital converter.

5. Bus

Bus is used to transfer data from one peripheral device to another. It is divided into two types, such as data bus and address.

PIC单片机总线


Data bus: only used to transmit or receive data.

Address bus: the address bus is used to transfer memory addresses from peripheral devices to the CPU. I / O pins are used to connect peripheral devices. UART and USART are serial communication protocols used to connect serial devices such as GSM, GPS, Bluetooth and IR.

6. A / D converter

The main purpose of the analog-to-digital converter is to convert analog voltage value into digital voltage value. The A / D module of PIC MCU consists of 5 inputs for 28 pin devices and 8 inputs for 40 pin devices. The operation of the analog-to-digital converter is controlled by adcon0 and adcon1 special registers. The high order of the converter is stored in register adresh, and the low order of the converter is stored in register adresl. For this purpose, an analog reference voltage of 5V is required.

7. Timer / counter

PIC MCU has four timers / counters. One 8-bit timer and the rest timers can choose 8-bit or 16 bit mode. Timers are used to generate precision actions, for example, to create a specific time delay between operations.

8. Interruption

PIC MCU contains 20 internal interrupts and three external interrupt sources, which are related to different peripherals such as ADC, USART, timer and so on.

9. Serial communication

Serial communication is a method of sequentially transmitting one bit of data at a time through the communication channel.

USART: name USART stands for universal synchronous and asynchronous receiver and transmitter. It is the serial communication of two protocols. It is used to send and receive data bit by bit through a wire relative to the clock pulse. PIC MCU has two pins TXD and RXD. These pins are used to send and receive data serially.

SPI protocol: the term SPI stands for serial peripheral interface. The protocol is used to send data between PIC MCU and other peripherals (such as SD card, sensor and shift register). PIC MCU supports three wire SPI communication between two devices on a common clock source. The data rate of SPI protocol is higher than that of USART.

I2C protocol: the term I2C stands for internal integrated circuit. It is a serial protocol used to connect low-speed devices, such as EEPROM, MCU, a / D converter, etc. PIC MCU supports two-wire interface or I2C communication between two, and can be used as the device of master device and slave device.

10. Oscillator

The oscillator is used to generate timing. PIC MCU is composed of external oscillator (such as RC oscillator or crystal oscillator). The crystal oscillator is connected between the two oscillator pins. The value of the capacitor is connected to each pin that determines the operating mode of the oscillator. These modes are crystal oscillator mode, high-speed mode and low-power mode. For RC oscillator, the values of resistance and capacitor determine the clock frequency, which ranges from 30kHz to 4MHz.

11. CCP module

The name of CCP module represents capture / compare / PWM, which operates in three modes, such as capture mode, comparison mode and PWM mode.

Capture mode: the capture mode captures the arrival time of the signal, or when the CCP pin changes to high level, it captures the value of Timer1.

Comparison mode: the comparison mode is used as an analog comparator. When the Timer1 value reaches a reference value, it will generate an output.

PWM mode: PWM mode provides pulse width modulation output with 10 bit resolution and programmable duty cycle.

Advantages of PIC single chip microcomputer:

(1) PIC MCU is consistent, and the error rate of PIC percentage is very low. Due to the use of RISC architecture, the performance of PIC MCU is very fast.

(2) Compared with other microcontrollers, the power consumption is very small and programming is very easy.

(3) Analog devices can be easily connected without any additional circuits.

Disadvantages of PIC single chip microcomputer:

(1) Due to the use of RISC architecture, the program is very long (35 instructions).

(2) There is an accumulator that cannot access the program memory.