MCU serial port communication burning control method and system, medium and electronic equipment
By calculating the communication rate and execution rate, matching the timing mechanism and optimizing the MCU burning process, the problem of slow MCU burning speed is solved, and efficient serial communication burning is achieved, especially in high baud rate and large data volume scenarios Significant speed improvement.
Patent Information
- Application Number
- CN202411257453.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-11-22
AI Technical Summary
During the existing MCU burning process, the burning speed is slow, and the host computer and MCU are waiting for the execution results in part, resulting in a long overall burning time and low execution efficiency.
By calculating the communication rate and the execution rate of the program editing interface, matching different timing mechanisms, optimizing the serial communication burning process, including obtaining the MCU type to determine whether the target task needs to be added, data reorganization and address alignment, and improving the serial communication baud rate and FLASH The amount of data of the API interface reduces the waiting time between tasks.
The burning efficiency has been significantly improved, especially in the scenarios where the serial port communication baud rate is high and the amount of burning data is large, the speed advantage is obvious, with an overall speed increase of 27.8% compared with the existing technology.
Smart Images

Figure CN119002948A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data processing, and in particular relates to an MCU serial port communication burning control method, system, medium and electronic equipment. Background Art
[0002] Currently, most drivers on the market include serial port communication, which is not only the control interface of the driver, but also provides hardware support for the driver's internal MCU update program.
[0003] The MCU update program process is as follows: 1. The host computer sends a start-burning command to the MCU through the serial port; 2. After receiving the command, the MCUbootloader program initializes the FLASH configuration and erases the data in the FLASH application space; after completion, it responds to the host computer; 3. The host computer parses the HEX target file that needs to be updated and sends a frame of data to the MCU; 4. After receiving the data, the MCUbootloader program cyclically calls the FLASH API interface function to complete the burning of a frame of data; after completion, it responds to the host computer; 5. Repeat steps 3 and 4 until all data are burned.
[0004] Although the conventional MCU burning process used in the prior art can complete the burning task, the burning speed is not high, and the host computer and MCU are waiting for the execution result part of the time. The overall burning time is relatively long and the execution efficiency is low. Summary of the invention
[0005] In view of the above-mentioned shortcomings of the prior art, the object of the present invention is to provide an MCU serial communication burning control method, system, medium and electronic device to solve the above-mentioned problems.
[0006] In a first aspect, the present invention provides an MCU serial communication burning control method, the method comprising the following steps:
[0007] Obtaining the MCU type to determine whether a target task needs to be added, wherein the target task includes a data reorganization task;
[0008] Calculate the communication rate of the communication serial port and the execution rate of the program editing interface;
[0009] Comparing the communication rate and the execution rate to match different timing mechanisms, wherein the timing mechanisms include a first mechanism, a second mechanism, a third mechanism, and a fourth mechanism;
[0010] The serial communication burning operation is performed based on the corresponding timing mechanism until all data are burned.
[0011] In a possible implementation of the present application, the calculating the communication rate of the communication serial port specifically includes:
[0012] Get the interval byte between the MCU receiving data frame and the response data frame and the maximum baud rate;
[0013] Get the effective data length of a frame of serial communication;
[0014] The communication rate is calculated based on the interval time, the maximum baud rate and the effective data length, wherein the communication rate is the single frame transmission and reception cycle time of the serial communication, and the formula is as follows:
[0015] Comm_Tcycle=(T_byte*2+N_byte+6)*(10*1 / Baud_max);
[0016] Wherein, Comm_Tcycle is the communication rate, T_byte is the interval byte, N_byte is the valid data length, and Baud_max is the maximum baud rate.
[0017] In a possible implementation of the present application, obtaining the MCU receiving data frame and the response data frame specifically includes:
[0018] Obtaining a data frame received by the MCU, wherein the data frame received by the MCU specifically includes: a starting address + valid data + a checksum;
[0019] The MCU response data frame is obtained, wherein the MCU response data frame specifically includes: response data+checksum.
[0020] In a possible implementation of the present application, the calculation of the execution rate of the program editing interface specifically includes:
[0021] Get the time consumed for the maximum amount of data in a single programming of the program editing interface;
[0022] Get the writing interval time of the program editing interface;
[0023] The execution rate is calculated based on the consumption time and the writing interval time, wherein the execution rate is the time for writing a frame cycle in the program editing interface, and the formula is as follows:
[0024] API_Tcycle=(API_Twrite+API_Twait)*Num;
[0025] Among them, API_Tcycle is the execution rate, API_Twrite is the consumption time, API_Twait is the write interval time, and Num is the conditional maximum integer.
[0026] In a possible implementation of the present application, calculating the conditional maximum integer specifically includes:
[0027] Get the maximum number of bytes received in one frame of serial communication;
[0028] Obtaining the maximum amount of data for single programming corresponding to the program editing interface;
[0029] The conditional maximum integer is calculated based on the maximum number of bytes and the maximum amount of data for single programming, and the formula is as follows:
[0030] Num<=(Nmax_byte-4) / API_byte, Num is a positive integer;
[0031] Among them, Num is the conditional maximum integer, Nmax_byte is the maximum number of bytes, and API_byte is the maximum amount of data that can be programmed in a single time.
[0032] In a possible implementation of the present application, comparing the communication rate and the execution rate to match different timing mechanisms specifically includes:
[0033] If the execution rate of the program editing interface is greater than or equal to the communication rate of the communication serial port, the first mechanism and the second mechanism are distinguished based on whether the target task is added or not, wherein if the target task is added, the first mechanism is matched; if the target task is not added, the second mechanism is matched;
[0034] If the execution rate of the program editing interface is lower than the communication rate of the communication serial port, the third mechanism and the fourth mechanism are distinguished based on whether the target task is added or not, wherein if the target task is added, the third mechanism is matched; if the target task is not added, the fourth mechanism is matched.
[0035] In a possible implementation of the present application, obtaining the MCU type to determine whether a target task needs to be added specifically includes: determining whether the address boundary of the MCU's program editing interface needs to be aligned, wherein, when alignment is required, the target task is added, wherein the target task is used to perform address reorganization based on the address alignment principle.
[0036] In a second aspect, the present invention provides an MCU serial port communication burning control system, the system comprising:
[0037] An acquisition module, used for acquiring the MCU type to determine whether a target task needs to be added, wherein the target task includes a data reorganization task;
[0038] A calculation module, used for calculating the communication rate of the communication serial port and the execution rate of the program editing interface;
[0039] A comparison module, used for comparing the communication rate and the execution rate to match different timing mechanisms, wherein the timing mechanisms include a first mechanism, a second mechanism, a third mechanism and a fourth mechanism;
[0040] The burning module is used to perform serial communication burning operations based on the corresponding timing mechanism until all data are burned.
[0041] In a third aspect, the present invention provides an electronic device, the electronic device comprising: a processor and a memory;
[0042] The memory is used to store computer programs;
[0043] The processor is used to execute the computer program stored in the memory, so that the electronic device executes the above-mentioned MCU serial port communication burning control method.
[0044] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which implements the above-mentioned MCU serial port communication burning control method when executed by an electronic device.
[0045] As described above, the MCU serial communication burning control method, system, medium and electronic device described in the present invention have the following beneficial effects: the burning efficiency can be improved, especially for application scenarios with high serial communication baud rate and large amount of burning data, the speed advantage is significantly improved compared with the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 Shown is a schematic diagram of a scene of an electronic device of the present invention in an embodiment;
[0047] Figure 2 Shown is a flow chart of an MCU serial communication burning control method in one embodiment of the present invention;
[0048] Figure 3 Shown is a schematic diagram of MCU communication tasks and Flash tasks in an embodiment of the MCU serial communication burning control method of the present invention;
[0049] Figure 4 Shown is a schematic diagram of a timing mechanism of an embodiment of the MCU serial communication burning control method of the present invention;
[0050] Figure 5 Shown is a schematic diagram of a timing mechanism of an embodiment of the MCU serial communication burning control method of the present invention;
[0051] Figure 6Shown is a schematic diagram of a timing mechanism of an embodiment of the MCU serial communication burning control method of the present invention;
[0052] Figure 7 Shown is a schematic diagram of a timing mechanism of an embodiment of the MCU serial communication burning control method of the present invention;
[0053] Figure 8 Shown is a flow chart of an MCU serial communication burning control method in one embodiment of the present invention;
[0054] Fig. 9 Shown is a flow chart of a data reorganization task in an embodiment of the MCU serial communication burning control system of the present invention;
[0055] Fig.10 It is a schematic structural diagram of an electronic device of the present invention in one embodiment. DETAILED DESCRIPTION
[0056] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0057] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0058] The following embodiments of the present invention provide a MCU serial communication burning control method, which can be applied to Figure 1 The electronic device shown. The electronic device described in the present invention may include a mobile phone 11 with a wireless charging function, a tablet computer 12, a laptop computer 13, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. The embodiment of the present invention does not impose any restrictions on the specific type of the electronic device.
[0059] For example, the electronic device may be a station (STAION, ST) in a WLAN with a wireless charging function, a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA) device, a handheld device with a wireless charging function, a computing device or other processing device, a computer, a laptop computer, a handheld communication device, a handheld computing device, and / or other devices for communicating on a wireless system and a next generation communication system, such as a mobile terminal in a 5G network, a mobile terminal in a future evolved Public Land Mobile Network (PLMN), or a mobile terminal in a future evolved Non-terrestrial Network (NTN).
[0060] The technical solutions in the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0061] Specifically, see Figure 2 In one embodiment of the invention, the MCU serial communication burning control method of the present invention comprises the following steps:
[0062] Step S202, obtaining the MCU type to determine whether a target task needs to be added, wherein the target task includes a data reorganization task;
[0063] Step S204, calculating the communication rate of the communication serial port and the execution rate of the program editing interface;
[0064] Step S206, comparing the communication rate and the execution rate to match different timing mechanisms, wherein the timing mechanisms include a first mechanism, a second mechanism, a third mechanism, and a fourth mechanism;
[0065] Step S208, performing serial communication programming based on the corresponding timing mechanism until all data are programmed.
[0066] It should be noted that in this embodiment, during the MCU programming process, the two main tasks are the communication task and the Flash task. The communication task is responsible for communicating with the host computer to obtain programming data; the Flash task is responsible for calling the FLASH API interface function to write data into the Flash area. The present invention executes these two tasks separately to reduce the waiting time between tasks.
[0067] Furthermore, in order to improve the efficiency of MCU burning, the following basic principles are followed: ①. The serial communication baud rate should be increased as much as possible to speed up data transmission. Among them, different drivers have different maximum baud rates supported by hardware due to different circuits and devices used for serial communication; in addition, the maximum serial communication baud rates supported by different MCUs are also different. Assuming that the maximum serial communication baud rate supported by the hardware circuit is Baud_hw, and the maximum serial communication baud rate supported by the MCU is Baud_sw, the maximum serial communication baud rate that can actually be used is the minimum value of the two, Min (Baud_hw, Baud_sw), recorded as Baud_max; ②. The maximum amount of data supported by the FLASH API interface function should be written as much as possible each time to reduce the time overhead caused by the interface function call. The maximum amount of data that can be programmed and the time consumed each time are different for the FLASH API interface used by different MCUs. Assume that the maximum data volume of a single FLASH API programming is API_byte bytes, and the time consumed is API_Twrite seconds; the waiting time between two calls to the interface function is API_Twait seconds; ③, the host computer sends the MCU data frame content: starting address + valid programming data + checksum; the starting address and checksum should be as short as possible to increase the proportion of valid data and improve transmission efficiency. In this solution, the starting address and checksum each occupy two bytes as an example for explanation; ④, the MCU responds to the host computer data frame content: feedback response + checksum; the feedback response and checksum should be as short as possible to improve transmission efficiency. However, it is best not to cancel the MCU feedback response, because if the serial communication hardware circuit fails, or the burning process fails, the host computer can get feedback in time and choose to re-operate or directly report the fault to the user. In this solution, the feedback response and checksum each occupy one byte as an example for explanation.
[0068] Specifically, in this embodiment, the MCU type is first obtained to determine whether it is necessary to add a target task, wherein the target task includes a data reorganization task, wherein the data reorganization task is optional and not required, and adding this task can improve program compatibility; further, the communication rate of the communication serial port and the execution rate of the program editing interface are calculated, so as to compare the communication rate and the execution rate to match different timing mechanisms, wherein the timing mechanism includes a first mechanism, a second mechanism, a third mechanism and a fourth mechanism, and the specific timing mechanism will be described in detail in the subsequent description. After matching different timing mechanisms, the serial port communication burning operation is performed based on the corresponding timing mechanism until all data is burned.
[0069] Further, in one embodiment of the invention, the calculating the communication rate of the communication serial port specifically includes:
[0070] Get the interval byte between the MCU receiving data frame and the response data frame and the maximum baud rate;
[0071] Get the effective data length of a frame of serial communication;
[0072] The communication rate is calculated based on the interval time, the maximum baud rate and the effective data length, wherein the communication rate is the single frame transmission and reception cycle time of the serial communication, and the formula is as follows:
[0073] Comm_Tcycle=(T_byte*2+N_byte+6)*(10*1 / Baud_max);
[0074] Wherein, Comm_Tcycle is the communication rate, T_byte is the interval byte, N_byte is the valid data length, and Baud_max is the maximum baud rate.
[0075] It should be noted that, in this embodiment, the obtaining of the MCU receive data frame and the response data frame specifically includes: obtaining the MCU receive data frame, wherein the MCU receive data frame specifically includes: starting address + valid data + checksum; specifically, starting address 2byte + valid data N_byte + checksum 2byte, obtaining the MCU response data frame, wherein the MCU response data frame specifically includes: response data + checksum, specifically, response data 1byte + checksum 1byte.
[0076] Further, in this embodiment, the schematic diagram of the MCU communication task and the Flash task is as follows: Figure 3 As shown, the interval byte between the MCU receiving data frame and the response data frame is obtained, specifically "2.5byte" and the maximum baud rate Baud_max, the effective data length N_byte of a serial communication frame is obtained, and the communication rate is calculated based on the interval time, the maximum baud rate and the effective data length, wherein the communication rate is the serial communication single frame receiving and sending cycle time, and the formula is as follows:
[0077] Comm_Tcycle=(2.5*2+N_byte+6)*(10*1 / Baud_max);
[0078] Wherein, Comm_Tcycle is the communication rate, T_byte is the interval byte, specifically "2.5byte", N_byte is the effective data length, wherein N_byte=API_byte*Num, which will be described in detail in the subsequent description, and Baud_max is the maximum baud rate.
[0079] Furthermore, in one embodiment of the invention, the execution rate of the computing program editing interface specifically includes:
[0080] Get the time consumed for the maximum amount of data in a single programming of the program editing interface;
[0081] Get the writing interval time of the program editing interface;
[0082] The execution rate is calculated based on the consumption time and the writing interval time, wherein the execution rate is the time for writing a frame cycle in the program editing interface, and the formula is as follows:
[0083] API_Tcycle=(API_Twrite+API_Twait)*Num;
[0084] Among them, API_Tcycle is the execution rate, API_Twrite is the consumption time, API_Twait is the write interval time, and Num is the conditional maximum integer.
[0085] It should be noted that, in this embodiment, Figure 3 As shown, FLASH API corresponds to the program editing interface, wherein the maximum amount of data for a single programming is API_byte bytes, the time consumed is API_Twrite seconds, and the write interval time of FLASH API, i.e. the program editing interface, is API_Twait seconds. Then, the FLASH API, i.e. the program editing interface writes a frame cycle time of API_Tcycle = (API_Twrite + API_Twait) * Num, wherein API_Tcycle is the execution rate, API_Twrite is the consumed time, API_Twait is the write interval time, and Num is the conditional maximum integer.
[0086] Furthermore, in one embodiment of the invention, calculating the conditional maximum integer specifically includes:
[0087] Get the maximum number of bytes received in one frame of serial communication;
[0088] Obtaining the maximum amount of data for single programming corresponding to the program editing interface;
[0089] The conditional maximum integer is calculated based on the maximum number of bytes and the maximum amount of data for single programming, and the formula is as follows:
[0090] Num<=(Nmax_byte-4) / API_byte, Num is a positive integer;
[0091] Among them, Num is the conditional maximum integer, Nmax_byte is the maximum number of bytes, and API_byte is the maximum amount of data that can be programmed in a single time.
[0092] It should be noted that, in this embodiment, based on the internal resources of the MCU such as FLASH, RAM, and stack, it is assumed that the maximum number of bytes received by the MCU in one frame of serial communication is Nmax_byte. From (2+API_byte*Num+2)<=API_byte, it is deduced that: Num<=(Nmax_byte-4) / API_byte, Num is a positive integer, where Num is the maximum integer that satisfies the above conditions, and the effective data length of one frame of serial communication is N_byte=API_byte*Num.
[0093] Further, in one embodiment of the invention, the comparing the communication rate and the execution rate to match different timing mechanisms specifically includes:
[0094] If the execution rate of the program editing interface is greater than or equal to the communication rate of the communication serial port, the first mechanism and the second mechanism are distinguished based on whether the target task is added or not, wherein if the target task is added, the first mechanism is matched; if the target task is not added, the second mechanism is matched;
[0095] If the execution rate of the program editing interface is lower than the communication rate of the communication serial port, the third mechanism and the fourth mechanism are distinguished based on whether the target task is added or not, wherein if the target task is added, the third mechanism is matched; if the target task is not added, the fourth mechanism is matched.
[0096] It should be noted that in this embodiment, before executing the corresponding timing control, there are two prerequisite judgments, one is the judgment of adding the data reorganization task, and the other is the judgment of the size of the execution rate and the communication rate. The two condition judgments correspond to four timing mechanisms.
[0097] Specifically, if API_Tcycle ≥ Comm_Tcycle, it means that the communication task is executed faster than the Flash task, which can be divided into the following two cases:
[0098] (a) If there is a data reorganization task, it corresponds to the first mechanism. The overall timing can be referred to Figure 4 :
[0099] i) After the MCU communication task completes receiving a frame of data, the MCU data reorganization task is started.
[0100] After the MCU data reorganization task is completed, the Flash task is started.
[0101] ii) During the execution of the MCU Flash task, the MCU communication task continues to execute.
[0102] iii) The MCU communication task receives a new frame of data and starts the MCU data reorganization task.
[0103] iv) The MCU communication task responds to the feedback buffer full signal.
[0104] v) When the host computer receives a buffer full signal, the data is not updated and waits for the MCU buffer to be cleared.
[0105] vi) After the Flash task is executed, the MCU communication task is notified that it can request new data;
[0106] The Flash task continues to execute, burning the data and reorganizing the data cached before the task.
[0107] vii) The MCU communication task responds to clear the buffer full signal.
[0108] viii) The host computer sends the next frame of data via serial communication.
[0109] The above process is repeated until all data has been burned.
[0110] (b) No data reorganization task, corresponding to the second mechanism, the overall timing can be referred to Figure 5 :
[0111] i) After the MCU communication task receives a frame of data, it starts the FLASH task.
[0112] ii) During the execution of the MCU Flash task, the MCU communication task continues to execute.
[0113] iii) The MCU communication task receives a new frame of data and caches the data.
[0114] iv) The MCU communication task responds to the feedback buffer full signal.
[0115] v) When the host computer receives a buffer full signal, the data is not updated and waits for the MCU buffer to be cleared.
[0116] vi) After the Flash task is executed, the MCU communication task is notified that it can request new data;
[0117] The Flash task continues to execute and burns the data previously cached by the Communication task.
[0118] vii) The MCU communication task responds to clear the buffer full signal.
[0119] (viii) The host computer sends the next frame of data through serial communication.
[0120] The above process is repeated in a loop until all data has been programmed.
[0121] If API_Tcycle < Comm_Tcycle, it indicates that the communication task is executed slower than the Flash task, which is divided into the following two cases:
[0122] (c) There is a data reorganization task, corresponding to the third mechanism. The overall timing can be referred to Figure 6 :
[0123] (i) After the MCU communication task receives a frame of data, it starts the MCU data reorganization task.
[0124] (ii) After the MCU data reorganization task is completed, it starts the Flash task.
[0125] (iii) During the execution of the MCU Flash task, the MCU communication task continues to execute.
[0126] (iv) The Flash task is executed in a loop until a frame of data is completely programmed.
[0127] (v) After the Flash task loop execution is completed, it notifies the MCU communication task.
[0128] (vi) The host computer sends the next frame of data through serial communication.
[0129] The above process is repeated in a loop until all data has been programmed.
[0130] (d) There is no data reorganization task, corresponding to the fourth mechanism. The overall timing can be referred to Figure 7 :
[0131] (i) After the MCU communication task receives a frame of data, it starts the Flash task.
[0132] (ii) During the execution of the MCU Flash task, the MCU communication task continues to execute.
[0133] (iii) The Flash task is executed in a loop until a frame of data is completely programmed.
[0134] (iv) After the Flash task loop execution is completed, it notifies the MCU communication task.
[0135] (v) The host computer sends the next frame of data through serial communication.
[0136] The above process is repeated in a loop until all data has been programmed.
[0137] Further, in one embodiment of the invention, the obtaining of the MCU type to determine whether a target task needs to be added specifically includes: determining whether an address boundary of a program editing interface of the MCU needs to be aligned, wherein, when alignment is required, the target task is added, wherein the target task is used to perform address reorganization based on an address alignment principle.
[0138] It should be noted that, in this embodiment, Figure 8 As shown, it is a flow chart of the data reorganization task, wherein the data reorganization task reassembles the two frames of data obtained by the communication task into one frame of data that can continuously call the FLASH API to execute writing according to the address alignment principle.
[0139] Specifically, this embodiment takes the driver using TI TMS320F280039 chip as an example: Assume that the maximum supported serial port communication baud rate Baud_max = 307200; the maximum serial port receiving data frame size Nmax_byte supported by the program = 260. The maximum data volume of a single FLASH API programming is API_byte = 16 bytes, and the time consumed is API_Twrite = 200*10-6 seconds; the waiting time between two calls to the interface function is API_Twait = 10*10-6 seconds.
[0140] At the beginning, it takes about API_Terase=20*10-3 seconds to initialize FLASH and erase FLASH. Assume that the size of the data file to be programmed is FILE_size=200KB. Since each frame of data contains the number of APIs Num<=(Nmax_byte-4) / API_byte (Num is a positive integer), it can be deduced that Num<=(260-4) / 16=16, and the maximum positive integer of Num is "16".
[0141] If the solution in the prior art is used: the single frame data programming cycle is:
[0142] Tcycle=(2.5*2+API_byte*Num+6)*(10*1 / Baud_max)+(API_byte+API_Twait)
[0143] *Num=(5+16*16+6)*10 / 307200+(200*10-6+10*10-6)*16
[0144] =12051*10-6 seconds;
[0145] The total programming time required is approximately:
[0146] Ttotal=Tcycle*[FILE_size / (API_byte*Num)]+API_Terase
[0147] =12051*10-6*[200*1024 / (16*16)]+20*10-3
[0148] = 9.66 seconds
[0149] Using the technical solution of the present invention: the single frame data programming cycle is:
[0150] Tcycle=(2.5*2+API_byte*Num+6)*(10*1 / Baud_max)
[0151] =(5+16*16+6)*10 / 307200
[0152] =8691*10-6 seconds
[0153] The total programming time required is approximately:
[0154] Ttotal=Tcycle*[FILE_size / (API_byte*Num)]+API_Terase
[0155] =8691*10-6*[20*1024 / (16*16)]+20*10-3
[0156] = 6.97 seconds
[0157] By using this solution, under the parameters given in this embodiment, the overall speed is improved by about "27.8%", which greatly improves the burning efficiency. Especially for application scenarios with high serial communication baud rate and large amount of burning data, the speed advantage will be more significantly improved compared with the existing technology.
[0158] The embodiment of the present application also provides an MCU serial port communication burning control system, which can implement the MCU serial port communication burning control method described in the present application. However, the implementation device of the MCU serial port communication burning control method described in the present application includes but is not limited to the structure of the MCU serial port communication burning control system listed in the present embodiment. All structural deformations and replacements of the prior art made according to the principles of the present application are included in the protection scope of the present application.
[0159] See also Fig. 9 In one embodiment, this embodiment provides an MCU serial communication burning control system 90, the system comprising:
[0160] An acquisition module 91 is used to acquire the MCU type to determine whether a target task needs to be added, wherein the target task includes a data reorganization task;
[0161] A calculation module 92, used for calculating the communication rate of the communication serial port and the execution rate of the program editing interface;
[0162] A comparison module 93, used for comparing the communication rate and the execution rate to match different timing mechanisms, wherein the timing mechanisms include a first mechanism, a second mechanism, a third mechanism and a fourth mechanism;
[0163] The burning module 94 is used to perform serial communication burning operations based on different timing mechanisms until all data are burned.
[0164] Since the specific implementation of this embodiment corresponds to the aforementioned method embodiment, the same details will not be repeated here, and those skilled in the art should also understand that Fig. 9 The division of the modules in the embodiment is merely a division of logical functions, and in actual implementation, all or part of them can be integrated into one or more physical entities, and these modules can be implemented entirely in the form of software called by processing elements, or entirely in the form of hardware, or some modules can be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware.
[0165] In the several embodiments provided by the present invention, it should be understood that the disclosed system, device or method can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules / units is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules or units, which can be electrical, mechanical or other forms.
[0166] The modules / units described as separate components may or may not be physically separated, and the components displayed as modules / units may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules / units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention. For example, the functional modules / units in the various embodiments of the present invention may be integrated into one processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into one module / unit.
[0167] Those of ordinary skill in the art should further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0168] The embodiment of the present invention also provides a computer-readable storage medium. A person of ordinary skill in the art can understand that all or part of the steps in the method for implementing the above embodiment can be completed by instructing the processor through a program, and the program can be stored in a computer-readable storage medium, and the storage medium is a non-transitory medium, such as a random access memory, a read-only memory, a flash memory, a hard disk, a solid-state hard disk, a magnetic tape, a floppy disk, an optical disc, and any combination thereof. The above storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (DVD)), or a semiconductor medium (e.g., a solid-state disk (SSD)), etc.
[0169] An embodiment of the present invention further provides an electronic device, which includes a processor and a memory.
[0170] The memory is used to store computer programs.
[0171] The memory includes: ROM, RAM, disk, USB flash drive, memory card or CD and other media that can store program codes.
[0172] The processor is connected to the memory and is used to execute the computer program stored in the memory so that the electronic device executes the above-mentioned MCU serial port communication burning control method.
[0173] Preferably, the processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0174] like Fig.10 As shown, the electronic device of the present invention is in the form of a general computing device. The components of the electronic device may include but are not limited to: one or more processors or processing units 101, a memory 102, and a bus 103 connecting different system components (including the memory 102 and the processing unit 101).
[0175] Bus 103 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.
[0176] Electronic devices typically include a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device, including volatile and non-volatile media, removable and non-removable media.
[0177] The memory 102 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 1021 and / or cache memory 1022. The electronic device may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 1023 may be used to read and write non-removable, non-volatile magnetic media ( Fig.10 not shown, usually called a "hard drive"). Although Fig.10Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 103 via one or more data medium interfaces. The memory 102 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0178] A program / utility 1024 having a set (at least one) of program modules 10241 may be stored, for example, in the memory 102, such program modules 10241 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 10241 generally perform the functions and / or methods of the embodiments described herein.
[0179] The electronic device may also communicate with one or more external devices (e.g., keyboards, pointing devices, displays, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via input / output (I / O) interface 104. Furthermore, the electronic device may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via network adapter 105. Fig.10 As shown, the network adapter 105 communicates with other modules of the electronic device via the bus 103. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0180] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A MCU serial communication burning control method, characterized in that: include: Obtaining the MCU type to determine whether a target task needs to be added, wherein the target task includes a data reorganization task; Calculate the communication rate of the communication serial port and the execution rate of the program editing interface; Comparing the communication rate and the execution rate to match different timing mechanisms, wherein the timing mechanisms include a first mechanism, a second mechanism, a third mechanism, and a fourth mechanism; The serial communication burning operation is performed based on the corresponding timing mechanism until all data are burned.
2. The MCU serial port communication burning control method according to claim 1, characterized in that: The calculating the communication rate of the communication serial port specifically includes: Get the interval byte between the MCU receiving data frame and the response data frame and the maximum baud rate; Get the effective data length of a frame of serial communication; The communication rate is calculated based on the interval time, the maximum baud rate and the effective data length, wherein the communication rate is the single frame transmission and reception cycle time of the serial communication, and the formula is as follows: Comm_Tcycle=(T_byte*2+N_byte+6)*(10*1 / Baud_max); Wherein, Comm_Tcycle is the communication rate, T_byte is the interval byte, N_byte is the valid data length, and Baud_max is the maximum baud rate.
3. The MCU serial communication burning control method according to claim 2, characterized in that: The obtaining of the MCU receiving data frame and the response data frame specifically includes: Obtaining a data frame received by the MCU, wherein the data frame received by the MCU specifically includes: a starting address + valid data + a checksum; The MCU response data frame is obtained, wherein the MCU response data frame specifically includes: response data+checksum.
4. The MCU serial communication burning control method according to claim 3, characterized in that: The execution rate of the computing program editing interface specifically includes: Get the time consumed for the maximum amount of data in a single programming of the program editing interface; Get the writing interval time of the program editing interface; The execution rate is calculated based on the consumption time and the writing interval time, wherein the execution rate is the time for writing a frame cycle in the program editing interface, and the formula is as follows: API_Tcycle=(API_Twrite+API_Twait)*Num; Among them, API_Tcycle is the execution rate, API_Twrite is the consumption time, API_Twait is the write interval time, and Num is the conditional maximum integer.
5. The MCU serial communication burning control method according to claim 4, characterized in that: Calculating the maximum integer of the condition, specifically including: Get the maximum number of bytes received in one frame of serial communication; Obtaining the maximum amount of data for single programming corresponding to the program editing interface; The conditional maximum integer is calculated based on the maximum number of bytes and the maximum amount of data for single programming, and the formula is as follows: Num<=(Nmax_byte-4) / API_byte, Num is a positive integer; Among them, Num is the conditional maximum integer, Nmax_byte is the maximum number of bytes, and API_byte is the maximum amount of data that can be programmed in a single time.
6. The MCU serial communication burning control method according to claim 5, characterized in that: The comparing the communication rate and the execution rate to match different timing mechanisms specifically includes: If the execution rate of the program editing interface is greater than or equal to the communication rate of the communication serial port, the first mechanism and the second mechanism are distinguished based on whether the target task is added or not, wherein if the target task is added, the first mechanism is matched; if the target task is not added, the second mechanism is matched; If the execution rate of the program editing interface is lower than the communication rate of the communication serial port, the third mechanism and the fourth mechanism are distinguished based on whether the target task is added or not, wherein if the target task is added, the third mechanism is matched; if the target task is not added, the fourth mechanism is matched.
7. The MCU serial communication burning control method according to claim 1, characterized in that: The obtaining of the MCU type to determine whether a target task needs to be added specifically includes: determining whether an address boundary of a program editing interface of the MCU needs to be aligned, wherein the target task is added when alignment is required, wherein the target task is used to perform address reorganization based on an address alignment principle.
8. An MCU serial communication burning control system, characterized in that: include: An acquisition module, used for acquiring the MCU type to determine whether a target task needs to be added, wherein the target task includes a data reorganization task; A calculation module, used for calculating the communication rate of the communication serial port and the execution rate of the program editing interface; A comparison module, used for comparing the communication rate and the execution rate to match different timing mechanisms, wherein the timing mechanisms include a first mechanism, a second mechanism, a third mechanism and a fourth mechanism; The burning module is used to perform serial communication burning operations based on the corresponding timing mechanism until all data are burned.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the MCU serial port communication burning control method described in any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: The electronic device comprises: a processor and a memory; wherein the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the MCU serial port communication burning control method as described in any one of claims 1 to 7.
