OTP burning method and microcontroller

CN116225467BActive Publication Date: 2026-10-16CRM ICBG (WUXI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111481020.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-06
Publication Date
2026-10-16
Estimated Expiration
2041-12-06

AI Technical Summary

Technical Problem

[0010]鉴于以上所述现有技术的缺点,本发明的目的在于提供一种OTP烧录方法及微控制器,用于解决现有技术中OTP存储空间利用率低、计算量大、对硬件系统RAM要求条件苛刻、OTP烧录时间过长的问题

Benefits of technology

[0029] 1. Each calibration point is assigned an address, which facilitates the burning of individual calibration data to the OTP, making full use of the OTP storage space and greatly reducing the burning time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116225467B_ABST
    Figure CN116225467B_ABST
Patent Text Reader

Abstract

The application provides an OTP burning method and a microcontroller. A program storage space and a data storage space are defined, a plurality of calibration point spaces are defined in the data storage space, each of the calibration point spaces is used for storing an address of calibration data and actual calibration data, one calibration point is selected, an OTP burning program is called, a value of address 0 is read, an address of current effective calibration data is obtained according to the value of address 0, a calibration frequency is counted, if the frequency is less than a calibration frequency threshold, the address is added by 1, new calibration data is written in a new address, meanwhile, the new calibration data is saved in address 0, burning is completed, the OTP burning program is exited, and if the frequency is equal to the calibration frequency threshold, an error is prompted. According to the application, each calibration point is allocated with an address, single calibration data burning OTP is facilitated, the utilization efficiency of the OTP storage space is improved, and the burning time is greatly shortened. The RAM is released after single calibration point burning is completed, and the calculation amount is small. The program storage space is saved, and the application of the microcontroller can be extended.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of semiconductor technology, and in particular to an OTP programming method and a microcontroller. Background Technology

[0002] OTP (One-Time Programmable) is a type of memory that means it can be programmed only once; once the program is burned into the memory, it cannot be changed or erased. The multimeter microcontroller has an 8K-word OTP program memory, and can be configured with a 6K-word program memory space and a 2K-word data memory space. Through its internal low-voltage programming control circuit, data that would normally be written to EEPROM (Electrically Erasable Programmable Read-Only Memory) is automatically written to the OTP memory area, which can replace EEPROM.

[0003] OTP memory is a one-time use memory, unlike electrically erasable EEPROM, so there is a limit to the number of times calibration data can be written to a specific address. The current programming method divides the 2K words OTP into 16 groups, but whether it is full-file calibration or single-file calibration, one group of addresses must be programmed after entering calibration mode. This results in a large amount of computation, long programming time, and inefficient use of OTP storage space, causing waste.

[0004] In multimeter products, EEPROM is usually used for measurement function definition and calibration. When the EEPROM data is incorrect, it will cause the multimeter's function and performance to malfunction. Moreover, the communication between the multimeter's microcontroller and the EEPROM requires IO (Input / Output) ports. When the multimeter has many buttons and peripheral functions, the IO ports become scarce. Therefore, technicians use OTP program storage space to replace EEPROM to save IO ports, reduce hardware costs, reduce power consumption, and simplify inventory preparation during mass production.

[0005] The existing method to replace EEPROM involves allocating 2K words of OTP (Optical Pointer Protocol) as data storage space within the multimeter microcontroller's 8K program memory to store calibration data. Taking a 24C02 EEPROM as an example (256 8-bit bytes), the 2K words of OTP can be divided into 16 groups. This means that each time calibration mode is entered and before exiting, 256 bytes of calibration data are programmed into the OTP. This results in significant programming time consumption and wasted address space. The existing programming calibration process is described below. Figure 1 As shown.

[0006] from Figure 1The programming and calibration process reveals the limitations of existing technologies:

[0007] 1) Because some ranges of the multimeter have poor accuracy, it is not necessary to calibrate all ranges when entering calibration mode. In this way, the calibration data of other calibration points will not change when calibrating a single range. However, when exiting calibration, a set of addresses must be burned. This does not make full use of OTP storage space and causes waste.

[0008] 2) It involves a large amount of computation and places high demands on the hardware system's RAM (Random Access Memory).

