S3C825A single chip microcomputer structure and software design

Publisher:谁与争锋1Latest update time:2011-09-05 Keywords:S3C825A Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Internal structure of S3C825A microcontroller

The internal structure block diagram of S3C825A is shown in Figure 1. From Figure 1, we can see that the microcontroller has the following features:

●Use SAM88RC as the central processing unit;

●With 48KB on-chip ROM and 2096byte register space;

●With up to 67 programmable I/O interfaces;

●Two 8-bit timer/counters and two 16-bit timer/counters;

●With LCD driver controller;

●With a 4-input 10-bit A/D converter;

●With master and slave crystal oscillator interfaces.


1.1 Storage Space Allocation

The S3C825A microcontroller has two types of storage space, 48KB internal mask programmable storage space (ROM) and 2096byte internal register space. The programmable storage space is mainly used to store program code and list data. Its starting 256Byte (00H0FFH) is used to store interrupt vector lists. Unused space can also be used as code storage space, but interrupt vectors must be placed in this space. For S3C825A, when the program executes RESET, the starting address of ROM is 0100H.

S3C825A has 2137 8-bit addressable registers, of which 13 bytes are used as CPU and system control registers, 60 bytes are used as interface control and data registers, 16 bytes are used as shared working registers, and the remaining 2048 bytes are used as general registers (including 32-byte LCD display registers). The internal registers of S3C825A are shown in Figure 2. Its internal register space is page-based management. The upper 64 bytes of each page are used as Set2 space, and the lower 192 bytes are used as main data register space, for a total of 7 pages (00H-1FH of the 7th page is the LCD display data register space). In addition, the extended 96 bytes can be used as Bank0 (64 bytes) and Bank1 (32 bytes) of Set1, which can be used as system control register space and working register space.

1.2 A/D Converter

S3C825A has a 4-input 10-bit analog/digital converter (A/D) integrated inside. The A/D converter can represent the analog level of each channel with a continuous approximate logic value, thereby obtaining an equivalent 10-bit digital level. The conversion process requires 50 clock cycles. The analog signal input port is multiplexed by P3.0"P3.2 of I/O Port3. The control register of Port3 (P3CONH, P3CONL) can determine whether Port3 is used for the analog signal input of the A/D converter. The control register of the A/D converter (ADCON) controls which channel of P3.0"P3.2 is used as the A/D input port. The analog level value of the input signal is required to be between AVREF and AVSS. The converted value is placed in the ADDATAH/ADDATAL register, and these two registers must be cleared before each conversion.

1.3 LCD Controller

S3C825A has an integrated LCD controller that can directly drive a 224-dot (28segX8com) LCD panel. In actual applications, you only need to store the data to be displayed in the LCD display register (700H-71FH), and then select the appropriate frame refresh frequency by configuring the LCD control register (LCON) and the LCD mode control register (LMOD). The LCD controller will automatically send the content to be displayed from the display register to the seg pin for display output without the need for other programming control.

2 S3C825A software development environment

2.1 In-circuit emulator OPENic i500

AIJIsysterm provides an effective online emulator for Samsung SAM8 series microcontrollers - OPENice i500. This emulator can run under Windows 95/98/2000/NT operating systems, has optional CPU clock resources (up to 80MHz) and up to 64kbyte of emulation code memory, and has a powerful built-in code editor. It can support high-speed code download based on RS232 (the maximum download speed can reach 115200b/s), and supports C language compilation/debugging (IAREW, CSPY). Therefore, the application of this emulator is very convenient.

The simulator can greatly improve the efficiency of program debugging and development.

2.2 SAM8 Development Environment

The commonly used development software for SAM8 series microcontrollers is the integrated development environment based on IAR Embedded Wordbench provided by IAR. This development system integrates IAR C compiler, assembler, connector, code editor, project manager and C-SPY debugger. It can edit, assemble and compile assembly language and C language source files, and the assembler and C program can share the same format of header files. It is a powerful development environment. This integrated development platform (IDE) can perform project management, run property setting, code editing and debugging under Windows 98/ME/NT4/2000/XP. The internal IAR C language encoder is powerful and can support ISO/ANSI standard C language compilation, and has a variety of code size and compilation speed modes and optional stack mode. In addition, it also supports SAM8 extended keywords and supports mixed program compilation of C language and assembly language.

The start environment is integrated with a relocatable macro assembler based on a general instruction set, and has an embedded C language preprocessor that can accept all C language macro definitions. The integrated IAR XLINK connector supports flexible code segment and data segment relocation, and can assemble several relocatable code module files required by applications into a program based on the information provided by the relocation module, thereby generating executable target code. In addition, the C-SPY debugger in the environment has a variety of test and analysis functions, supports single-step debugging, controls the program to run to a specified location (Go to Cursor/Go to Label/Go to Address), debug returns (Go to Return), real-time tracking of variables, registers (Register Groups), memory (Memory), etc., which greatly improve development efficiency.

