Erroneous register write prevention circuit, microcontroller, and erroneous register write prevention method

The register write error prevention circuit enables user-defined protection of specific registers in microcontrollers, addressing CPU-induced errors without increasing circuit size, ensuring reliable operation.

JP2024160577APending Publication Date: 2024-11-14KK TOSHIBA +1
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
JP2023075728
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-05-01
Publication Date
2024-11-14

AI Technical Summary

Technical Problem

Existing microcontrollers face the challenge of preventing erroneous register writes due to CPU malfunctions caused by disturbance noise, which can lead to serious issues, and existing solutions that provide write protection for all registers increase circuit scale, failing to accommodate user-specific protection needs.

Method used

A register write error prevention circuit that allows users to selectively protect specific registers through a selection unit, address comparison, and write control mechanism, preventing erroneous writes without increasing circuit size.

Benefits of technology

Effectively prevents erroneous register writes based on user-defined settings, ensuring reliable operation without enlarging the circuit footprint, while allowing normal writes to proceed as intended.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2024160577000001_ABST
    Figure 2024160577000001_ABST
Patent Text Reader

Abstract

To provide an erroneous register write prevention circuit 2 with which it is possible to prevent erroneous writes to a discretionary register which is selected in accordance with a user's setting and needs to be protected against erroneous writes.SOLUTION: An erroneous register write prevention circuit 2 comprises: a selection unit 22 for selecting a discretionary first register 40X to be protected against erroneous writes among a plurality of registers 40; a memory 26 for storing the first address of the first register 40X; an address comparison unit 25 which, when a write signal to a register at a second address among the plurality of registers 40 is inputted, compares the first address with the second address, and outputs a match signal when the first address and the second address match; and a write control unit 30 for disabling outputting the write signal to the first register when the match signal is inputted once from the address comparison unit 25.SELECTED DRAWING: Figure 2
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] 1. Field of the Invention The present invention relates to a circuit for preventing erroneous write to a register, a microcontroller having the circuit for preventing erroneous write to a register, and a method for preventing erroneous write to a register. [Background technology]

[0002] Microcontrollers that control controlled devices such as motors in real time can have their CPUs malfunction due to disturbances such as noise, resulting in incorrect data being written to registers.

[0003] By providing each register with a write-protect register, it is possible to prevent erroneous writing to the register, but this increases the circuit scale.

[0004] By providing write-protect registers only to specific registers at the design stage, manufacturers can prevent an increase in circuit size. Also, for example, in a microcontroller with one write-protect register provided in the clock generation circuit, it is possible to permit or prohibit writing to all registers (register group) in the clock generation circuit by specifying an address.

[0005] However, the registers that the manufacturer expects to be protected from erroneous writes may not match the registers that the user wants to protect. In other words, depending on the user's usage pattern, even if a register is not provided with a write-protect register, if an erroneous signal is written to it, a serious problem may occur. [Prior art documents] [Patent documents]

[0006] [Patent Document 1] Japanese Patent Application Publication No. 8-235073 Summary of the Invention [Problem to be solved by the invention]

[0007] The problem that the present invention aims to solve is to provide a register erroneous write prevention circuit capable of preventing erroneous writing to any register selected in accordance with a user's setting, a microcontroller having a register erroneous write prevention circuit capable of preventing erroneous writing to any register selected in accordance with a user's setting, and a register erroneous write prevention method capable of preventing erroneous writing to any register selected in accordance with a user's setting. [Brief description of the drawings]

[0008] [Figure 1] FIG. 2 is a configuration diagram of a microcontroller according to an embodiment. [Diagram 2] FIG. 2 is a configuration diagram of a register erroneous write prevention circuit according to an embodiment. [Diagram 3] FIG. 2 is a configuration diagram of a write control unit according to the embodiment. [Figure 4] FIG. 13 is a configuration diagram of a write control unit according to the first modified example. [Diagram 5] FIG. 11 is a configuration diagram of a write control unit according to a second modified example. [Figure 6] 13 is a flowchart of a method for preventing erroneous writing to a register of a microcontroller according to a second modified example. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0009] The register erroneous write prevention circuit of the embodiment includes a selection unit that selects an arbitrary first register from a plurality of registers for preventing erroneous write, a memory that stores a first address of the first register, an address comparison unit that compares the first address with the second address when a write signal is input to a register with a second address from the plurality of registers, and outputs a match signal when the first address and the second address match, and a write control unit that does not output the write signal to the first register when the match signal is input once from the address comparison unit.

