As the performance of hardware platforms in the embedded industry increases, project requirements and functions become increasingly complex. The CORTEX-M3 launched by ARM has made engineers who used to work on single-chip microcomputers face a dilemma in chip and technology selection. This topic will provide you with a reference from various aspects such as chip prices, hardware and software design of the entire system, and maintenance costs, and analyze the similarities and differences in software development between single-chip microcomputers and systems with operating systems from a technical perspective.
● 1. Price comparison between MCU and new processors such as ARM
● 2. The difference between software development with and without an operating system
● 2.1. Differences in driver development
● 2.2. Differences in application development
1. Price comparison between MCU and new processors such as ARM
Table 1
From the resources of various chips in Table 1, we can roughly guess their application scenarios. 51 MCUs are usually used for some relatively simple control, such as collecting signals and driving some switches. The Flash of AT89S51 is only 4K, and a slightly complex program will take more than 4K. SST89E564RD is an extended 51 MCU, its Flash reaches 64KB, and it can be connected to up to 64KB of SRAM. The program on SST89E564RD can be written more complex, but it also has fewer external interfaces.
The CORTEX-M3 series processors have extremely rich external interfaces, which makes it more widely used. However, due to its relatively small Flash and memory, operating systems are generally not run on it. It can be regarded as a microcontroller with very outstanding performance.
HI3510 is a chip used for monitoring equipment by HiSilicon Semiconductor. It usually runs Linux system, collects data through the camera, encodes it, and then transmits it through the network. After the other end receives the data, it decodes it. The program running on it is very complex, with beautiful picture interface, touch screen control, database, etc. The DSP core is used for the encoding and decoding of sound and image.
S3C2440 is a general-purpose chip. Compared with the "advanced single-chip microcomputer" STM32F103, it has more storage controllers and NAND controllers, which allows it to connect larger Flash and larger memory; it also has a memory management unit (MMU), which allows it to perform address mapping (mapping between virtual addresses and physical addresses). You can run Linux systems on S3C2440 and run larger and more complex programs.
In actual work, how do we choose these chips? In one word: cost! When developing any product, we must consider the cost performance. Everything should start from "cost". Cost includes not only the price of the chip, but also the hardware and software design and maintenance difficulty of the entire system.
You can ask about the chip price in the electronics market, or you can find a counter that sells this kind of chip on http://www.ic.net.cn and then make an inquiry by phone.
Based on different applications, the selection of processors and other peripherals must be considered uniformly. If you want to implement a simple USB read and write function, you can choose a CORTEX-M3 chip with a USB controller, or you can choose an 8051 with an external USB controller such as SL811, depending on which solution has a lower cost. When selecting a chip, you must consider it based on the entire system.
The employee's preference and knowledge structure are also very important factors. If he is familiar with ATMEL chips, he will not prefer Samsung. If he does not know operating systems such as Linux, he will not have the concept of operating systems when selecting. Choosing chips and technologies that he is not familiar with may also result in higher costs in the end.
2. The difference between software development with and without an operating system
In simple terms, a processing chip that does not run an operating system is called a single-chip microcomputer, and single-chip microcomputer programming is to write bare board programs, which run directly on the board; in contrast, the other type of program is an operating system-based program. To put it simply, this type of program can call "codes written by others" through a unified interface, and realize its own functions faster and more conveniently based on "other people's work."
2.1. Differences in driver development
I have summarized two differences in driver development: whether it can be borrowed and whether it is universal.
2.1.1 Can I borrow it?
There are a lot of software resources based on the operating system. When you want to write a Linux device driver, first look for it on the Internet. If it exists, use it directly. Then find something similar and modify it. If it doesn't exist, study the device manual and write it from scratch. Driver development without an operating system requires a deep understanding of the device manual, building a running environment for it from scratch, and implementing various functions for the application to use.
For example, to drive an LCD, the method on the microcontroller is:
① First, you need to understand the specifications of the LCD and figure out how to set each register, such as the LCD clock, resolution, and pixels.
② Allocate a piece of memory for LCD use
③ Write a function to draw points at specified coordinates. For example, find the small area corresponding to this pixel in this memory according to the x and y coordinates and fill in the data.
When based on the operating system, we first find similar drivers, figure out the driver structure, and find the places to modify and make modifications.
The following is the code for the microcontroller to operate the LCD:
① Initialization:
void Tft_Lcd_Init(int type)
{
/*
* Set the LCD controller's control registers LCDCON1~5
* 1. LCDCON1:
* Set the frequency of VCLK: VCLK (Hz) = HCLK/[(CLKVAL+1) x2]
* Select LCD type: TFT LCD
* Set display mode: 16BPP
* Disable LCD signal output first
* 2. LCDCON2/3/4:
* Set the time parameters of the control signal
* Set the resolution, i.e. the number of rows and columns
* Now, the display frequency can be calculated according to the formula:
* When HCLK=100MHz,
* Rate = 1/[{(VSPW+1)+(VBPD+1)+(LIINEVAL+1)+(VFPD+1)}x
* {(HSPW+1)+(HBPD+1)+(HFPD+1)+(HOZVAL+1)}x
* {2x(CLKVAL+1)/(HCLK)}]
* = 60Hz
* 3. LCDCON5:
* Data format when setting display mode to 16BPP: 5:6:5
* Set the polarity of HSYNC and VSYNC pulses (this needs to refer to the specific LCD interface signal): Invert
* Halfword (2-byte) swap enable
*/
LCDCON1 = (CLKVAL_TFT_320240《《8) | (LCDTYPE_TFT《《5) |
(BPPMODE_16BPP《《1) | (ENVID_DISABLE《《0);
LCDCON2 = (VBPD_320240《《24) | (LINEVAL_TFT_320240《《14) |
(VFPD_320240《《6) | (VSPW_320240);
LCDCON3 = (HBPD_320240《《19) | (HOZVAL_TFT_320240《《8) | (HFPD_320240);
LCDCON4 = HSPW_320240;
// LCDCON5 = (FORMAT8BPP_565《《11) | (HSYNC_INV《《9) | (VSYNC_INV《《8) |
// (HWSWP《《1);
LCDCON5 = (FORMAT8BPP_565《《11) | (HSYNC_INV《《9) | (VSYNC_INV《《8) | (VDEN_INV 《《 6) |
(HWSWP《《0);
/*
* Set the LCD controller address register LCDSADDR1~3
* The frame memory is exactly the same as the view point,
* The image data format is as follows:
* |----PAGEWIDTH----|
* y/x 0 1 2 239
* 0 rgb rgb rgb 。。。 rgb
* 1 rgb rgb rgb 。。。 rgb
* 1. LCDSADDR1:
* Set LCDBANK, LCDBASEU
* 2. LCDSADDR2:
* Set LCDBASEL: frame buffer end address A[21:1]
* 3. LCDSADDR3:
* OFFSIZE is equal to 0, PAGEWIDTH is equal to (240*2/2)
*/
LCDSADDR1 = ((LCDBUFFER》》22)《《21) | LOWER21BITS(LCDBUFFER》》1);
LCDSADDR2 = LOWER21BITS((LCDBUFFER+
(LINEVAL_TFT_320240+1)*(HOZVAL_TFT_320240+1)*2)》》1);
LCDSADDR3 = (0《《11) | (LCD_XSIZE_TFT_320240*2/2);
/* Disable temporary palette register */
TPAL = 0;
fb_base_addr = LCDBUFFER;
bpp = 16;
xsize = 320;
ysize = 240;
}
② Draw points:
/*
* Pixel size
* Input parameters:
* x, y: pixel coordinates
* color: color value
* For 16BPP: color is in the format 0xAARRGGBB (AA = transparency),
* Need to be converted to 5:6:5 format
* For 8BPP: color is the index value in the palette,
* Its color depends on the value in the palette
*/
void PutPixel(UINT32 x, UINT32 y, UINT32 color)
{
UINT8 red,green,blue;
switch (bpp){
case 16:
{
UINT16 *addr = (UINT16 *)fb_base_addr + (y * xsize + x);
red = (color 》》 19) & 0x1f;
green = (color 》》 10) & 0x3f;
blue = (color 》》 3) & 0x1f;
color = (red << 11) | (green << 5) | blue; // Format 5:6:5
*addr = (UINT16) color;
break;
}
case 8:
{
UINT8 *addr = (UINT8 *)fb_base_addr + (y * xsize + x);
*addr = (UINT8) color;
break;
}
default:
break;
}
}
Here are the changes in the Linux LCD driver (archarmmach-s3c2440mach-smdk2440.c):
/* 320x240 */
staTIc struct s3c2410fb_mach_info smdk2440_lcd_cfg __initdata = {
.right = {
.lcdcon1 = S3C2410_LCDCON1_TFT16BPP |
S3C2410_LCDCON1_TFT |
S3C2410_LCDCON1_CLKVAL(0x04),
.lcdcon2 = S3C2410_LCDCON2_VBPD(1) |
S3C2410_LCDCON2_LINEVAL(239) |
S3C2410_LCDCON2_VFPD(5) |
S3C2410_LCDCON2_VSPW(1),
.lcdcon3 = S3C2410_LCDCON3_HBPD(36) |
S3C2410_LCDCON3_HOZVAL(319) |
S3C2410_LCDCON3_HFPD(19),
.lcdcon4 = S3C2410_LCDCON4_MVAL(13) |
S3C2410_LCDCON4_HSPW(5),
.lcdcon5 = S3C2410_LCDCON5_FRM565 |
S3C2410_LCDCON5_INVVLINE |
S3C2410_LCDCON5_INVV |
S3C2410_LCDCON5_INVVDEN |
S3C2410_LCDCON5_PWREN |
S3C2410_LCDCON5_HWSWP,
},
.gpccon = 0xaaaa56aa,
.gpccon_mask = 0xffffffff,
.gpcup = 0xffffffff,
.gpcup_mask = 0xffffffff,
.gpdcon = 0xaaaaaaaa,
.gpdcon_mask = 0xffffffff,
.gpdup = 0xffffffff,
.gpdup_mask = 0xffffffff,
.fixed_syncs = 1,
.type = S3C2410_LCDCON1_TFT,
.width = 320,
.height = 240,
.xres = {
.min = 320,
.max = 320,
.defval = 320,
},
.yres = {
.max = 240,
.min = 240,
.defval = 240,
},
.bpp = {
.min = 16,
.max = 16,
.defval = 16,
},
};
This does not mean that Linux driver code is easier to write than MCU driver code. How to find the code to be modified among tens of thousands of files also requires hard learning. Driver development based on the operating system requires not only understanding the specific operation of the chip, but also understanding the software structure of the operating system.
Previous article:MCU, DSP, ARM learning method experience sharing
Next article:How to remotely update embedded systems? Common embedded operating systems
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- pic18F27Q10 eeprom erase problem
- 【BearPi-HM Micro】Part 4: Familiar with the Openharmomy compilation framework and serial port interactive output
- 50 ways to use TI CC6678 digital signal processor (DSP)
- Definition of Direct Current and Alternating Current
- [Reference Book] PCB Design Tips (ADI Think Tank)
- What is this device and what does it do?
- NeoPixel NanoRing
- How to optimize the area of FPGA design
- LED screen blanking technology
- Integer division problem