Single-chip microcomputer data reading method and system

Through dynamic scheduling strategies and task queue mechanisms, the microcontroller data reading method is optimized, and the problems of low efficiency and poor stability in the existing technology are solved, efficient and stable data processing and programming simplification are achieved, and microcontroller interface updates are adapted to microcontroller interface updates.

CN119311434AActive Publication Date: 2025-01-14SANJUXING TECHNOLOGY (GUANGDONG) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The existing microcontroller data reading methods are low in efficiency, poor stability when processing large data volumes and complex data, and have high programming complexity, making it difficult to adapt to system failures caused by microcontroller interface updates.

Method used

Adopt dynamic scheduling strategy and task queue mechanism to realize data reading and processing through API interface, optimize data transmission paths, add cache and prefetch technology, dynamically adjust task priority and processing methods, and use infrared remote control and cache to accelerate data transmission.

Benefits of technology

It improves data reading efficiency and system stability, reduces programming complexity, avoids frequent interrupt triggering, improves system processing capabilities and response speed, and dynamically adjusts task scheduling strategies to adapt to load changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311434A_ABST
    Figure CN119311434A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of electronic information, and particularly relates to a single-chip microcomputer data reading method and system. The method mainly comprises the following steps: configuring a single-chip microcomputer system and an API interface, and ensuring smooth connection; a dynamic scheduling strategy is adopted to read the data, an accelerated data transmission path is adopted, meanwhile, a high-speed cache and prefetching technology is added, and the data to be accessed is predicted and loaded in advance, so that the data is completely read and transmitted to a data processing end; a data processing mechanism of a task queue is adopted, a data task with the highest priority is taken out from the queue, and data processed by a data processing end is temporarily stored in a memory or connected to a display device. According to the method, a data transmission path is optimized, a hardware acceleration mechanism is introduced, the data transmission efficiency and the system stability are improved, and therefore the programming complexity and the error possibility are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The 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 single-chip microcomputer system of electronic equipment, the efficiency and stability of data reading are crucial. At present, the 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, the CPU is burdened with heavy workloads and reduced efficiency when processing large amounts of data. Although the ISR method can respond in real time, it is frequently interrupted 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] In addition, the single-chip microcomputer is updated very quickly. When a new generation of single-chip microcomputer is launched, the interface and other aspects are usually improved, resulting in the need for corresponding modifications to the data reading method of the single-chip microcomputer, which easily leads to failure of the single-chip microcomputer in the device. Therefore, the present invention provides a more efficient and stable data reading method and system, which can optimize the interface, data transmission path and data processing mechanism. 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 of the existing single chip computer system.

[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, comprising the following steps: (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; (2) Data reading, input and transmission: Dynamic scheduling strategies are used to read data and accelerated data transmission paths are adopted to optimize the bandwidth and transmission protocol of the data bus. At the same time, cache and prefetch technologies are added 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 end. (3) Data processing: A task queue is used for data processing. 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 places it in the corresponding position of the queue according to the priority tag, then takes out the data task with the highest priority from the queue and hands it over to a dedicated hardware processing unit for parallel processing.

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

[0007] Furthermore, the API interface implements data reading, task adding, task scheduling and processing result acquisition through simple function calls, and 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 and 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 certain termination condition is reached; c. Obtain processing result process: 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) Try 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.

[0008] Furthermore, the error information includes recording error logs and recovering or retrying tasks.

[0009] Furthermore, the specific process of implementing the dynamic scheduling strategy is as follows: a. Label setting: First, determine the type of task, including computation-intensive, I / O-intensive, and real-time. Then assign one or more labels to each task, using a string of numbers and / or letters to represent the label, 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 label and the defined weight factor. Sort all tasks in the task queue by weight value. Tasks with higher weight values ​​have higher priorities. c. Load determination: Real-time monitoring of system resource usage, including CPU usage, memory usage, and disk I / O. One or more load thresholds are set for each system resource. When resource usage exceeds these thresholds, the system is considered to be in a high-load state. Based on the real-time monitoring data and load thresholds, the current system load is evaluated; d. Task scheduling based on load and priority: Before placing a task into a queue, decide whether to pre-process the task based on the priority of the task and the load of the system. The pre-processing includes splitting, merging and delaying. During the task processing, update the status of the task queue based on the completion of the task, maintain multiple task queues, and assign tasks to different queues based on the priority of the task and the load of the system. When the system is in a high-load state, suspend the processing of low-priority tasks, or delay some tasks until the load is reduced; e. Optimization and adjustment: According to 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.

[0010] 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).

[0011] Furthermore, the cache stores the currently executing program and the data being accessed. When the program is running, the CPU directly accesses instructions and data 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.

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

[0013] Furthermore, 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 the priority is set for it according to the urgency and importance of the task, and then the task object is 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.

[0014] 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.

[0015] A system including a single-chip computer 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 a single-chip computer system and an API interface, ensures smooth connection, writes the single-chip computer system program according to actual needs, and calls the API interface 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 simultaneously adds a cache and pre-fetching technology to predict and load the data to be accessed in advance, so as to read the data completely and transmit it to a data processing module; the data processing module adopts a task queue data processing mechanism, first establishes a task queue for storing data tasks to be processed, and each of the data tasks includes a priority tag for identifying its urgency and importance; when a new data task arrives, the single-chip computer system puts it into the corresponding position of the queue according to the priority tag, then takes out the data task with the highest priority from the queue, and hands it over to a special 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.

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