[0010] A microcontroller of an embodiment has a plurality of registers and a register erroneous write prevention circuit, and the register erroneous write prevention circuit includes a selection unit that selects an arbitrary first register from the plurality of registers to which erroneous write is to be prevented, a memory that stores a first address of the first register, an address comparison unit that compares the first address with the second address when a write signal is input to a register with a second address from the plurality of registers and outputs a match signal if the first address and the second address match, and a write control unit that does not output the write signal to the first register when the match signal is input once from the address comparison unit.

[0011] In an embodiment of a method for preventing erroneous writes to a register, an arbitrary first register for preventing erroneous writes is selected from among a plurality of registers in accordance with a user setting, a first address of the first register is stored in a memory, and when a write signal is input to a register with a second address among the plurality of registers, the first address and the second address are compared, and if the first address and the second address match, a match signal is output, and if the match signal is input once, the write signal is not output to the first register.

[0012] Hereinafter, the microcontroller 1 and the register erroneous write prevention circuit 2 according to the embodiment will be described in detail with reference to the drawings. In the drawings based on the embodiment, illustrations and reference numerals of some components are omitted.

[0013] As shown in FIG. 1, a microcontroller 1 that controls a controlled unit 3 includes a CPU 10, a ROM 11, a RAM 12, an input unit 14, a clock circuit 15, and a register erroneous write prevention circuit 2.

[0014] The CPU 10 is a central processing unit that controls the overall operation of the microcontroller 1. The ROM 11 stores programs and the like. The RAM 12 is a temporary storage unit that is used when executing a program read from the ROM 11. The controlled unit 3 is, for example, a motor control unit. The input unit 14 allows the user to set the microcontroller 1 and receives feedback signals from the controlled unit 3.

[0015] The register erroneous write prevention circuit 2 prevents erroneous writing to any register selected by the user. Hereinafter, the selected register for which erroneous writing is to be prevented is referred to as a first register 40X (FIG. 2). The multiple registers 40 are temporary storage units of the CPU 10, the controlled unit 3, or a functional unit (not shown).

[0016] As shown in FIG. 2, the register erroneous write prevention circuit 2 includes a selection circuit 22, a setting circuit 24, a memory 26 which is a register table 26, an address comparator 25, and a write control circuit 30.

[0017] The selection circuit 22 is a selection unit that selects any one or more first registers 40X that prevent erroneous writing from among the multiple registers 40 in accordance with a user's setting. The setting circuit 24 is a setting unit that sets, for example, an erroneous writing prevention level in accordance with a user's setting. The selection circuit 22 and the setting circuit 24 operate in accordance with, for example, a user's setting input via the input unit 14.

[0018] In addition, when the control contents set in advance by the user are stored in, for example, the RAM 12, the selection circuit 22 and the setting circuit 24 operate according to the settings stored in the RAM 12. Furthermore, the control contents may be transferred to the internal memory of the write control circuit 30. In this case, the selection circuit 22 and the setting circuit 24 operate according to the settings stored in the internal memory of the write control circuit 30.

[0019] In the case where the control contents selected by the user are transferred to the RAM 12, the memory 26, or the internal memory of the write control circuit 30, the selection circuit 22 and the setting circuit 24 are not essential components of the microcontroller 1.

[0020] The memory 26, which is a register table that stores first addresses that are addresses of the first registers 40X, may be a part of the RAM 12, or the stored data may be transferred to the RAM 12. For example, when 32 registers are set as the first registers 40X, a 256-bit area of ​​the RAM 12 is used as the memory 26 to store 32 8-bit first addresses.

[0021] The address comparator 25 is an address comparison unit that, when a write signal is input to a register with a second address among multiple registers, compares the first address with the second address and outputs a match signal if the first address and the second address match.

[0022] 3, the write control circuit 30 receives a write signal from the CPU 10 and a match signal from the address comparator 23. The write control circuit 30 is a write control unit including a gating circuit 31 that does not output a write signal to the first register 40X when a match signal is input. The gating circuit 31 is an AND circuit that receives an inverted signal of the match signal.

[0023] The register erroneous write prevention circuit 2 prohibits writing to a register based on a match signal between an address accessed by the CPU 10 and a register address registered in a register table 26.

[0024] The method for preventing erroneous writes to a register comprises the steps of: selecting an arbitrary first register 40X from among a plurality of registers 40, which is to prevent erroneous writes, according to a user setting; storing a first address of the first register 40X in a memory 26; when a write signal is input to a register having a second address among the plurality of registers 40, comparing the first address with the second address; outputting a match signal if the first address and the second address match; and not outputting the write signal to the first register 40X if the match signal has been input once.

