A single chip computer data reading method and system

By optimizing the MCU data reading through dynamic scheduling strategy and task queue mechanism, the problems of low data transmission efficiency and poor system stability are solved, and efficient and stable data processing and programming simplification are achieved.

CN119311434BActive Publication Date: 2025-09-30SANJUXING TECHNOLOGY (GUANGDONG) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410992237.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2025-09-30
Estimated Expiration
2044-07-23

AI Technical Summary

Technical Problem

When processing large amounts of data and complex data, existing single-chip microcomputer systems have low data transmission efficiency, poor system stability, high programming complexity, and frequent equipment failures caused by interface updates.

Method used

It adopts dynamic scheduling strategies and task queue mechanisms, optimizes data bus bandwidth and transmission protocols through API interfaces, adds cache and prefetching technologies, uses task queues for parallel processing based on priority tags, and accelerates data transmission through infrared remote controls and sensors.

Benefits of technology

It improves data processing capabilities and system response speed, reduces programming complexity, avoids frequent interrupt triggering, and ensures system stability and resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311434B_ABST
    Figure CN119311434B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of electronic information technology, and specifically relates to a single-chip computer data reading method and system. The method mainly includes the following steps: configuring the single-chip computer system and API interface, and ensuring smooth connection; adopting a dynamic scheduling strategy to read data and adopting an accelerated data transmission path, while adding cache and prefetching technology to predict and load the data to be accessed in advance, so that the data can be fully read and transmitted to the data processing end; adopting a task queue data processing mechanism to take out the data task with the highest priority from the queue, and temporarily storing the data processed by the data processing end in a memory or connecting to a display device. The present invention optimizes the data transmission path, introduces a hardware acceleration mechanism, improves data transmission efficiency and system stability, thereby reducing programming complexity and the possibility of errors.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of electronic information technology, and in particular relates to a single chip computer data reading method and system. Background Art

[0002] In the microcontroller system of electronic devices, the efficiency and stability of data reading are crucial. Currently, mainstream data reading solutions on the market, such as DMA and ISR, can meet basic needs, but their limitations are increasingly prominent when dealing with large amounts of data and complex data processing. Although the DMA method can achieve fast data transmission, it puts a heavy burden on the CPU when processing large amounts of data, reducing efficiency. Although the ISR method can respond in real time, it frequently interrupts when processing complex data, which can easily affect system stability. In addition, these methods often require developers to write cumbersome drivers and interrupt service routines, which not only increases the difficulty of programming but also increases the risk of errors.

[0003] Furthermore, MCUs are frequently updated and replaced. New generations often incorporate improvements to interfaces and other aspects, requiring corresponding modifications to the MCU's data reading methods. This can easily lead to malfunctions in the MCU within the device. Therefore, the present invention provides a more efficient and stable data reading method and system that optimizes interfaces, data transmission paths, and data processing mechanisms. Summary of the Invention

[0004] The present invention provides a single-chip computer data reading method and system, which are used to solve the technical problems of low data transmission efficiency, poor system stability and high programming complexity in existing single-chip computer systems.

[0005] In order to achieve the above object, the technical solution adopted by the present invention is as follows: A method for reading data from a single chip microcomputer comprises the following steps:

[0006] (1) Initialization: Configure the MCU system and API interface and ensure smooth connection. Write the MCU system program according to actual needs and call the API interface in the program to read and return data.

[0007] (2) Data reading, input, and transmission: Dynamic scheduling strategies are used to read data and accelerate data transmission paths, optimizing the bandwidth and transmission protocols of the data bus. Cache and prefetching technologies are also added to predict and load data that will be accessed in advance, thereby fully reading and transmitting the data to the data processing end.

[0008] (3) Data processing: A task queue data processing mechanism is adopted. First, a task queue is established to store data tasks to be processed. Each data task contains a priority tag to identify its urgency and importance. When a new data task arrives, the microcontroller system will place it in the corresponding position of the queue according to the priority tag, and then take out the data task with the highest priority from the queue and hand it over to a dedicated hardware processing unit for parallel processing.