[0017] Compared with the prior art, the present invention has the following beneficial effects: (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.

[0018] (2) The present invention is based on a data processing mechanism based on a task queue, dynamically adjusting the task priority and processing mode according to actual needs, effectively avoiding frequent triggering of interrupts and reducing the instability of the system. At the same time, since the hardware processing unit has a high parallel processing capability, it can quickly process a large number of data tasks, further improving the processing capability and response speed of the system.

[0019] (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

[0020] Figure 1 This is a structural diagram of single chip microcomputer data reading of the present invention; Figure 2 This is a circuit diagram of the single chip computer system of the present invention; Figure 3 This is a circuit diagram of the single-chip computer system display device of the present invention. DETAILED DESCRIPTION

[0021] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments 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 of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.

[0022] like Figure 1 As shown, a single chip computer data reading method comprises the following steps: (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 shown in the figure. Figure 2 As shown: The API interface provides an intuitive and easy-to-use way to manage data reading and processing tasks. Users do not need to care about the underlying complex 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: a. Task adding function: This function adds a new data task to the task queue. The task data, priority and processing function are specified by the user.

[0023] Function name: add_task Parameters: task_data: pointer to task data, the type is defined according to specific requirements.

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

[0025] handler: A pointer to a task processing function, which is responsible for processing task data and returning the processing result.

[0026] 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.

[0027] Function name: schedule_tasks c. Get processing result function: This function is used to get the processing result of the specified task. The user can query the processing status and processing result of the task through the unique identifier of the task.

[0028] Function name: get_result Parameters: task_id: The unique identifier of the task, used to distinguish different tasks.

[0029] 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.

[0030] 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, rescheduling tasks, etc.

[0031] Function name: handle_error Parameters: task_id: The unique ID of the task where the error occurred.

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

[0033] 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 and 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 certain termination condition is reached; c. Obtain processing result process: 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) Try 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.

[0034] (2) Data reading, input and transmission: Dynamic scheduling strategies are used to read data and accelerated data transmission paths are adopted to optimize the bandwidth and transmission protocol of the data bus. At the same time, cache and prefetch technologies are added 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 end.

[0035] The dynamic scheduling strategy dynamically adjusts the processing order of tasks and the number of concurrently processed tasks according to the real-time load of the system 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 to ensure that high-priority tasks are processed in a timely manner while avoiding system overload and resource waste. The specific process is as follows: a. Label settings: Task classification: First, determine the type of task, including compute-intensive, I / O-intensive, real-time, etc.

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

[0037] b. Weight calculation and priority setting: 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.

[0038] Weight calculation: Based on the task 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.

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

[0040] c. Load condition determination: Monitor resources: Real-time monitoring of system resource usage, including CPU usage, memory usage, disk I / O, etc.

[0041] 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.

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

[0043] d. Task scheduling based on load and priority: 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.

[0044] Queue management: Maintain multiple task queues, including high priority queues, low priority queues, delay queues, etc. Assign tasks to different queues based on task priority and system load.

[0045] Dynamic Scheduling: Dynamically adjust the task scheduling strategy based on the real-time system load and the state of the task queue. When the system is under high load, suspend the processing of low-priority tasks or delay some tasks until the load is reduced.

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

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

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

[0049] The accelerated data transmission path uses an infrared remote control, an infrared receiving sensor circuit and a single-chip decoding software. The encoding methods of the infrared remote control are mainly divided into two types: PWM (pulse width modulation) and PPM (pulse position modulation). The PWM method uses the duty cycle of the infrared carrier to represent "0" and "1". The time for transmitting the infrared carrier is fixed, and the duty cycle is changed by changing the time when the carrier is not transmitted. For example, the commonly used TV remote control uses NEC UPD6121, and its "0" is 0.56ms for carrier transmission and 0.56ms for non-transmission; its "1" is 0.56ms for carrier transmission and 1.68ms for non-transmission. In addition, there is a guide code for the convenience of decoding. The total encoding length of UPD6121 is 108ms.

[0050] The PPM method uses the position of the transmitted carrier to represent "0" and "1". From transmitting the carrier to not transmitting the carrier is "0", and from not transmitting the carrier to transmitting the carrier is "1". The time for transmitting the carrier and not transmitting the carrier is the same, both 0.68ms, that is, the time for each bit is fixed.

[0051] Cache is an important storage component in the computer memory hierarchy. Its operation is based on the principle of locality of programs and data; that is, in a short time interval, the program is concentrated on a smaller main memory address space for execution, and the access to data also has locality. The working process of cache usually involves putting the currently executing program and the data being accessed into it, so that when the program is running, the CPU directly accesses instructions and data from the cache without having to read from the slow main memory, thereby greatly improving the CPU's program execution speed.

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

[0053] (3) Data processing: A task queue is used for data processing. 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 places it in the corresponding position of the queue according to the priority tag, then takes out the data task with the highest priority from the queue and hands it over to a dedicated hardware processing unit for parallel processing.

[0054] The 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 unique identification (ID) of the task, task data, task priority, and processing function. The task queue is implemented using a linked list structure, in which 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 the task is processed, it is removed from the head of the linked list.

[0055] The specific process of task processing is as follows: a. Task addition: When a new data task needs to be processed, it is encapsulated as a task object, and the priority is set for it according to the urgency and importance of the task, and then the task object is 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.

[0056] The first-in-first-out feature of the task queue and the concurrent processing mechanism ensure that high-priority tasks are processed first, while making full use of system resources to improve data processing efficiency. Frequent triggering of interrupts is avoided, and the stability and reliability of the system are improved. At the same time, the error handling mechanism ensures that when an error occurs, the error information can be processed and recorded in a timely manner.

[0057] (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 Shown is a 4-digit digital tube.

[0058] Specifically, when the above-mentioned single-chip microcomputer data reading method is applied to electric tools, 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.

[0059] A single-chip computer data reading system 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 a single-chip computer system and an API interface and ensures smooth connection, writes the single-chip computer system program according to actual needs, and calls the API interface 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 simultaneously adds a cache and pre-fetching technology to predict and load the data to be accessed in advance, so as to read the data completely and transmit it to a data processing module; the data processing module adopts a task queue data processing mechanism, firstly establishes a task queue for storing data tasks to be processed, each of the data tasks contains a priority tag for identifying its urgency and importance; when a new data task arrives, the single-chip computer system will put it into 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 special 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.

[0060] 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 adopts a dynamic scheduling strategy to dynamically adjust the number and allocation mode 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; and can more flexibly respond to changes in system load, ensure that important tasks are processed in a timely manner, and avoid system overload and resource waste.

[0061] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.

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 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; (2) Data reading, input and transmission: Dynamic scheduling strategies are used to read data and accelerated data transmission paths are adopted to optimize the bandwidth and transmission protocol of the data bus. At the same time, cache and prefetch technologies are added 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 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 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. (4) Data output: The data processed by the data processing end is temporarily stored in a memory or connected to a display device to ensure the integrity and continuity of the microcontroller system data.

2. A single chip computer data reading method according to claim 1, characterized in that: The API interface implements data reading, task adding, 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 and 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 certain termination condition is reached; c. Obtain processing result process: 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) Try 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.

3. A single chip computer data reading method according to claim 2, characterized in that: Error information includes recording error logs and recovering or retrying tasks.

4. A single chip computer data reading method according to claim 1, characterized in that: The specific process of implementing the dynamic scheduling strategy is as follows: a. Label setting: First, determine the type of task, including computation-intensive, I / O-intensive, and real-time. Then assign one or more labels to each task, using a string of numbers and / or letters to represent the label, 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 label and the defined weight factor. Sort all tasks in the task queue by weight value. Tasks with higher weight values ​​have higher priorities. c. Load determination: Real-time monitoring of system resource usage, including CPU usage, memory usage, and disk I / O. One or more load thresholds are set for each system resource. When resource usage exceeds these thresholds, the system is considered to be in a high-load state. Based on the real-time monitoring data and load thresholds, the current system load is evaluated; d. Task scheduling based on load and priority: Before placing a task into a queue, decide whether to pre-process the task based on the priority of the task and the load of the system. The pre-processing includes splitting, merging and delaying. During the task processing, update the status of the task queue based on the completion of the task, maintain multiple task queues, and assign tasks to different queues based on the priority of the task and the load of the system. When the system is in a high-load state, suspend the processing of low-priority tasks, or delay some tasks until the load is reduced; e. Optimization and adjustment: Based on the results of system monitoring, dynamically adjust parameters such as weight factors and load thresholds to optimize scheduling strategies, allowing users or system administrators to adjust task priorities and scheduling strategies through the interface or API interface to meet different needs.

5. A single chip computer data reading method 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).

6. A single chip computer data reading method according to claim 1, characterized in that: The cache stores the currently executing program and the data being accessed. When the program is running, the CPU directly accesses instructions and data 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.

7. A single chip computer data reading method 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.

8. A single chip computer data reading method according to claim 7, 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 the priority is set for it according to the urgency and importance of the task, and then the task object is 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.

9. A system for implementing a single chip microcomputer data reading method according to any one of claims 1 to 8, 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, wherein the initialization module configures a single-chip microcomputer system and an API interface, ensures smooth connection, writes the single-chip microcomputer system program according to actual needs, and calls the API interface 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 pre-fetch technology to predict and load the data to be accessed in advance, so as to read the data completely and transmit it to the data processing module; the data processing module adopts a data processing mechanism of a task queue, first establishes a task queue for storing data tasks to be processed, and each of the data tasks contains a priority tag for identifying 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.

10. The system of a single chip computer data reading method according to claim 9, 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

  • Single-chip microcomputer data processing system and method for realizing multichannel data acquisition

    CN115237639A

  • Task-driven multitasking method that constrains task suspension to task preemption

    US8739176B1

  • Task scheduling method and related device

    WO2024046088A1