[0025] Even if the CPU 10 outputs a write signal to the first register 40X that prevents erroneous writing due to a malfunction, writing is not performed to the first register 40X by the register erroneous write prevention circuit 2. The microcontroller 1 and the register erroneous write prevention circuit 2 can prevent erroneous writing to any register according to the user's usage environment without increasing the circuit size.

[0026] Needless to say, for registers for which erroneous write protection is not set (such as register 40A), normal write operations are performed since no match signal is output from address comparator 25. Also, the user can delete the first register 40X, re-register it, or register a different address.

[0027] <Modification> The microcontrollers 1A, 1B and register erroneous write prevention circuits 2A, 2B of the first and second modifications are similar to the microcontroller 1 and register erroneous write prevention circuit 2 of the embodiment, so the same components are given the same reference numerals and descriptions thereof are omitted.

[0028] In the microcontroller 1, not only erroneous writing but also writing during normal operation is prevented in the first register 40X in which erroneous writing prevention is set. In other words, the first register 40X is registered as a write-prohibited register.

[0029] In contrast, in the microcontrollers 1A and 1B of the modified examples, the first register 40X is a write-restricted register that prevents erroneous writing due to malfunction of the CPU 10 or the like, but allows writing when the CPU 10 operates normally.

[0030] <Variation 1> For example, when the CPU 10 of the microcontroller 1A writes to the first register 40X for which erroneous write prevention is set, the CPU 10 outputs a write signal to the first register 40X twice in succession, for example, at an interval of a first time T1. The write control circuit 30A outputs a write signal to the register 40X of the first address when the write signal is input twice in succession, even if the write signal is to the first register 40X for which erroneous write prevention is set. In other words, the write control circuit 30A judges a write signal input only once as a malfunction, but judges a write signal input twice in succession with the same address as a normal operation. In other words, the write control circuit 30A judges that a write signal input twice in succession to the register of the same address is not input twice in succession if it is a malfunction.

[0031] The write control circuit 30A of the microcontroller 1A prevents erroneous writing to any register for which the user has set erroneous write prevention, but allows writing by normal operation.

[0032] It is preferable that the setting circuit 24 of the register erroneous write prevention circuit 2A of the microcontroller 1A can set the predetermined number N of times that a write signal is continuously input to the same register in order to execute writing by normal operation. In other words, it is preferable that the predetermined number N is variable. The larger the predetermined number N, the higher the performance of preventing erroneous writing, but the longer the write process will take. For this reason, it is preferable that the predetermined number N is 2 or more and 5 or less.

[0033] As shown in FIG. 4, the write control circuit 30A includes an AND circuit 31A, a first counter circuit 32, an RS flip-flop circuit 33, and an AND circuit .

[0034] When the count of the first counter circuit 32 reaches the set value A, the RS flip-flop circuit 33 is set, and the AND circuit 34 is released. The released state means a state in which a write signal can be output to the register when a logical AND signal of the next match signal and the write signal is input. Therefore, when a logical AND signal of the next match signal and the write signal is input from the AND circuit 34 to the register, data is written to the register. That is, in the above example, the B value is set to (A value + 1). When the first counter circuit 32 reaches the B value, the RS flip-flop circuit 33 is reset, the AND circuit 34 gates the write signal, and the write control circuit 30A is initialized to a write-prohibited state.

[0035] As described above, the write control circuit 30A counts the logical product of the match signal and the register write signal, and releases the write-prohibited state when it reaches a first predetermined number A, and outputs a write signal to the register (data is written to the register) a predetermined number B, after which it is initialized to the write-prohibited state.

[0036] For example, when A=2 and B=3, the write prohibition to the first register 40X is lifted when the logical product of the register write signal and the match signal is calculated twice, and the register write signal is input to the register when the logical product of the register write signal and the match signal is calculated three times.

[0037] The predetermined number of times N may be set according to a user's setting, or may be automatically set by the CPU 10 according to a preset reliability level. The reliability level is a level of malfunction prevention performance. For example, when the reliability level is set to H (high), the predetermined number of times N may be set to be larger than when the reliability level is set to L (low).

[0038] For example, when (N=3), the first time T1 from the input of the first write signal to the input of the second write signal may be different from the first time T1 from the input of the second write signal to the input of the third write signal.