3 Software Design for Hybrid Programming

In the process of software development for SAM8 series microcontrollers, programming in C language has the advantages of short development cycle, strong readability, good portability and convenient modification, but the assembly code generated by disassembling C program is often long. If you program directly in assembly language, although the compiled program is shorter, the development cycle is long and it is not convenient to modify. Therefore, a better solution is to write the framework or main part of the program in C language, and write the part with higher execution efficiency requirements in assembly language. The following mainly introduces the software design method for mixed programming for SAM8 series microcontrollers.

3.1 IAR C compiler function parameter transmission rules

IAR C language compiler specifies two ways to pass function parameters, namely register passing and stack passing. The order of passing is from left to right, and the specific way to pass depends on the type of function parameters.

IAR C language compiler divides the registers of the microcontroller into two groups. The function parameters in the high-speed register group (R10-R15) are passed from left to right to R15 to R10 in sequence until these registers are full, and the remaining function parameters are passed through the stack. Because these registers are temporary registers, they are released after use, so they do not need to be protected during the application process. The second group is ordinary registers (R1, R4-R9). This group of registers is mainly used as register variables and to save intermediate variables. It does not need to be protected during the application process, but it can be not reflected in the C language function writing, and it is automatically completed by the compiler.

When the function parameters are of the following two types, the stack method should be used for passing: The first is when the parameter is a struct or union parameter type larger than 4 bytes. The second is when the parameter is an unnamed parameter type of a variable-length function.

Function parameters are usually placed in the main memory starting at the position specified by the stack pointer, and the parameters of the called function are stored in the specified stack from left to right. When the called function returns to the calling function, the stack is automatically cleared and the main memory space is released for use by the passing function next time.

The function return value can be placed in R15 or R15:R14 register pair according to its type. If the return value is a struct or union type, the value returned in R15 is the starting position of the stack pointer for storing the return result.

The C language compiler will also automatically protect the registers used (including R10-R15) when compiling the interrupt function. The protection of the status register FLAGS is also automatically completed during the interrupt processing. The registers used in the interrupt process are protected by the PUSH Rn instruction and restored by the POP Rn instruction. When the status register FLAGS is automatically restored by the IRET instruction, you can return from the interrupt.

3.2 Conventions for Assembly Language Functions

For an assembler to be called by a C language function, the following three points must be met when using it:

1) Comply with the C language parameter passing rules;

2) There is a PUBLIC function entry flag;

3) Use extern in C language function to indicate external function.

The rules for passing parameters are the same as those for C language functions. The only difference is that they must be specifically reflected in the process of writing assembly language functions.

4 Application Examples

With the above calling rules clarified, mixed programming is easier, which can be summarized as follows:

1) Use the "extern" keyword in the C language source file to import the label exported by the assembly language source file;

2) Use the "PUBLIC" keyword in the assembly language source file to export the label to the C language source file;

3) Use the "EXTERN" keyword in assembly language to import keywords exported by the C language function source file;

4) Use C language to export the label to assembly language. This step does not require keywords;

5) Import the edited C language and assembly language source files into the design system, and call them using the respective function calling instructions.

The following is a detailed explanation using two examples that I used in the design of tuners.

4.1 Calling between C language and assembly language

In this example, the C language function main() calls the assembly language function get_rand() to get a random number. Then, the assembly language function get_rand() calls the C language library function rand() to get another integer random number. The C language function mult() is then called to multiply the high bit of this random value by the actual parameter passed to the main() function, and the product value is returned to the main() parameter.

4.2 Writing Interrupt Service Routine in Assembly Language

In order to improve the system response speed, the design often requires the interrupt service program to have a shorter execution time and faster execution speed. Therefore, the best way is to write the interrupt service program in assembly language. However, pay attention to the following two points:

1) The interrupt function does not pass parameters or return results;

2) All registers used during the interrupt process must be protected.

In this example, the interrupt service routine of the watchdog timer is written in assembly language, while the main program is written in C language.

5 Conclusion

The above method has been applied to the design of the tuner that I participated in designing and achieved good results. However, it should also be noted that the setting of compiler options during debugging has a certain impact on the program running results. Therefore, for different cores in the SAM8 system, different kernel version numbers must be selected, otherwise, the parameters passed by the registers may be misplaced, resulting in parameter passing errors and inconvenience in debugging.

Keywords:S3C825A Reference address:S3C825A single chip microcomputer structure and software design

Previous article:IC card device driver module code
Next article:PCF2111CT Character LCD Driver Module

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号