[0009] 3) The burning process takes a long time. Summary of the Invention

[0010] In view of the shortcomings of the prior art described above, the purpose of this invention is to provide an OTP programming method and a microcontroller to solve the problems of low OTP storage space utilization, large computational load, stringent requirements on hardware system RAM, and excessively long OTP programming time in the prior art.

[0011] To achieve the above and other related objectives, the present invention provides an OTP programming method, the OTP programming method comprising at least:

[0012] 1) Identify the memory and then calculate the storage space;

[0013] 2) Allocate program storage space and data storage space in the storage space, allocate multiple calibration point spaces in the data storage space, and allocate current calibration data address space and calibration data space in each of the calibration point spaces;

[0014] 3) Select a calibration point;

[0015] 4) Start OTP programming;

[0016] 5) Read the value of the current calibration data address space, obtain the current valid calibration data based on the value, and then obtain the position of the current valid calibration data in the calibration data space;

[0017] 6) Count the number of times calibration has been performed;

[0018] 7) If the number of attempts is less than the calibration attempt threshold, increment the position of the calibration data space by 1, write the new calibration data to the new position, and simultaneously save the new calibration data in the current calibration data address space. Complete the OTP programming, generate the key, and exit the OTP programming process. If the number of attempts is equal to the calibration attempt threshold, display an error message and return to step 3.

[0019] Optionally, the process of identifying the memory includes: identifying the product serial number of the memory and then determining whether the memory is legitimate; after confirming that the memory is legitimate, identifying the structure of the memory; the process of calculating the storage space is to calculate the storage space for OTP programming based on the structure of the memory.

[0020] Optionally, the first address of each of the calibration point spaces is set to the current calibration data address space.

[0021] Optionally, the calibration data space includes a default calibration data space and a programmed calibration data space, wherein the second address of the calibration point space is set as the default calibration data space, and new calibration data cannot be written there; the programmed calibration data space is used to write new calibration data.

[0022] Optionally, the step of selecting calibration points includes: retrieving the calibration points in the order of their addresses in the storage space; then retrieving the calibration data space that has not been burned, selecting the calibration points to be burned; and locking the calibration points that have been burned to prevent the locked calibration points from being retrieved again.

[0023] Optionally, the key can be set to a format of: software identification code, memory hardware identification code, and random number, to prevent the written calibration data from being stolen and thus ensure the security of the OTP programming process.

[0024] This invention proposes a microcontroller for implementing the OTP programming method. The microcontroller includes at least: a programming module and a latching module, wherein:

[0025] The programming module is used for OTP programming;

[0026] The latch module corresponds to the programming module and is used to lock the programming module.

[0027] Optionally, the programming module further includes a software version number, a hardware version number, and a key to prevent the programming module from being copied.

[0028] As described above, the OTP programming method and microcontroller of the present invention have the following beneficial effects:

[0029] 1. Each calibration point is assigned an address, which facilitates the burning of individual calibration data to the OTP, making full use of the OTP storage space and greatly reducing the burning time.

[0030] 2. After a single calibration point is programmed, the RAM is released, resulting in a small computational load.

[0031] 3. Saves program storage space, enabling expansion of microcontroller applications. For example, multimeters can use the saved space to upgrade other functions. Attached Figure Description

[0032] Figure 1 The diagram shown is an exemplary programming and calibration process of this application.

[0033] Figure 2 The diagram shown is a schematic diagram of an OTP programming process provided in Embodiment 1 of this application.

[0034] Figure 3 The diagram shown is a microcontroller structure diagram provided in Embodiment 2 of this application.

[0035] Component designation explanation

[0036] 310 Programming Module

[0037] 320 latch module

[0038] Steps S1 to S7 Detailed Implementation

[0039] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention.

[0040] Please see Figure 2 and Figure 3 It should be noted that the illustrations provided in this embodiment are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0041] Example 1

[0042] like Figure 2 As shown, this embodiment provides an OTP programming method, which includes at least:

[0043] S1: As Figure 2 As shown, the memory is identified, and then the storage space is calculated.