[0039] For example, when used in an environment with a lot of disturbance noise, the predetermined number N is set to be larger than when used in an environment with little disturbance noise. Also, for a register whose malfunction may cause a serious breakdown or accident, the predetermined number N is set to be larger.

[0040] It should be noted that since a match signal is not output to a register for which erroneous write protection is not set (for example, register 40A, etc.), it goes without saying that a write operation is performed with a single write signal.

[0041] <Variation 2> The microcontroller 1B and the circuit 2B for preventing erroneous write to a register in the second modification are similar to the microcontroller 1A and the circuit 2A for preventing erroneous write to a register in the first modification, so the same components are given the same reference numerals and the description thereof is omitted.

[0042] The setting circuit 24 of the register erroneous write prevention circuit 2B of the microcontroller 1B can set not only the predetermined number N of times of input of a write signal for writing to the first register 40X that has been set for erroneous write prevention, but also the second time T2 until the predetermined number N of inputs is completed.

[0043] As shown in FIG. 5, the write control circuit 30B includes an AND circuit 31A, a first counter circuit 32, an RS flip-flop circuit 33, an AND circuit , a second counter circuit 35, and an OR circuit .

[0044] The second counter circuit 35 measures time based on the clock signal. If the second counter circuit 35 does not receive N consecutive signals by the second time T2, the second counter circuit 35 is initialized to a register write inhibit state.

[0045] After register write is released at count A, if the number of writes reaches a predetermined number N (count B) within the second time T2, a write signal is output to the first register 40X. If the number of writes does not reach the count B value even after the time limit (second time T2) has elapsed, register write is prohibited. In other words, no write signal is output to the register. The second time T2 is set by the arbitrarily settable C value of the second counter circuit 35.

[0046] The shorter the second time T2, the higher the performance of preventing erroneous writing, but conversely, there is a risk that the write signal that should be written will not be output. For this reason, it is preferable that the second time T2 is, for example, equal to or greater than the shortest time TS required to input the write signal N times, and equal to or less than twice the shortest time TS.

[0047] The second time T2 may be set according to a user's setting, like the predetermined number of times N, or may be automatically set according to a preset reliability level.

[0048] As described above, the register erroneous write prevention circuit 2 of the microcontroller 1B does not output a write signal unless a predetermined number N of write signals are input multiple times at intervals of a first time T1 and the write signal is not input multiple times within a predetermined second time T2.

[0049] 6 shows a flowchart of the method for preventing erroneous write to a register of the microcontroller 1B according to the modified example 2. The method for preventing erroneous write to a register of the microcontroller according to the modified example 2 includes the steps of the embodiment and the method for preventing erroneous write to a register of the microcontroller according to the modified example 1.

[0050] <Step S10> The register for setting the erroneous write protection is selected by the user. Note that a register for setting the erroneous write protection may also be set by the manufacturer at the time of shipment. The register for setting the erroneous write protection set by the manufacturer is stored in a non-volatile storage unit that cannot be changed by the user, such as a ROM. In contrast, the register for the user who obtains the product to set at his / her discretion is stored in a non-volatile storage unit that can be rewritten by the user, such as a flash memory or an EPROM. In other words, a microcontroller in which a register for setting the erroneous write protection is stored in memory 26, which is a non-volatile storage unit that can be rewritten by the user, can be regarded as having a register for setting the erroneous write protection selected by the user.

[0051] The user registers the selected register for setting erroneous write protection in the memory 26. Furthermore, the predetermined number of times N for writing data to the register for which erroneous write protection is set and the second time T2 are also registered in the write control circuit 30B.

[0052] <Step S20> A write signal to any one of the registers 40 and the address (second address) of the register to be written to are input.

[0053] <Step S30> The address comparator 25 compares the address (first address) of the register for which erroneous write protection is set and which is registered in the register table 26 with the address (second address) of the write signal.

[0054] <Step S40> If the addresses do not match (NO), in step S70, the write control circuit 30B outputs a write signal to the register at the second address.

[0055] <Step S50> If the addresses match (S40: YES), that is, if the signal is for a write to a register at a first address that is set to prevent erroneous writing, the write control circuit 30B determines whether the number of consecutive writes to that register is a predetermined number N. If the number of writes is N (YES), in step S70, the write control circuit 30B outputs a write signal even to a register at a second address, that is, a register at a first address that is set to prevent erroneous writing.

[0056] <Step S60> If the number of write operations is less than N (S50: NO), the write control circuit 30B determines whether the time from the first write operation has elapsed a predetermined second time T2.

