introduction
SPCE061A is a 16-bit single-chip microcomputer with u-class SP core newly launched by Lingyang Technology. SPCE061A with embedded 32K words of Flash is an economical choice for digital speech recognition applications. It supports a streamlined instruction system and has rich hardware resources on the chip. Only a small amount of off-chip expansion circuits need to be designed to achieve the hardware functional requirements of the application system. μC/OS-II is a streamlined operating system kernel with strong real-time performance and strong portability. Designing a system based on μC/OS-II can improve the efficiency of system software development. Porting μC/OS-II to SPCE061A and designing software on the μC/OS-II platform are of great significance in improving the quality of related embedded application system products, reducing development cycles and reducing costs.
Design of the minimum hardware system based on SPCE061A
System structure of SPCE061A
SPCE061A has rich on-chip system resources. The structure is shown in Figure 1. The chip includes:
·16-bit high performance USB core microcontroller
CPU clock range: 0.32MHz~49MHz
On-chip 32k words of Flash program memory, 2k words of SRAM data memory
· 2 16-bit I/O ports
14 interrupt sources
1 channel dedicated audio A/D conversion channel
7-channel A/D conversion channel
Built-in MIC amplifier circuit and automatic gain (AGC) amplifier circuit
·2-channel current output type D/A conversion channel
·2 16-bit general-purpose timers/counters
Real-time clock (RTC)
Low voltage reset, low voltage monitoring
Built-in online emulation interface (ICE)
·With confidentiality function
·With WatchDog function
Construction of the Minimum Application System Based on SPCE061A
Based on the rich on-chip resources of SPCE061A, a minimum system can be formed by connecting a 32768 Hz crystal oscillator and a resonant capacitor to its OSCO and OSCI terminals, connecting corresponding capacitors and resistors to the RC input VCP terminal of the phase-locked loop voltage-controlled oscillator, and adding a reset circuit. As shown in Figure 2. The peripheral circuit interface can be expanded to include an LCD display for real-time display of relevant data.
μC/OS-II transplantation on SPCE061A
Main contents of μC/OS-II kernel transplantation
μC/OS-II is a preemptive real-time multitasking operating system designed for microcontrollers and application software development. Its kernel mainly implements task scheduling, communication between tasks, memory management and time management. Its software architecture and its relationship with hardware are shown in Figure 3. The
multitasking application is located at the top layer, and it implements task scheduling and switching, storage management and communication of task processes by calling the kernel's API functions. Most of the code of μC/OS-II is written in C language, and the three source program files related to the hardware, OS_CPU.H, OS_CPU_A.A, and OS_CPU_C.C, contain assembly language codes related to the hardware processor to implement access to processor registers and stack operations. Therefore, the transplantation of the μC/OS-II operating system on SPCE061A mainly involves the writing of the three source programs OS_CPU.H, OS_CPU_A.A, and OS_CPU_C.C.
OS_CPU.H includes processor-related constants, macros and type definitions defined with #define. This is consistent with the variable types defined by μC/OS-II. OS_CPU_A.A requires the user to write four simple assembly functions: (1) The OSStartHighRdy() function is used to run the highest priority ready task. (2) OSCtxSw() is used to implement the switching between tasks during normal CPU operation, that is, to save the current task stack and pop the high priority task stack, so that the highest priority task can obtain the control of the CPU. (3) OSIntCtxSw() is a function that performs the task switching function in the interrupt service program. (4) OSTickISR() is the interrupt service program of the system clock. The execution frequency of this program is 10 to 100 Hz. Its main function is to check whether there is a task that has been suspended due to delay and becomes a ready task. If there is, OSIntCtxSw() is called to switch tasks, so as to run the high priority task. OS_CPU_C.C mainly writes the task stack initialization function OSTaskStklnit().
Key issues in transplantation
When a multi-task system is running, any currently running task seems to monopolize the CPU. It is necessary to open up a memory space for each task as the task stack of the task. The function of this stack is to save the values of the CPU registers and the data of the system stack before the task is switched. Since different processors have different internal register allocations and sometimes the stack grows in different ways, the key issue of porting is how to protect the status of registers when switching tasks for different processors, as well as the switching of the system stack and the task stack, so as to write a good software layer between the underlying hardware and the operating system. The Lingyang SPCE061A microcontroller has five general registers R1~R5, as well as the segment register SR and the program counter PC. There are a total of 7 CPU internal registers that need to be saved before the task is switched. The μC/OS-II system implements task switching by calling OSCtxSw().
Speech Recognition System Example
This system verifies the successful transplantation of μC/OS-II on SPCE061A by designing a speech recognition system. The system creates a total of 4 real-time tasks. The hardware implementation only requires adding corresponding audio circuits and LCD display modules to the minimum system.
//Create speech recognition initialization task
OSTaskCreate(Task1, (void * )0, (void*) tackl[-TASK—STK—SIZE-1], 1);
//Create a voice training task
OSTaskCreate(Task2, (void * )0, (void*) tack2[-TASK—STK—SIZE-1], 2);
//Create a speech recognition task
OSTaskCreate(Task3, (void * )0, (void*) tack3[-TASK—STK—SIZE—1], 3);
//LCD display task
OSTaskCreate(Task4, (void * )1, (void*) tack4[-TASK—STK—SIZE-1], 4);
At the same time, the signal quantity is used to realize the communication between the speech recognition task and the LCD display task, so that after the system successfully recognizes the speech, it can control the LCD to output the correct or incorrect information. System operation results: The system is initialized and the training function is called to perform speech recognition training; after the training is successful, the speech recognition loop is entered and the speech recognition results are displayed on the LCD.
Conclusion
The μC/OS-II operating system has strong real-time performance and a small amount of code (more than 8K in total). It has been ported to many processors. Porting μC/OS-II to the SPCE061A chip has certain application value, making the design of the application system based on SPCE061A more flexible. At the same time, the porting of the μC/OS-II real-time operating system to SPCE061A can not only improve the real-time performance, reliability and stability of the application system based on SPCE061A, but also improve the portability of the application software and reduce the R&D cycle.
References:
1. JEAN J, LABROSSE. uC/OS-II open source real-time embedded operating system [M]. Translated by Shao Beibei. Beijing: China Electric Power Press, 2001
2. Shao Beibei. Online Development Method for Embedded Microcontrollers[M]. Beijing: Tsinghua University Press, 2004
3. Ren Zhe. Principles and Applications of Embedded Real-time Operating System uC/OS-II [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 2005
4. Liu Haicheng, Qin Jinping, Han Xichun. Principles and Applications of MCU-DSP Microcontrollers [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 2006
Previous article:FPGA Design of Traffic Light Control Circuit
Next article:A brief discussion on the porting of μCOSII to the ARM processor based on the Cortex-M3 core
Recommended ReadingLatest update time:2024-11-16 20:36
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- 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
- MicroPython upgraded to v1.12
- I would like to ask, how is the transformer in a single-tube transformer-coupled amplifier magnetically reset?
- Sensor materials for learning at home: the hottest collection of EE sensor materials
- [RVB2601 Creative Application Development] Unboxing
- E103-W01-BF Unboxing and Brief Introduction
- SensorTile.box trial (unboxing and mobile APP connection)
- [Silicon Labs Development Kit Review] +Si7021 Temperature and Humidity Sensor Detection
- RISC-V RVB2601 first experience--Section 3--IO simulation serial port completed
- Talk to a VICOR engineer about your design and how to improve your AT equipment throughput and uptime.
- [HC32F460 Development Board Review] (Part 5) On-Chip Programmable Gain Amplifier (PGA) Review