[0009] (4) Data output: The data processed by the data processing terminal is temporarily stored in the memory or connected to the display device to ensure the integrity and continuity of the MCU system data.

[0010] Furthermore, the API interface implements data reading, task addition, task scheduling, and processing result acquisition through simple function calls. The specific process is as follows:

[0011] a. Task adding process:

[0012] 1) Receive task_data, priority and handler as input parameters;

[0013] 2) Create a new task object, including task_data, priority and handler, add the newly created task object to the task queue, and sort it according to priority;

[0014] 3) If the queue is full or reaches a certain limit, it is necessary to reject new tasks or wait for tasks in the queue to be completed before adding them. After the task is added, return or notify the caller;

[0015] b. Task scheduling process:

[0016] 1) Monitor system resource usage, CPU usage, and memory usage;

[0017] 2) Check the task queue and select the task with the highest priority that is suitable for the current system load;

[0018] 3) Call the handler function of the selected task to process the task data;

[0019] 4) During the processing, the system resources are continuously monitored. If the system load is too high, some tasks may need to be paused or delayed;

[0020] 5) When the task is completed, store the processing results;

[0021] 6) Repeat steps 2)-5) until the task queue is empty or a termination condition is reached;

[0022] c. Obtaining processing results:

[0023] 1) Receive task_id as input parameter;

[0024] 2) Find the processing result of the task corresponding to task_id;

[0025] 3) If the task has been completed and the processing result is available, a pointer to the processing result is returned;

[0026] 4) If the task is not completed or an error occurs, a null pointer is returned and additional error information may be provided;

[0027] d. Error handling process:

[0028] 1) Receive task_id and error_code as input parameters;

[0029] 2) Determine the type and cause of the error based on error_code;

[0030] 3) Record error information to facilitate subsequent analysis and debugging;

[0031] 4) Attempt to recover or retry the task. If recovery or retry is not possible, notify the user or system administrator.

[0032] 5) After processing is completed, return or notify the caller.

[0033] Furthermore, the error information includes recording error logs and recovering or retrying the task.

[0034] Furthermore, the specific process of implementing the dynamic scheduling strategy is as follows:

[0035] a. Label setting: First, determine the task type, including compute-intensive, I / O-intensive, and real-time. Then, assign one or more labels to each task. Labels are represented by a string consisting of numbers and / or letters, where each character or number segment represents a different attribute.

[0036] b. Weight calculation and priority setting: Define weight factors, including task type, source, and urgency. Calculate a weight value for each task based on the task tag and the defined weight factor. Sort all tasks in the task queue by weight value. Tasks with higher weight values ​​have higher priority.

[0037] c. Load determination: Monitor system resource usage in real time, including CPU usage, memory usage, and disk I / O. Set one or more load thresholds for each system resource. When resource usage exceeds these thresholds, the system is considered to be under high load. Based on the real-time monitoring data and the load thresholds, the current system load is assessed.

[0038] d. Load- and priority-based task scheduling: Before placing a task into a queue, the system determines whether to pre-process the task based on its priority and system load. This pre-processing includes splitting, merging, and delaying the task. During task processing, the system updates the status of the task queue based on task completion. The system maintains multiple task queues and assigns tasks to different queues based on their priority and system load. When the system is highly loaded, the system suspends processing of low-priority tasks or defers processing of some tasks until the load decreases.

[0039] e. Optimization and Adjustment: Based on the results of system monitoring, dynamically adjust the parameters of weight factors and load thresholds to optimize the scheduling strategy, allowing users or system administrators to adjust the priority and scheduling strategy of tasks through the interface or API interface to meet different needs.

[0040] Furthermore, the accelerated data transmission path uses an infrared remote controller, an infrared receiving sensor circuit and a single-chip microcomputer decoding software. The encoding methods of the infrared remote controller are mainly divided into two types: PWM (pulse width modulation) and PPM (pulse position modulation).