[0057] If the second time T2 has elapsed (YES), the write control circuit 30B determines that this write is not normal and ends the series of processes for this write. Then, the write process to a new register with a different address is repeated from step S20.

[0058] If the second time T2 has not elapsed (NO), the write control circuit 30B again proceeds to the step of inputting a write signal to the register of the same address (S20). Note that, even in S20, if the second time T2 has elapsed (step S65: YES), the write control circuit 30B determines that this write is not a normal write intended by the user, and ends the series of processes for this write.

[0059] Also, although not shown, in step S20, if a write signal is input to a register having an address different from the address for which the number of writes was being counted, the write control circuit 30B also ends writing to the register having the address for which the number of writes was being counted.

[0060] At least one of the functional units such as the microcontroller 1 in each embodiment may be configured by an internal circuit of a processor operated by software, or may be configured by a dedicated hardware circuit.

[0061] Moreover, the controlled unit 3 is not limited to a motor control unit, and there is no restriction on its use.

[0062] Although some embodiments of the invention have been described, these embodiments are presented as examples and are not intended to limit the scope of the invention. These novel embodiments can be implemented in various other forms, and various omissions, substitutions, and modifications can be made without departing from the spirit of the invention. These embodiments and their modifications are included in the scope and spirit of the invention, and are included in the scope of the invention and its equivalents described in the claims. [Explanation of symbols]

[0063] 1, 1A, 1B… Microcontroller 2, 2A, 2B... Miswrite prevention circuit 3…Controlled part 10. CPU 11...ROM 12…RAM 14... Input unit 22... Selection circuit 24, 24A, 24B... Setting circuit 25... Address comparator 26... Memory (register table) 30, 30A, 30B... Write control circuit 31... Gating circuit 31A…AND circuit 32... First counter circuit 33... RS flip-flop circuit 34... AND circuit 35... Second counter circuit 36... NOR circuit 40... Register 40X... First register

Claims

1. a selection unit that selects an arbitrary first register that is to be prevented from erroneous writing from among the plurality of registers; a memory for storing a first address of the first register; an address comparator that, when a write signal is input to a register having a second address among the plurality of registers, compares the first address with the second address, and outputs a match signal when the first address and the second address match; a write control unit that does not output the write signal to the first register when the match signal is input once from the address comparison unit.

2. 2. The circuit for preventing erroneous write to a register according to claim 1, wherein the first register is selected according to a user setting.

3. A setting unit that sets a number of predetermined times that the write signal is continuously input to the write control unit, 3. The circuit for preventing erroneous write to a register according to claim 2, wherein the write control section outputs the write signal when the write signal and the match signal are input consecutively a predetermined number of times.

4. 4. The circuit for preventing erroneous write to a register according to claim 3, wherein the predetermined number of times is set according to a user setting.

5. 4. The circuit for preventing erroneous write to a register according to claim 3, wherein the predetermined number of times is automatically set in accordance with a preset reliability level.

6. the plurality of predetermined times of the write signal are input consecutively at a first time interval; The register erroneous write prevention circuit according to any one of claims 3 to 5, characterized in that the write control unit outputs the write signal when the write signal and the match signal are input consecutively a predetermined number of times within a predetermined second time period.

7. 7. The circuit for preventing erroneous write to a register according to claim 6, wherein the second time period is set according to a user setting.

8. 8. The circuit for preventing erroneous write to a register according to claim 7, wherein the second time period is automatically set in accordance with a preset reliability level.

9. A plurality of registers and a register erroneous write prevention circuit, The register erroneous write prevention circuit includes: A selection unit that selects an arbitrary first register that is to be prevented from being written erroneously from among the plurality of registers; a memory for storing a first address of the first register; an address comparator that, when a write signal is input to a register having a second address among the plurality of registers, compares the first address with the second address, and outputs a match signal when the first address and the second address match; a write control unit that does not output the write signal to the first register when the match signal is input once from the address comparison unit.

10. An arbitrary first register that prevents erroneous writing is selected from among the plurality of registers according to a user setting; a first address of the first register is stored in a memory; when a write signal is input to a register having a second address among the plurality of registers, the first address is compared with the second address, and when the first address and the second address match, a match signal is output; 2. A method for preventing erroneous write to a register, comprising the steps of: not outputting the write signal to the first register when the match signal is input once.

Citation Information

Patent Citations

  • Protection circuit of register

    JP1999073371A

  • Interruption control circuit and microcontroller

    JP2001043111A

  • Write-protect method

    JP2003015958A

  • microprocessor

    JP2003316649A

  • Write protect method

    US20030005241A1