Design of embedded serial communication based on S3C2410

Publisher:幸福微风Latest update time:2021-05-26 Source: eefocusKeywords:S3C2410 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1S3C2410 Hardware Platform Introduction


S3C2410 is a new generation of high-performance microprocessor produced by Samsung, South Korea. It is a 16/32-bit RISC processor based on the ARM920T core. It is mainly used in embedded systems.


S3C2410 has powerful data processing capabilities, low cost, low power consumption and other advantages. It is increasingly widely used in various handheld and mobile devices, and the program functions based on its platform are becoming more and more complex. Therefore, building a multi-threaded operating system on its platform has become the demand of more and more system designers. This article introduces the specific implementation process of multi-threading on S3C2410.


2 System Structure Analysis


The essential function of the serial port is to act as a code converter between the CPU and the serial device. Generally, microcomputers are equipped with communication adapters, which enable the computer to communicate with other computers or devices with RS232C serial ports. The main purpose of this system is to achieve short-distance serial communication between the host and the target. The host is a Red Hat Linux 9.03 environment PC with Intel X86 architecture, and the target is an ARM architecture development board.


The core of the target machine development board in this system is Samsung's S3C2410. The development board adopts the mode of core board plus baseboard. The core board interface adopts DIMM200 standard connector. It works very reliably and can run stably at a clock frequency of 203 MHz. Its peripherals are very rich and powerful. It can fully meet the design needs. The serial port line adopts the commonly used RS 232C interface mode. It can realize data transmission and control between the computer and the development board.


3 System Hardware Structure Principle


Serial communication can be performed in DOS or Windows environment. Communication programs can be written in assembly or high-level language. This article introduces how to achieve serial communication under Linux operating system.


In the process of realizing serial communication, it is necessary to ensure the reliability and stability of data transmission. Its hardware design is indispensable. In this paper, the S3C2410 chip is selected as the core device. The S3C2410 chip is a 16/32-bit RISC processor of SAMSUNG. It adopts the ARM920T core, has two independent UART controllers and separate 16 kB instruction cache and 16 kB data cache. The highest baud rate supported by each controller can reach 230.4 kb/s. These characteristics of the S3C2410 chip provide a reliable guarantee for the realization of serial communication between the computer and the development board under the "nux operating system". The hardware structure principle of the embedded serial communication based on S3C2410 is shown in Figure 1.


In the host computer system, the serial communication program is written under the Linux operating system. It is downloaded to the target machine, i.e. the development board, through the JTAG interface module. Under the corresponding software control command, the data between the host and the target machine can be sent and received through the serial interface line. The power module in the target machine provides the normal voltage required for the development board system to work. Various data information can be displayed in time through the LCD display module. The operation of the target machine can also be controlled through the keyboard control module. The external memory module can be composed of FLASH or SDRAM. Of course, as a complete system, it must also be equipped with other peripheral circuits to ensure the normal operation of the system.


4 Software Implementation


The design of serial communication software is the key to the successful operation of the system. How to ensure the efficiency, reliability, real-time performance of communication and save system resources are the issues that designers are concerned about. Therefore, the definition of communication protocol, the structural design of software outsourcing, and the selection of program development tools are extremely important in system design. The development of the PC-side serial communication program is based on the object-oriented design method of the Windows environment. The development environment uses vc++. There are many implementation methods, and there are many literatures introducing this. I will not go into details here. For the serial communication program on the microcontroller side, there are literatures introducing the program framework based on assembly language, but there are few introductions to the C language implementation based on the hierarchical structure. The following will specifically introduce the design and implementation of the serial full-duplex communication program under the hierarchical structure framework in KeilC51.


4.1 Communication protocol port baud rate


There are two communication modes based on serial I=1: intermittent communication and asynchronous communication. This adopts asynchronous serial communication. During the communication process, the microcontroller should handle the following issues: (1) Identify the command. The PC transmits the command to the microcontroller. The microcontroller can identify different commands and perform different operations according to the content of different commands. (2) Identify the data. The microcontroller can identify the data attached to the command. The maximum number of bits of transmitted data is determined by the set buffer size. (3) Error handling. Including identifying invalid commands and handling communication errors. When the microcontroller receives a command that the system has not defined, or the received command does not conform to the pre-defined format. It should respond, report an error to the system and perform error handling. The error type number should be defined in advance. (4) Correct response. When the microcontroller system receives a message without communication error and in accordance with the communication protocol, it should perform the corresponding operation according to the received command and return the operation result to the PC, such as sending an "OK" message for confirmation.


Issues that the PC should handle: (1) Collecting data sent by the MCU, such as the status information of a device module; (2) Receiving the normal response and error response information of the MCU. If there is an error response information, it should be processed according to the error type. Since there may be multiple device modules to be controlled, the device modules can be uniformly addressed and unique 16-bit addresses can be set for different devices to distinguish them. In this way, when the PC and the MCU are transmitting data, both parties can identify the source of the data and the object to be controlled. Table 1 shows an example of the communication protocol format. It consists of a PC transmission command protocol and a MCU response protocol.



4.2 Layered Design of MCU Communication Software


The software development environment of the single-chip microcomputer system is Keil C51. Compared with assembly language, C language has obvious advantages in structure, readability and maintainability. It is more conducive to program transplantation and expansion. The serial port communication program adopts a layered structure. That is, the program is divided into physical layer, driver layer and application layer. The layered design has the following advantages: (1) The serial port program that communicates with the host supports concurrent reception and transmission (active transmission and passive query devices coexist), which is conducive to improving communication efficiency and real-time data processing. (2) When the single chip