[0044] Specifically, as an example, the process of identifying the memory includes: identifying the product serial number of the memory and then determining whether the memory is legitimate; after confirming the memory is legitimate, identifying the structure of the memory; the process of calculating the storage space is to calculate the storage space used for OTP programming based on the memory structure. It should be noted that, in addition to subtracting the space already programmed, the calculation of the storage space used for OTP programming also needs to subtract the space that is damaged and cannot be programmed.

[0045] S2: As Figure 2 As shown, program storage space and data storage space are allocated in the storage space, multiple calibration point spaces are allocated in the data storage space, and current calibration data address space and calibration data space are allocated in each of the calibration point spaces.

[0046] Specifically, as an example, the first address of each calibration point space is set to the current calibration data address space. It should be noted that the location of the current calibration data address space setting includes, but is not limited to, the first address of the calibration point space, and should be set according to the specific usage scenario, and is not limited to this embodiment.

[0047] Specifically, as an example, the calibration data space includes a default calibration data space and a programmed calibration data space. The second address of the calibration point space is set as the default calibration data space, where no new calibration data can be written. The programmed calibration data space is used to write new calibration data. It should be noted that the settings of the default calibration data space and the programmed calibration data space should consider actual usage scenarios and are not limited to this embodiment.

[0048] Furthermore, as an example, such as Figure 2 The method flow shown has a program storage space of 7KB and a data storage space of 1KB. More specifically, as an example, such as... Figure 2 The method flow shown has a calibration point space of 16 bytes, where address 0 is used to store the address of the currently valid calibration data; addresses 1 to 15 are used to store the actual calibration data. Furthermore, as... Figure 2 The method flow shown has 64 calibration points.

[0049] It should be further noted that the program storage space and the data storage space should be set according to the actual usage scenario and are not limited to this embodiment. In this embodiment, the number of calibration points = data storage space / standard point space, which is the calculation logic that the number of calibration points equals 64 in this embodiment. The space of the calibration point includes, but is not limited to, 16 bytes. The specific settings should take into account the bit width of the microcontroller, the size of the microcontroller's storage space, and the specific system architecture of the product in which the microcontroller is located, and are not limited to this embodiment.

[0050] S3: As Figure 2 As shown, select a calibration point.

[0051] Specifically, as an example, the steps for selecting calibration points include: retrieving the calibration points in the order of their storage addresses; then retrieving the calibration data space that has not been programmed, selecting the calibration points to be programmed; and locking the programmed calibration points to prevent them from being retrieved again. It should be noted that locking the programmed calibration points means that they do not need to be retrieved in the next calibration point selection, saving retrieval time and thus conserving program space.

[0052] S4: As Figure 2 As shown, start OTP burning.

[0053] S5: As Figure 2 As shown, the value of the current calibration data address space is read, the current valid calibration data is obtained based on the value, and then the position of the current valid calibration data in the calibration data space is obtained.

[0054] Specifically, as an example, according to the example in step S2, the value of address 0 in the calibration point can obtain the address of the currently valid calibration data, and addresses 1 to 15 are used to store the actual calibration data. As an example, address 1 stores default calibration data and cannot write new calibration data. It should be further noted that, as an example, the data at address 1 is the default value before calibration, serving as the initial value. More specifically, as an example, addresses 2 to 15 are used to write new calibration data during calibration. It should be added that the definition of address functions should be set according to the actual applicable scenario and is not limited to this embodiment. Further, as an example, during calibration, new calibration data is written to address 3, and at the same time, the new calibration data is written to address 0. When the value of address 0 is read, the calibration data is obtained, thus knowing that calibration data has been written to address 3.

[0055] S6: As Figure 2 As shown, this counts the number of times the calibration has been performed.

[0056] S7: As Figure 2 As shown, if the number of attempts is less than the calibration attempt threshold, the position of the calibration data space is incremented by 1, new calibration data is written to the new position, and the new calibration data is stored in the current calibration data address space. The OTP programming is completed, a key is generated, and the OTP programming is exited. If the number of attempts is equal to the calibration attempt threshold, an error is reported, and the process returns to step S3.