[0041] Furthermore, the cache stores the currently executing program and the data being accessed. When the program is running, the CPU accesses instructions and data directly from the cache without having to read them from the slow main memory. Prefetching predicts the data that the program may need next and loads it into the cache in advance, reducing the time the CPU waits for data to be read from the main memory.

[0042] Furthermore, the task queue is a first-in-first-out queue for data tasks to be processed, which includes a unique identifier of the task, task data, task priority, and processing function.

[0043] Furthermore, the task queue processing flow is as follows:

[0044] a. Task addition: When a new data task needs to be processed, it is encapsulated as a task object, and its priority is set according to its urgency and importance. The task object is then added to the end of the task queue.

[0045] b. Task scheduling: The task scheduler periodically obtains the highest priority task from the head of the task queue and passes it to the corresponding processing unit for processing;

[0046] c. Task processing: After receiving the task, the processing unit processes the data according to the processing function in the task. After the processing is completed, the task status is updated to completed and the task is removed from the task queue.

[0047] d. Concurrent processing: The task scheduler dynamically adjusts the number of concurrently processed tasks based on the system load and the capabilities of the processing unit;

[0048] e. Error handling: During the task processing, if an error or exception occurs, the processing unit will record the error information in the log, update the task status to error, and the task scheduler will reschedule the task for retry.

[0049] A system comprising a single-chip microcomputer data reading method comprises an initialization module, a data reading module, a data transmission module, a data output module, and a CPU control system, wherein the initialization module configures the single-chip microcomputer system and an API interface and ensures smooth connection, compiles a program for the single-chip microcomputer system according to actual needs, and calls the API interface in the program to read and return data; the data reading module adopts a dynamic scheduling strategy to read data, optimizes the bandwidth and transmission protocol of the data bus, and simultaneously incorporates cache and prefetching technology to predict and load data to be accessed in advance, thereby completely reading and transmitting the data to a data processing module; the data processing module adopts a task queue data processing mechanism, first establishing a task queue for storing data tasks to be processed, each data task including a priority tag for identifying its urgency and importance; when a new data task arrives, the single-chip microcomputer system places it in the corresponding position of the queue according to the priority tag, then removes the data task with the highest priority from the queue and hands it to a dedicated hardware processing unit for parallel processing; the data output module temporarily stores the data processed by the data processing module in a memory or connects it to a display device.

[0050] Furthermore, the initialization module, data reading module, data transmission module, and data output module are controlled by the CPU control system.

[0051] Compared with the prior art, the present invention has the following beneficial effects:

[0052] (1) The programming interface of the present invention adopts a function call method. Users can read and process data through simple function calls, which reduces the complexity of programming and enables users to achieve the required functions more easily.

[0053] (2) The present invention is based on a task queue-based data processing mechanism that dynamically adjusts task priorities and processing methods according to actual needs, effectively avoiding frequent interrupt triggering and reducing system instability. At the same time, because the hardware processing unit has a high parallel processing capability, it can quickly process a large number of data tasks, further improving the system's processing power and response speed.

[0054] (3) The present invention dynamically adjusts the processing order of tasks and the number of concurrently processed tasks according to the real-time load of the single-chip microcomputer system and the status of the task queue to achieve optimal system performance and resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 This is a diagram showing the data reading structure of the single chip microcomputer of the present invention;

[0056] Figure 2 This is a circuit diagram of the single chip microcomputer system of the present invention;

[0057] Figure 3 This is the circuit diagram of the single chip computer system display device of the present invention. DETAILED DESCRIPTION

[0058] The present invention will be described in detail below with reference to specific embodiments. The following examples will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those skilled in the art, several changes and improvements can be made without departing from the scope of the present invention. These all fall within the scope of protection of the present invention.

[0059] like Figure 1 As shown, a method for reading data from a single chip microcomputer includes the following steps:

[0060] (1) Initialization: Configure the MCU system and API interface, and ensure smooth connection. Write the MCU system program according to actual needs, and call the API interface in the program to read and return data. The MCU system circuit diagram is as follows: Figure 2 As shown:

