Copyright statement: This article is the original article for the blogger, without permission may not be reproduced.
The author will explain how to master the system programming and SOC programming from the angle of the system design of the chip IC. The author has more than 10 years of experience in embedded and R & D, as an architect repeatedly led based on nucleus ARM/MIPS/51 multimedia SOC R & D and production case, in the high-end processor system programming and embedded Linux has a wealth of teaching experience, I hope this series of articles can give embedded learning practitioners and profound guidance.
First, the boundaries and scope of system programming
Embedded developers often from the simplest to 51 microcontroller programming, and slowly exposed to as pic, AVR, STM32 series or types of controller, and may steering program of Samsung s5pv210, Exynos4412 and other high-end processor.
Developers in the development process is understanding the types of controller or processor corresponding to the instruction set and the datasheet, followed by simple routines to start programming, and the most common module is GPIO interrupt and timer. After exposure to a variety of types of processor programming, we may have a summary of the question:
After the header files include a representative of the types of IC register map. Some series chip control programming may is exactly the same, and different series of chip control programming is also similar, only different is that register different names. This is why?
To answer these questions, we must understand the system programming category, clear boundary system programming. To deeply understand the system programming, we need to design a system from the point of view of the chip to understand the development of the chip, you can refer to the author before writing the "integrated circuit design and division of labor".
One of the points is very important, is that we want to understand the relationship between the CPU core and SOC. This world has R & D capability of SOC (system on chip SOC (system on chip), many, many, to the famous apple and Samsung, small to Shenzhen those little-known but very profitable chip design companies are belong to the ranks. And core CPU, around the world, and can design CPU IP core just a few, such as the Intel x86, arm, ARM core, MIPs MIPS core, 51 kernel also a. Here to illustrate a point, no Chinese, the state although key support integrated circuit, but directors know the smashing showering is useless, really the first integrated circuit package technology and development up again. Now the Android intelligent machines are based on the ARM core, want to know who is the father of ARM? Not long ago, the master Furber Steve made a lecture at Guangdong University of Technology:
SOC is according to market demand and function positioning, in a type of CPU core based on the integration of various common peripheral controller module, such as in front of the GPIO, int and timer, and some special controller module, such as TI's single Bluetooth chip cc2541 integration of Bluetooth baseband and RF controller. The relationship between SOC and CPU is shown below:
System programming is obviously for the architecture of the programming, and the carrier is the system CPU. Therefore, CC2541, 89C51 and so are 51 system programming, and ATJ213X, PIC32 are based on the MIPS system programming, and S5PV210 and S3C2440 are ARM system programming. For the same CPU nuclear design company, it has no reason to own the CPU nuclear design into different styles, the same company different CPU processor series should follow the same architecture. So, what is the category of architecture? Is the red part of the image above, including the design of the CPU core and the timing and control of the bus. And CPU core and subdivided Cu (control unit) and PU (arithmetic unit), Cu and disjunctive means, decoding, access to the register, write back unit stores etc. pipeline operation and advanced CPU generally will be integrated co processing. Therefore, the system architecture programming generally includes the following:
(1) instruction set (addressing, Computing), assembly pseudo instruction
2) pipeline, instruction prefetching and jump rules. In pipelined mode, instruction prefetch the currently executing instructions following N instructions, so PC and perform address is not consistent, so if there is an interruption, abnormal return address to determine how.
(3) Co processing (MMU virtual memory, cache cache)
(4) register usage and parameter transfer specification (ABI). How to solve the register level of the C language to achieve the parameter transfer. Please refer to my previous blog post.C/ compilation of mixed programming interface ABI --MIPS"
5) the exception / interrupt (hardware interrupt, general exceptions, instruction in interrupt), int management above all hardware interrupts, such as serial port, timer and external interrupt and all the interrupt pin or after being sent to the CPU interrupt signal. Therefore, for CPU, when the interrupt occurs, it does not know which module has been interrupted, only the INT module to know.
6) debugging specification
7) bus specification. For programmers, it does not need to be too concerned about the bus specification. But it is an important criterion for SOC chip design. It specifies the timing and arbitration of the bus and the specification of the arbitration and the storage mode (Von Neumann or Harvard architecture).
For a CPU core design company, and it will provide two things to the SOC chip design company, is the system design specifications, such as instruction ARMV7 describes the execution of each instruction pseudo code process (the pseudo code for the hardware language, such as HDL); another kind of things is specific Series CPU design specifications, and implemented in the standard CPU IP core (IP core) for RTL level register circuit.
So, for the same system under the different series, their differences in where?
For example, arm development direction now is a series of cortex mainly for high-end consumer class electronics, such as mobile phones, tablet, cortex r mainly for high requirements of real-time military, aviation and other occasions, the cortex M series is to seize the low-end controller market, such as STM32, stm8 and so on. The system is the arm architecture, but the process, power consumption, performance is not the same, and CPU core integrated is not the same, such as M series and no integrated cache, quite a series, M series of MMU is a simplified version.
System programming is embedded architects and operating system developers need to master, for the general developers are less exposed to. The above analysis is based on the analysis of the theoretical level. And SOC programming is for the majority of ordinary developers, will be from the perspective of system design to guide you how to SOC programming.
Two, the scope and definition of SOC programming
SOC programming is on chip integrated module register control program. In the development of practice, we tend to SOC programming and system programming is called the system programming. It doesn't matter, as long as we understand the relationship between them.
So what is the scope of SOC programming?
1) general control module, such as CLOCK, GPIO, INT, TIMER, UART, etc..
2) special control module, such as LCD, Bluetooth, encoding and decoding, etc..
Some modules do not need to connect peripheral devices can be connected to the peripheral functions, such as TIMER, most of the modules need to connect peripheral devices through the pin to complete the function. Are integrated on chip and therefore the control portion of the module, such as LCD controller, the control circuit achieve LCD driver (peripheral) data transmission timing, signal line, column signal and setting interface. Change an angle to said, if there is no LCD controller, we also like to through the GPIO to simulate the timing of the LCD driver, but to do so, for ordinary developers too complex, the CPU is a heavy burden. So the system designer will implement the proprietary control circuit for the LCD drive.
So what do we do with SOC programming for the LCD controller? At the very least, we need to give the LCD controller an identity, let it start or close, how to give this signal? The LCD controller circuit is nothing more than a bunch of sequential circuits and combinational logic circuit, startup and shutdown can be represented with a signal input, and the signal in the CPU view can be mapped into a register one bit. Therefore, SOC programming is for register programming. For LCD control programming, of course, not only a register so simple, because for a SoC vendor. It is expected to LCD driver compatible with the market more compatible with different resolution and image depth, so it will certainly have different register to set it up.
From the point of view of teaching, system programming and SOC programming is divided into five levels:
1) system instruction set, such as ARM instruction set
2) a specific series of CPU codes, such as the CortexA8 kernel based on the ARM system
3) SOC level, the bus bus based on CPU core integration timer, interrupt, clock, GPIO and other controllers, such as Samsung's S5PV210 and OMAP3430 TI are based on A8 Cortex core.
4) board level circuit, such as development board, mobile phone board circuit, the circuit diagram of the SOC pin and peripheral equipment will be clearly connected. Such as A GPIO's first pin connected to the LED0, it is necessary to control the GPIOA0 to control the LED0 programming.
5) peripheral equipment specifications, said board level circuit diagram of all peripheral equipment specifications, such as the specific SPEC LCD (size, resolution, delay parameters, etc.).
The author to SOC programming process definition is: control mechanism based on 1) and 2) instruction set, and CPU bus, according to the characteristic parameters of specific peripheral equipment 5) and 4) specific circuit connection of 3) SOC corresponding control module registers programming, to achieve the purpose of the control, use.
Three, SOC design and programming
Understanding SOC system design can greatly help programming, each SOC control routines are given by the SOC system designers, because they also need to be programmed to test and verify the function of the SOC chip.
In addition, we need to understand a point of view, for different system, the same module design is basically the same, or it can be said, from the programming point of view, integrated module design process control is not about architecture (both for more is on the bus control, and the with the programmer is not linked to. Therefore, based on the LCD controller and the LCD controller based on the MIPS system, the design of the ARM controller is consistent, and the GPIO control of different systems is also consistent. Although the underlying register circuit may not be the same, but for the upper programming staff, the two are consistent, the difference may be just the name of the register. For example, 51 single-chip microcomputer and arm processor GPIO are input registers, output registers, the direction of the register, the drop in the register and so on.
Below to CLOCK and GPIO as an example of SOC programming, as far as possible to extract common design and control process.
1 minimum system
In addition to the minimum system after CPU and RAM, another important component is the crystal. SOC or CPU in the final analysis is a pile of combinational logic circuit and the sequential circuits and sequential circuits need clock to work properly, and crystal oscillator provides clock, the after power on continuous clock generation.
The low-end microcontroller and no clock control module, the direct use of crystal (such as the 12m or 24m), namely the working frequency of the CPU is 12m or 24MHz. But as a senior processor, the main frequency of its support to achieve 1G or higher. And market and there is no 1g crystal. Therefore, SOC is bound to realize FM, PLL frequency doubling technology is widely used in the processor clock module, which is will crystal oscillator frequency is doubled improve. CLOCK module in addition to achieve frequency multiplication control, but also need to consider such a demand:
1) SOC integrated modules, the working frequency of the various modules is not to do the same, or is in different levels, such as the working frequency of the CPU and GPU, RAM in G, the working frequency of the LCD is about 100m, video encoding and decoding the working frequency of 100 m level, and like GPIO, serial port of these modules work frequency can be 10m level. Therefore, CLOCK also need to carry out frequency division. Therefore, the CLOCK module is a general approach to the classification module, and a frequency division. For example, the CLOCK S5PV210 will be divided into three frequency range, M domain supply CPU, LCD, JPEG, D, HDMI,,,,,, P, and other peripheral equipment supply GPIO, UART and so on. Each domain is given a frequency (which can be adjusted by the controller).
2) for the module in the same domain, its operating frequency is not the same, so it is allowed to divide two stages.
Therefore, for a high-level processor integration of the module programming, set the CLOCK source frequency is the first step in the relevant register. General level division by the operating system developers set, two frequency division set by the development of the module is responsible for the.
3 pin multiplexing
Chip packaging is an important part of the cost of the chip and package involves multiplexed pins and chip package also involves the BOM cost of the final product, so the reuse of the pin in the system design is a key technology, SOC IC companies in the top secret technology. As efficient as possible, pin multiplexing is critical.
What are we going to do with the programmer? That is to remember that each pin may be a function reuse pin, in the use of this pin, the pin must be set before the function. Pin is generally the default GPIO function, if we want to use the pin for serial port or LCD and other control functions, we must set the function register corresponding to the pin. This is the second step in SOC programming.
CLOCK and pin function settings are applicable for all modules.
Here we have to talk about the generic module GPIO. For GPIO programming, we should be very familiar with, that is, it must be with input data registers, output data registers, input and output high resistance state setting register, on the drop set. The general process is:
1) set up the drop - down register
2) set the direction of pin
3) through the input data register to read data or write data to the output data register.
Remember function pin settings are also needed. Some advanced SOC may also have a drive capability level set register, which controls the drive strength of the pin.
Please refer to the author's blog.Both software and hardware are highly abstract to life.On interrupt control (ARMSystem programming".
The author before the teaching to A8 S5PV210 based on cortex as an example, the time to sort out the SOC of the various modules of the programming method.
More embedded Linux and Internet of things technology development original share please pay attention to micro channel public number: embedded Penguin circle
- step on
- Guess you're looking for