[0057] Specifically, as an example, according to the example in step S2, the calibration count threshold is equal to 14. It should be specifically noted that, as... Figure 2In the illustrated method flow, in this embodiment, except for address 1, which cannot write new calibration data, addresses 2 through 15 can all be written with calibration data. This is why the calibration count is equal to 14. It should be noted that if new calibration data is written to address 1, this calibration data is simultaneously saved to address 0. When writing calibration data again, the value of address 0 is read, and it is determined that address 1 has already been written with calibration data. Therefore, calibration data cannot be written to address 1; it can only be written to address 2. That is, the number of calibrations already performed is 1, and the number of remaining calibrations is 13. If the programming is complete, a key is generated. More specifically, as an example, the key format is set as: software identification code, memory hardware identification code, and random number, used to prevent the written calibration data from being stolen, thereby ensuring the security of the OTP programming process and exiting the OTP programming program. If the number of calibrations equals the calibration count threshold, the calibration point can no longer be programmed, and an available calibration point needs to be selected.

[0058] More specifically, such as Figure 2 The method flow shown is an example. To implement the OTP programming method provided in this embodiment, Table 1 shows the meaning and initial value information of the calibration point address, and Table 2 shows the information of calibration point address 0, as shown below:

[0059]

[0060]

[0061] Table 1

[0062] FFFEH Address 1 FFFCH Address 2 FFF8H Address 3 FFF0H Address 4 FFE0H Address 5 FFC0H Address 6 FF80H Address 7 FF00H Address 8 FE00H Address 9 FC00H Address 10 F800H Address 11 F000H Address 12 E000H Address 13 C000H Address 14 8000H Address 15

[0063] Table 2

[0064] It should be noted that 7K of program storage space and 1K of data storage space are allocated, with 16 words of address space assigned to each calibration point, as shown in Table 1. This is divided into two parts: the first part is one word (address 0), used to store the address information of the currently valid calibration data; the second part is 15 words (addresses 1 to 15), used to store the actual calibration data. Before calibration, the data at address 1 is used, with an initial value of 8000H. The initial values ​​of addresses 2 to 15 are all FFFFH, ensuring reliable data storage during calibration. Each calibration point is allowed 14 calibration attempts. When the OTP programming subroutine is called, it first uses the information at address 0 to determine the address of the currently valid calibration data, as shown in Table 2. If the data at address 0 is FFC0H, it indicates that the data at address 6 is the currently valid calibration data, and that there are 9 calibration attempts remaining. Further, new calibration data needs to be written to address 7 for the next calibration attempt. This process continues until 14 attempts are completed, indicating that the calibration address has been exhausted, and an error message is displayed. Therefore, the programming methods in Tables 1 and 2 show that this example conforms to... Figure 2 The OTP programming method flow shown in Embodiment 1.

[0065] Example 2

[0066] like Figure 3 As shown, this embodiment provides a microcontroller for implementing the OTP programming method provided in Embodiment 1. The microcontroller includes: a programming module 310 and a latching module 320, wherein:

[0067] like Figure 3 As shown, the programming module 310 is used for OTP programming.

[0068] Specifically, as an example, such as Figure 3 As shown, the programming module further includes a software version number, a hardware version number, and a key to prevent the programming module from being copied. The software version number corresponds to the OTP programming program in Embodiment 1; the hardware version number corresponds to the microcontroller; and the key is used for encryption operations of the programming program.

[0069] like Figure 3As shown in the example, the latch module 320 corresponds to the programming module 310 and is used to lock the programming module. It should be noted that if the programming module 310 completes the OTP programming process, the latch module 320 generates a serial number corresponding to the software version number, the hardware version number, and the key. This serial number is used to ensure that each microcontroller is unique, locking the programming module 310 that has completed the OTP programming process, preventing the programming module 310 from being repeatedly programmed, and ensuring a more secure application of the programming module 310. It should be further noted that any solution that can ensure the secure application of the programming module 310 is applicable and is not limited to this embodiment.