[0061] The API interface provides an intuitive and easy-to-use way to manage data reading and processing tasks. Users do not need to worry about the complex underlying hardware acceleration mechanism or the implementation details of the task queue. They can read data, add tasks, schedule tasks, and obtain processing results through simple function calls. The specific interface design is as follows:

[0062] a. Task Add Function: This function adds a new data task to the task queue. The task data, priority, and processing function are specified by the user.

[0063] Function name: add_task

[0064] Parameters: task_data: pointer to task data, the type is defined according to specific requirements.

[0065] priority: The priority of the task, integer type. The larger the value, the higher the priority.

[0066] handler: A pointer to a task processing function that processes task data and returns the processing result.

[0067] b. Task Scheduling Function: This function is responsible for scheduling tasks from the task queue for processing. Users do not need to call this function directly; it will be automatically executed within the system.

[0068] Function name: schedule_tasks

[0069] c. Get processing result function: This function is used to obtain the processing result of a specified task. Users can query the processing status and processing result of a task through the unique identifier of the task.

[0070] Function name: get_result

[0071] Parameters: task_id: The unique identifier of the task, used to distinguish different tasks.

[0072] Return value: A pointer to the processing result. The type is defined according to specific requirements. If the task is not completed or an error occurs, a null pointer is returned.

[0073] d. Error handling function: This function is used to handle errors that occur during task execution. Users define error handling logic by implementing this function, such as recording error logs and rescheduling tasks.

[0074] Function name: handle_error

[0075] Parameters: task_id: The unique identifier of the task where the error occurred.

[0076] error_code: Error code, used to identify different types of errors.

[0077] The specific process is as follows:

[0078] a. Task adding process:

[0079] 1) Receive task_data, priority and handler as input parameters;

[0080] 2) Create a new task object, including task_data, priority and handler, add the newly created task object to the task queue, and sort it according to priority;

[0081] 3) If the queue is full or reaches a certain limit, it is necessary to reject new tasks or wait for tasks in the queue to be completed before adding them. After the task is added, return or notify the caller;

[0082] b. Task scheduling process:

[0083] 1) Monitor system resource usage, CPU usage, and memory usage;

[0084] 2) Check the task queue and select the task with the highest priority that is suitable for the current system load;

[0085] 3) Call the handler function of the selected task to process the task data;

[0086] 4) During the processing, the system resources are continuously monitored. If the system load is too high, some tasks may need to be paused or delayed;

[0087] 5) When the task is completed, store the processing results;

[0088] 6) Repeat steps 2)-5) until the task queue is empty or a termination condition is reached;

[0089] c. Obtaining processing results:

[0090] 1) Receive task_id as input parameter;

[0091] 2) Find the processing result of the task corresponding to task_id;

[0092] 3) If the task has been completed and the processing result is available, a pointer to the processing result is returned;

[0093] 4) If the task is not completed or an error occurs, a null pointer is returned and additional error information may be provided;

[0094] d. Error handling process:

[0095] 1) Receive task_id and error_code as input parameters;

[0096] 2) Determine the type and cause of the error based on error_code;

[0097] 3) Record error information to facilitate subsequent analysis and debugging;

[0098] 4) Attempt to recover or retry the task. If recovery or retry is not possible, notify the user or system administrator.

[0099] 5) After processing is completed, return or notify the caller.

[0100] (2) Data reading, input and transmission: Use dynamic scheduling strategies to read data and adopt accelerated data transmission paths, optimize the bandwidth and transmission protocol of the data bus, and add cache and prefetch technologies to predict and load data that will be accessed in advance, so that the data can be fully read and transmitted to the data processing end.

[0101] The dynamic scheduling strategy dynamically adjusts the order of task processing and the number of concurrently processed tasks based on the real-time system load and the status of the task queue to achieve optimal system performance and resource utilization. It can respond to changes in system load in real time, ensuring that high-priority tasks are processed in a timely manner while avoiding system overload and resource waste. The specific process is as follows:

[0102] a. Label settings:

[0103] Task classification: First, determine the type of task, including compute-intensive, I / O-intensive, real-time, etc.

[0104] Label generation: Assign one or more labels to each task, which are based on the task's type, source, urgency, etc. For example, a label is represented by a string consisting of numbers and / or letters, where each character or number segment represents a different attribute.

[0105] b. Weight calculation and priority setting:

[0106] Weight Factor: Define weight factors, including task type (computation-intensive tasks have higher weights), source (system tasks or user tasks), urgency (real-time tasks have higher weights), etc.

[0107] Weight calculation: Based on the task's label and the defined weight factor, a weight value is calculated for each task. This weight value will serve as the basis for task priority.

[0108] Priority sorting: Sort all tasks in the task queue according to their weight values. Tasks with higher weight values ​​have higher priorities.

[0109] c. Load condition determination:

[0110] Monitor resources: Real-time monitoring of system resource usage, including CPU usage, memory usage, disk I / O, etc.

[0111] Load threshold: Set one or more load thresholds for each system resource. When resource usage exceeds these thresholds, the system is considered to be in a high load state.

[0112] Load assessment: Evaluate the current load of the system based on real-time monitoring data and load thresholds.

[0113] d. Task scheduling based on load and priority:

[0114] Task preprocessing: Before placing a task into the queue, decide whether to preprocess the task (such as splitting, merging, delaying) based on the task priority and system load.

[0115] Queue management: Maintain multiple task queues, including high-priority queues, low-priority queues, delay queues, etc. Tasks are assigned to different queues based on their priority and system load.

[0116] Dynamic Scheduling: Dynamically adjusts the task scheduling strategy based on the system's real-time load and the state of the task queue. When the system is under high load, the processing of low-priority tasks is suspended, or some tasks are delayed until the load is reduced.

[0117] e. Optimization and adjustment:

[0118] Performance monitoring: Monitor the system's processing capacity and response speed in real time to evaluate the effectiveness of the current scheduling strategy.

[0119] Strategy adjustment: Based on the results of performance monitoring, dynamically adjust parameters such as weight factors and load thresholds to optimize the scheduling strategy.

[0120] Feedback mechanism: allows users or system administrators to adjust task priorities and scheduling strategies through the interface or API interface to meet different needs.

[0121] The accelerated data transmission path utilizes an infrared remote control, an infrared receiving sensor circuit, and microcontroller decoding software. The infrared remote control uses two main encoding methods: PWM (Pulse Width Modulation) and PPM (Pulse Position Modulation). The PWM method uses the duty cycle of the transmitted infrared carrier to represent "0" and "1." The infrared carrier is transmitted for a fixed period of time, and the duty cycle is changed by varying the period of inactivity. For example, a common TV remote control uses the NEC UPD6121. A "0" is a 0.56ms transmission of the carrier and a 0.56ms non-transmission; a "1" is a 0.56ms transmission of the carrier and a 1.68ms non-transmission. In addition, a pilot code is included to facilitate decoding. The total encoding length of the UPD6121 is 108ms.

[0122] The PPM method uses the position of the transmitted carrier to represent "0" and "1." The transition from transmitting the carrier to not transmitting the carrier is a "0," and the transition from not transmitting the carrier to transmitting the carrier is a "1." The duration of the carrier transmission and the duration of the carrier non-transmission are the same, 0.68ms, meaning each bit has a fixed duration.

[0123] Cache is a key storage component in a computer's memory hierarchy. Its operation is based on the principle of program and data locality: that is, within a short time interval, programs are concentrated in a smaller main memory address space, and data access also exhibits locality. The cache typically stores the currently executing program and the data being accessed. This allows the CPU to access instructions and data directly from the cache while the program is running, without having to read from slower main memory, significantly improving the CPU's program execution speed.