When the machine has only one serial port and there are multiple device modules controlled by serial communication, the serial port must be expanded. In order to simplify the hardware, the simulated serial port must be implemented by software. Therefore, the system should have software implementation that supports I/O port simulated serial port operation. Standard serial I/O and simulated serial port are different in physical implementation, but a unified external package is used to improve the encapsulation and modularity of the program. (3) Prevent serial port operations from monopolizing CPU resources in the process and avoid the occurrence of phenomena such as missed detection of status information.


The main functions of the three-layer program and its implementation in C language are as follows:


(1) Driver layer: Also known as the abstract layer, this layer defines the basic operation structure of the serial port. Based on this structure, serial port designs in different modes are implemented, including serial port implementation in interrupt mode and serial port implementation in I/O port simulation mode. Although the underlying implementation of the two modes is different, the driver layer shields the physical details of different serial port operations and simplifies the application layer's operation of the serial port. The structure of the serial port is defined as follows:


typedef struct Serial


{ void (* pfSetBaudRate)(unsigned long baud_rate); //Set the serial port baud rate


void (*pfOpen)(void); //Serial port open


void (*pfClose)(void); //Serial port closed


unsigned (*pfGetChar)(unsigned char *c); //Get a number from the receive buffer


void (*pfPutChar)(unsigned char c); //Send a byte


void (*pfPutStr)(unsigned char *tmp_str, unsigned char tmp_len); //Send a string of numbers


}Cserial;


(2) Physical layer: In this layer, different physical operations are performed for different serial port entities, such as microcontroller serial port initialization, timer initialization in I/O simulated serial port mode, I/O interrupt initialization, etc. Its function is to provide support for different serial port operation modes. Different serial port entities are designed for the two different physical implementation methods of standard full-duplex serial port and simulated serial port (including internal execution of the underlying operations of each type of serial port and related basic external initialization operations). Different implementation methods bind different operation function pointers. The pointers point to different operations. The two serial port entities are encapsulated into a unified serial port basic class, making the program more versatile and extensible. In the physical layer, a circular FIFO double buffer queue is used to cache and read the received and sent data. The combination of the buffer circular FIFO operation mode and the reception and transmission of data in the interrupt mode ensures the reliability and real-time performance of data processing. Due to space limitations, the following only gives the sample code for the declaration of the buffer structure and related pointers:

[1] [2]
Keywords:S3C2410 Reference address:Design of embedded serial communication based on S3C2410

Previous article:Design of flexible DC transmission bridge arm controller based on Zynq7000
Next article:Necessary steps to get started with ARM embedded development

Recommended ReadingLatest update time:2024-11-15 12:55

Qt-embedded-linux-opensource-src-4.5.1 ported to mini2440 development board technical description
Friends who have used FriendlyArm know that the built-in interface design of FriendlyArm mini2440 is qt2, but now q4 is gradually becoming the mainstream. It is not easy to successfully transplant qt4 to mini2440. I also spent a lot of effort to complete such a project. Now I share my experience with you, hoping tha
[Microcontroller]
Some details of the differences between s3c2410 and s3c2440
Both socs are arm920, cpuid is 0x41129200, and many register settings are the same, but if you want to directly use the bootloader and kernel of 2410 on 2440, it will definitely go wrong. There are many articles like this on the Internet, most of which only mention macro aspects, such as camera driver, main frequency,
[Microcontroller]
VIVI transplantation based on S3C2410
Host: UBUNTU10.04LTS, cross toolchain: arm-linux-gcc 2.95, installation directory: /usr/local/arm/2.95.3/bin Target board: Edukit-III, S3c2410 daughter board Problem description: Since the LINUX version of Embest's Edukit-III experiment box is 2.4, and in view of the fact that the LINUX 2.6 kernel is more popular now,
[Microcontroller]
uboot porting process on ARM s3c2410
Overview u-boot is a bootloader program developed by the German DENX team for various embedded CPUs. The u-boot software currently under development can be obtained through CVS under LINUX. The current version number is: u-boot 1.0.2, see the definition in include/version.h. #cvs –dserver:anonymous@cvs.sourceforge.ne
[Microcontroller]
s3c2410 board.c analysis
Before introducing this function, we need to look at several data structures, which are several important data structures in u-boot: 1), gd_t This data structure stores the configuration information required by u-boot (I will temporarily call it the global information table), typedef struct global_data {     bd_t *bd;
[Microcontroller]
S3C2410A GPIO introduction and application
1. The concept of GPIO GPIO stands for General-Purpose Input/Output Ports. In embedded systems, it is often necessary to control many external devices or circuits with simple structures. Some of these devices need to be controlled by the CPU, and some need the CPU to provide input signals. GPIO is a general-purpose
[Microcontroller]
Getting Started with S3c2410 Bare Board Program---Flowing Light
I am new to arm, so I wrote a few small practice programs, recorded here. Includes: running water lamp, single button, pwm driven buzzer, serial port and PC communication Development board s3c2410, development environment realview + h-jtag Without further ado, let’s start the first program. The study of bare boa
[Microcontroller]
Analysis of the driver of s3c2410 touch screen under linux
The touch screen driver is in the /kernel/drivers/char/s3c2410-ts.c file. The driver must always have the following important data structures:  1. File_operations of the touch screen  static struct file_operations s3c2410_fops={     owner: THIS_MODULE,     open: s3c2410_ts_open,     read: s3c2410_ts_read,      release
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号