[0070] It should be noted that, as an example, such as Figure 3 As shown, according to the OTP programming method mentioned in Embodiment 1, the microcontroller has 7K of program storage space and 1K of data storage space. Addresses are assigned to each calibration point based on the function definition. During OTP programming, the storage address of the calibration point is first found through the function definition. The information at address 0 determines the address of the currently valid calibration data for that calibration point. When the cumulative calibration count is less than 14, the address is incremented by 1, and the internal circuitry of the microcontroller is used to program the new calibration data. This simplifies the programming process and increases the number of programming cycles while minimizing impact on program space. This achieves the goals of eliminating the need for an external EEPROM, saving space for upgrading and expanding the microcontroller's functionality, reducing the difficulty of implementing the microcontroller's hardware, and simplifying mass production processes. It should be noted that the microcontroller includes, but is not limited to, multimeter microcontrollers and electronic scale microcontrollers, and is not limited to this embodiment.

[0071] In summary, this invention defines a program storage space and a data storage space. Within the data storage space, multiple calibration point spaces are defined. Each calibration point space stores the address of the calibration data and the actual calibration data. The process involves selecting a calibration point, calling the OTP programming program, reading the value of address 0, and obtaining the address of the currently valid calibration data based on the value of address 0. The number of calibrations already performed is counted. If the number of calibrations is less than the calibration count threshold, the address is incremented by 1, new calibration data is written to the new address, and the new calibration data is stored at address 0. The programming process is then complete, and the OTP programming program exits. If the number of calibrations equals the calibration count threshold, an error message is displayed. This invention allocates an address to each calibration point, facilitating the programming of individual calibration data into the OTP, improving the utilization efficiency of the OTP storage space, and significantly reducing programming time. RAM is released after programming a single calibration point, resulting in minimal computational load. It saves program storage space and can expand the application of microcontrollers. Therefore, this invention effectively overcomes the various shortcomings of existing technologies and has high industrial application value.

[0072] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can 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 those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.

Claims

1. An OTP programming method, characterized in that, The OTP programming method includes at least the following: 1) Identify the memory and then calculate the storage space; 2) Allocate program storage space and data storage space in the storage space, allocate multiple calibration point spaces in the data storage space, and allocate current calibration data address space and calibration data space in each of the calibration point spaces; 3) Select a calibration point; the steps for selecting a calibration point include: retrieving the calibration points in the order of the storage space addresses; then retrieving the calibration data space that has not been burned, selecting the calibration point for burning; and locking the calibration points that have been burned to prevent the locked calibration points from being retrieved again. 4) Start OTP programming; 5) Read the value of the current calibration data address space, obtain the current valid calibration data based on the value, and then obtain the location of the current valid calibration data in the calibration data space; 6) Count the number of times calibration has been performed; 7) If the number of attempts is less than the calibration attempt threshold, increment the position of the calibration data space by 1, write the new calibration data to the new position, and simultaneously save the new calibration data in the current calibration data address space. Complete the OTP programming, generate the key, and exit the OTP programming process. If the number of attempts is equal to the calibration attempt threshold, display an error message and return to step 3.

2. The OTP programming method according to claim 1, characterized in that: The process of identifying the memory includes: identifying the product serial number of the memory and then determining whether the memory is legitimate; after confirming that the memory is legitimate, the structure of the memory is then identified; the process of calculating the storage space is to calculate the storage space used for OTP burning based on the structure of the memory.

3. The OTP programming method according to claim 1, characterized in that: Set the first address of each calibration point space to the current calibration data address space.

4. The OTP programming method according to claim 1, characterized in that: The calibration data space includes a default calibration data space and a programmed calibration data space. The second address of the calibration point space is set as the default calibration data space, and no new calibration data can be written there. The programmed calibration data space is used to write new calibration data.

5. The OTP programming method according to claim 1, characterized in that: The key is set in the following format: software identification code, memory hardware identification code, and random number. This is used to prevent the written calibration data from being stolen, thereby ensuring the security of the OTP programming process.

6. A microcontroller for implementing the OTP programming method as described in any one of claims 1 to 5, characterized in that: The microcontroller includes at least: a programming module and a latching module, wherein: The programming module is used for OTP programming; The latch module corresponds to the programming module and is used to lock the programming module.

7. A microcontroller according to claim 6, characterized in that: The programming module also includes a software version number, a hardware version number, and a key to prevent the programming module from being copied.

Citation Information

Patent Citations

  • OTP programming method and device

    CN106648713A

  • Writing method and device of programs

    CN106802811A