[0124] Prefetching is a technique used by the CPU to fetch instructions or data from slower memory into faster local caches before they are actually needed, thereby improving execution performance. Prefetching predicts the data that the program may need next and loads it into the cache in advance, reducing the time the CPU waits for data to be read from main memory and improving program execution efficiency.

[0125] (3) Data processing: A task queue data processing mechanism is adopted. First, a task queue is established to store data tasks to be processed. Each data task contains a priority tag to identify its urgency and importance. When a new data task arrives, the microcontroller system will place it in the corresponding position of the queue according to the priority tag, and then take out the data task with the highest priority from the queue and hand it over to a dedicated hardware processing unit for parallel processing.

[0126] A task queue is a first-in, first-out (FIFO) queue used to store and manage pending data tasks. Each data task is abstracted as a task object, which contains information such as the task's unique identifier (ID), task data, task priority, and processing function. The task queue is implemented using a linked list structure, where each node corresponds to a task object. The head (front) of the linked list points to the first task in the queue, and the tail (rear) of the linked list points to the last task in the queue. When a new task is added to the queue, it is added to the tail of the linked list; when a task is processed, it is removed from the head of the linked list.

[0127] The specific process of task processing is as follows:

[0128] a. Task addition: When a new data task needs to be processed, it is encapsulated as a task object, and its priority is set according to its urgency and importance. The task object is then added to the end of the task queue.

[0129] b. Task scheduling: The task scheduler periodically obtains the highest priority task from the head of the task queue and passes it to the corresponding processing unit for processing;

[0130] c. Task processing: After receiving the task, the processing unit processes the data according to the processing function in the task. After the processing is completed, the task status is updated to completed and the task is removed from the task queue;

[0131] d. Concurrent processing: The task scheduler dynamically adjusts the number of concurrently processed tasks based on the system load and the capabilities of the processing unit;

[0132] e. Error handling: During the task processing, if an error or exception occurs, the processing unit will record the error information in the log, update the task status to error, and the task scheduler will reschedule the task for retry.

[0133] The first-in-first-out (FIFO) nature of the task queue and its concurrent processing mechanism ensure that high-priority tasks are processed first, while fully utilizing system resources to improve data processing efficiency. This avoids frequent interruptions and improves system stability and reliability. Furthermore, the error handling mechanism ensures that errors are promptly processed and logged.

[0134] (4) Data output: The data processed by the data processing terminal is temporarily stored in the memory or connected to the display device to ensure the integrity and continuity of the single chip system data. The display device is an LED digital tube. Figure 3 The figure shows a 4-digit digital tube.

[0135] Specifically, when the above-mentioned single-chip microcomputer data reading method is applied to an electric tool, the API interface is replaced with an integrated infrared receiving head, where the OUT pin of the infrared receiving head is a signal output pin, which is connected to the REMOTE pin of the single-chip microcomputer system, so that the single-chip microcomputer system can decode and process the signal received by the infrared receiving head according to the above method.

[0136] A single-chip microcomputer data reading system comprises an initialization module, a data reading module, a data transmission module, a data output module, and a CPU control system. The initialization module configures the single-chip microcomputer system and an API interface and ensures smooth connection. The single-chip microcomputer system program is written according to actual needs, and the API interface is called in the program to realize data reading and returning. The data reading module adopts a dynamic scheduling strategy to read data, optimizes the bandwidth and transmission protocol of the data bus, and incorporates high-speed cache and prefetching technology to predict and load data to be accessed in advance, so that the data can be completely read and transmitted to the data processing module. The data processing module adopts a task queue data processing mechanism, first establishing a task queue for storing data tasks to be processed, each data task containing a priority tag for identifying its urgency and importance. When a new data task arrives, the single-chip microcomputer system will place it in the corresponding position of the queue according to the priority tag, then take out the data task with the highest priority from the queue and hand it over to a dedicated hardware processing unit for parallel processing. The data output module temporarily stores the data processed by the data processing module in a memory or connects it to a display device.

[0137] The initialization module, data reading module, data transmission module, and data output module are controlled by a CPU control system. The CPU control system of the present invention uses a dynamic scheduling strategy to dynamically adjust the number and allocation of concurrent processing units by real-time monitoring and evaluation of system load, task priority, and task queue status to achieve optimal task scheduling and resource utilization. It can also more flexibly respond to changes in system load, ensuring that important tasks are processed in a timely manner while avoiding system overload and resource waste.

[0138] The above describes specific embodiments of the present invention. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art may make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. The embodiments of this application and the features in the embodiments may be combined with each other in any manner unless there is a conflict.

Claims

1. A method for reading data from a single chip microcomputer, characterized in that: The following steps are involved: (1) Initialization: Configure the MCU system and API interface, ensure smooth connection, write the MCU system program according to actual needs, and call the API interface in the program to read and return data; (2) Data reading, input, and transmission: Dynamic scheduling strategies are used to read data and accelerate data transmission paths, optimizing the bandwidth and transmission protocols of the data bus. Cache and prefetching technologies are also added to predict and load data that will be accessed in advance, thereby fully reading and transmitting the data to the data processing end. (3) Data processing: A task queue data processing mechanism is used. First, a task queue is established to store data tasks to be processed. Each data task contains a priority tag to identify its urgency and importance. When a new data task arrives, the MCU system will place it in the corresponding position of the queue according to the priority tag, and then take out the data task with the highest priority from the queue and hand it over to a dedicated hardware processing unit for parallel processing. (4) Data output: The data processed by the data processing terminal is temporarily stored in a memory or connected to a display device to ensure the integrity and continuity of the data in the single-chip microcomputer system; The API interface implements data reading, task addition, task scheduling, and processing result acquisition through simple function calls. The specific process is as follows: a. Task adding process: 1) Receive task_data, priority and handler as input parameters; 2) Create a new task object, including task_data, priority and handler, add the newly created task object to the task queue, and sort it according to priority; 3) If the queue is full or reaches a certain limit, it is necessary to reject new tasks or wait for tasks in the queue to be completed before adding them. After the task is added, return or notify the caller; b. Task scheduling process: 1) Monitor system resource usage, CPU usage, and memory usage; 2) Check the task queue and select the task with the highest priority that is suitable for the current system load; 3) Call the handler function of the selected task to process the task data; 4) During the processing, the system resources are continuously monitored. If the system load is too high, some tasks may need to be paused or delayed; 5) When the task is completed, store the processing results; 6) Repeat steps 2)-5) until the task queue is empty or a termination condition is reached; c. Obtaining processing results: 1) Receive task_id as input parameter; 2) Find the processing result of the task corresponding to task_id; 3) If the task has been completed and the processing result is available, a pointer to the processing result is returned; 4) If the task is not completed or an error occurs, a null pointer is returned and additional error information may be provided; d. Error handling process: 1) Receive task_id and error_code as input parameters; 2) Determine the type and cause of the error based on error_code; 3) Record error information to facilitate subsequent analysis and debugging; 4) Attempt to recover or retry the task. If recovery or retry is not possible, notify the user or system administrator. 5) After processing is completed, return or notify the caller.

2. A method for reading data from a single chip microcomputer according to claim 1, characterized in that: Error information includes recording error logs and recovering or retrying tasks.

3. The method for reading data from a single chip microcomputer according to claim 1, wherein: The specific process of implementing the dynamic scheduling strategy is as follows: a. Label setting: First, determine the task type, including compute-intensive, I / O-intensive, and real-time. Then, assign one or more labels to each task. Labels are represented by a string consisting of numbers and / or letters, where each character or number segment represents a different attribute. b. Weight calculation and priority setting: Define weight factors, including task type, source, and urgency. Calculate a weight value for each task based on the task tag and the defined weight factor. Sort all tasks in the task queue by weight value. Tasks with higher weight values ​​have higher priority. c. Load determination: Monitor system resource usage in real time, including CPU usage, memory usage, and disk I / O. Set one or more load thresholds for each system resource. When resource usage exceeds these thresholds, the system is considered to be under high load. Based on the real-time monitoring data and the load thresholds, the current system load is assessed. d. Load- and priority-based task scheduling: Before placing a task into a queue, the system determines whether to pre-process the task based on its priority and system load. This pre-processing includes splitting, merging, and delaying the task. During task processing, the system updates the status of the task queue based on task completion. The system maintains multiple task queues and assigns tasks to different queues based on their priority and system load. When the system is highly loaded, the system suspends processing of low-priority tasks or defers processing of some tasks until the load decreases. e. Optimization and Adjustment: Based on the results of system monitoring, dynamically adjust the parameters of weight factors and load thresholds to optimize the scheduling strategy, allowing users or system administrators to adjust the priority and scheduling strategy of tasks through the interface or API interface to meet different needs.

4. A method for reading data from a single chip microcomputer according to claim 1, characterized in that: The accelerated data transmission path uses an infrared remote controller, an infrared receiving sensor circuit and a single-chip decoding software. The encoding methods of the infrared remote controller are mainly divided into two types: PWM (pulse width modulation) and PPM (pulse position modulation).

5. The method for reading data from a single chip microcomputer according to claim 1, wherein: The cache stores the currently executing program and the data being accessed. When the program is running, the CPU accesses instructions and data directly from the cache without having to read them from the slow main memory. Prefetching predicts the data that the program may need next and loads it into the cache in advance, reducing the time the CPU waits for data to be read from the main memory.

6. A method for reading data from a single chip microcomputer according to claim 1, characterized in that: The task queue is a first-in-first-out queue for data tasks to be processed, which contains the unique identifier of the task, task data, task priority and processing function.

7. A method for reading data from a single chip microcomputer according to claim 6, characterized in that: The task queue processing flow is as follows: a. Task addition: When a new data task needs to be processed, it is encapsulated as a task object, and its priority is set according to its urgency and importance. The task object is then added to the end of the task queue. b. Task scheduling: The task scheduler periodically obtains the highest priority task from the head of the task queue and passes it to the corresponding processing unit for processing; c. Task processing: After receiving the task, the processing unit processes the data according to the processing function in the task. After the processing is completed, the task status is updated to completed and the task is removed from the task queue; d. Concurrent processing: The task scheduler dynamically adjusts the number of concurrently processed tasks based on the system load and the capabilities of the processing unit; e. Error handling: During the task processing, if an error or exception occurs, the processing unit will record the error information in the log, update the task status to error, and the task scheduler will reschedule the task for retry.

8. A system for implementing the method for reading data from a single chip microcomputer according to any one of claims 1 to 7, characterized in that: It includes an initialization module, a data reading module, a data transmission module, a data output module, and a CPU control system. The initialization module configures the single-chip microcomputer system and the API interface and ensures a smooth connection. The single-chip microcomputer system program is written according to actual needs, and the API interface is called in the program to realize data reading and returning. The data reading module adopts a dynamic scheduling strategy to read data, optimizes the bandwidth and transmission protocol of the data bus, and adds cache and prefetching technology to predict and load the data to be accessed in advance, so that the data can be completely read and transmitted to the data processing module. The data processing module adopts a task queue data processing mechanism. First, a task queue is established to store data tasks to be processed. Each data task contains a priority tag to identify its urgency and importance. When a new data task arrives, the single-chip microcomputer system will put it into the corresponding position of the queue according to the priority tag, and then take out the data task with the highest priority from the queue and hand it over to a dedicated hardware processing unit for parallel processing. The data output module temporarily stores the data processed by the data processing module in a memory or connects it to a display device.

9. The system of the single chip computer data reading method according to claim 8, characterized in that: The initialization module, data reading module, data transmission module, and data output module are controlled by the CPU control system.

Citation Information

Patent Citations

  • Task scheduling processing method and device, computer equipment and storage medium

    CN112667376A

  • Implementation method of preemptive multi-task real-time operating system for miniature single-chip microcomputer

    CN113900787A