Method and device for adding checksum
The checksum addition method addresses the issue of inappropriate checksum addition by calculating checksums based on command type, ensuring robust data transmission integrity.
Patent Information
- Application Number
- JP2020070471
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2020-04-09
- Publication Date
- 2024-09-18
- Estimated Expiration
- 2040-04-09
AI Technical Summary
Conventional methods fail to add a checksum to data transmitted in response to a command in a manner appropriate to the command type.
A checksum addition method that includes command acquisition, data reading, and checksum calculation, where the checksum is calculated in units of data based on the type of command, ensuring appropriate checksum addition for different command types.
Ensures checksums are added to data in a manner appropriate to the command type, enhancing data integrity and error detection during transmission.
Smart Images

Figure 0007553041000004 
Figure 0007553041000007 
Figure 0007553041000001
Abstract
Description
[Technical field]
[0001] The present invention relates to a checksum adding method and a checksum adding device. [Background technology]
[0002] The following non-patent document 1 discloses a technology for an IC equipped with a temperature sensor and a humidity sensor, which reads sensor data stored in a register in response to an external command, calculates a checksum, and transmits the sensor data and the checksum to the outside. [Prior art documents] [Non-patent literature]
[0003] [Non-Patent Document 1] Silicon Laboratories Inc., "I2C HUMIDITY AND TEMPERATURE SENSOR", [online], [searched March 30, 2020], Internet<https: / / www.silabs.com / documents / public / data-sheets / Si7006-A20.pdf> Summary of the Invention [Problem to be solved by the invention]
[0004] However, in conventional technology, when data read in response to a command sent from a requester is sent to the requester, it is not possible to add a checksum to the data in a more appropriate manner in response to the command. [Means for solving the problem]
[0005] A checksum addition method according to one embodiment includes a command acquisition step of acquiring a command and address sent from a requestor, a data reading step of reading data from an address in accordance with the command, a checksum calculation step of calculating a checksum to be added to the data, and a data transmission step of transmitting the checksum and data to the requestor, where the checksum calculation step calculates a checksum in data units in accordance with the type of command. Effect of the Invention
[0006] According to one embodiment of a checksum addition method, when data read in response to a command sent from a requester is sent to the requester, a checksum can be added to the data in a more appropriate manner depending on the command. [Brief description of the drawings]
[0007] [Figure 1] FIG. 1 is a diagram showing a configuration of a detection system according to an embodiment; [Diagram 2] FIG. 2 is a diagram showing a functional configuration of a communication unit according to an embodiment; [Diagram 3] A flowchart showing the procedure of a checksum adding method by a communication unit according to an embodiment. [Figure 4] FIG. 1 is a diagram showing a first example of communication data transmitted and received by a communication unit according to an embodiment; [Diagram 5] FIG. 11 is a diagram showing a second example of communication data transmitted and received by a communication unit according to an embodiment; [Figure 6] FIG. 11 is a diagram showing a third example of communication data transmitted and received by a communication unit according to an embodiment; [Figure 7] FIG. 13 is a diagram showing an example of a checksum calculation performed by a communication unit according to an embodiment; DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0008] Hereinafter, an embodiment will be described with reference to the drawings.
[0009] (Configuration of detection system 10) 1 is a diagram showing a configuration of a detection system 10 (an example of a "sensor system") according to an embodiment. The detection system 10 shown in FIG. 1 includes a sensor 12, a sensor 14, an IC (Integrated Circuit) 20, and an MCU (Micro Controller Unit) 40.
[0010] The sensors 12 and 14 detect various detection targets (for example, temperature, strain, etc.). A differential sensor or a single-ended sensor can be used as the sensors 12 and 14. The number of sensors may be three or more, and may be provided inside the IC 20.
[0011] The IC 20 is an integrated circuit that performs a predetermined process on the sensor signals output from the sensors 12 and 14. For example, the IC 20 can amplify the sensor signals output from the sensors 12 and 14, convert the signals from analog signals to digital signals, and store the signals in the register 32.
[0012] The MCU 40 is an example of a "request source" and an "external device", and can read and write data from and to the register 32 of the IC 20 by sending a READ command or a WRITE command via I2C communication to the communication unit 34 of the IC 20. For example, the MCU 40 can read sensor data from the register 32 of the IC 20 and perform predetermined digital processing using the sensor data by sending a READ command to the communication unit 34.
[0013] (Configuration of IC20) As shown in FIG. 1, the IC 20 includes a multiplexer 22, a PGA (Programmable Gain Amplifier) 24, an AD converter 26, and a digital processing circuit 30.
[0014] The multiplexer 22 is connected to each of the sensors 12 and 14. The multiplexer 22 selects one of the multiple sensor signals output from each of the sensors 12 and 14, and outputs the selected one sensor signal to the PGA 24.
[0015] The PGA 24 is connected to the output terminal of the multiplexer 22. The PGA 24 is an amplifier capable of changing the gain. The PGA 24 amplifies the sensor signal output from the multiplexer 22 and outputs the amplified signal to the AD converter 26.
[0016] The AD converter 26 is connected to the output terminal of the PGA 24. The AD converter 26 converts the sensor signal output from the PGA 24 from an analog signal to a digital signal, and outputs the digital signal to the digital processing circuit 30.
[0017] The digital processing circuit 30 is connected to the output terminal of the AD converter 26. The digital processing circuit 30 has a register 32 and a communication unit 34. The digital processing circuit 30 performs a predetermined digital signal processing on the sensor signal (digital signal) output from the AD converter 26. For example, the digital processing circuit 30 stores the sensor signal (i.e., sensor data) output from the AD converter 26 in the register 32. The communication unit 34 of the digital processing circuit 30 reads and writes data from the register 32 in response to a command from the MCU 40. For example, the communication unit 34 reads various data (including sensor data) stored in the register 32 in response to a READ command transmitted from the MCU 40 via I2C communication, and transmits the data to the MCU 40 via I2C communication.
[0018] The communication unit 34 is an example of a "checksum adding device" and has a checksum adding function. The communication unit 34 can add a checksum (CRC (Cyclic Redundancy Checking) of I2C communication) to data read from the register 32 and transmit the data and the checksum to the MCU 40. In particular, the communication unit 34 of this embodiment can add a checksum to data using a different addition method for each type of command.
[0019] (Functional configuration of communication unit 34) 2 is a diagram showing a functional configuration of the communication unit 34 according to an embodiment. As shown in FIG. 2, the communication unit 34 includes a command acquisition unit 201, a data reading unit 202, a checksum calculation unit 203, and a data transmission unit 204.
[0020] The command acquisition unit 201 acquires the command and address sent from the MCU 40 via I2C communication with the MCU 40.
[0021] The data reading unit 202 reads data from the address of the register 32 obtained by the command obtaining unit 201 in response to the command obtained by the command obtaining unit 201 .
[0022] The checksum calculation unit 203 calculates a checksum to be added to the data read by the data reading unit 202 .
[0023] The data transmission unit 204 transmits the data read by the data reading unit 202 and the checksum calculated by the checksum calculation unit 203 to the MCU 40 via I2C communication with the MCU 40.
[0024] (Procedure for adding checksum by communication unit 34) FIG. 3 is a flowchart showing the procedure of a checksum adding method performed by the communication unit 34 according to one embodiment.
[0025] First, the command acquisition unit 201 acquires a command and an address transmitted from the MCU 40 (step S301: command acquisition step).
[0026] Next, the data reading unit 202 reads data from the address obtained in step S301 of the register 32 in response to the command obtained in step S301 (step S302: data reading step).
[0027] Next, the checksum calculation unit 203 calculates a checksum to be added to the data read in step S302 (step S303: checksum calculation step).
[0028] Next, the data transmission unit 204 transmits the checksum and the data to the MCU 40 (step S304: data transmission step). Then, the communication unit 34 ends the series of processes shown in FIG.
[0029] In this embodiment, in the checksum calculation process in step S303, the checksum calculation unit 203 calculates the checksum in data units according to the type of the command acquired in step S301.
[0030] For example, if the command acquired in step S301 is a READ command (an example of a "first read command"), the data reading unit 202 reads one piece of data of a predetermined data unit (8 bits) from the address acquired in step S301 of the register 32. Then, the checksum calculation unit 203 calculates a checksum for the one piece of data read from the register 32.
[0031] Furthermore, for example, if the command acquired in step S301 is a BURST READ command (an example of a "second read command"), the data reading unit 202 reads a plurality of data of a predetermined data unit (8 bits) from the address acquired in step S301 of the register 32. Then, the checksum calculation unit 203 calculates a checksum for each of the plurality of data read from the register 32.
[0032] Furthermore, for example, when the command acquired in step S301 is a RESULT READ command (an example of a “third read command”), the data reading unit 202 reads a group of data including a plurality of data of a predetermined data unit (8 bits) from the address acquired in step S301 of the register 32. Then, the checksum calculation unit 203 calculates a checksum for the group of data read from the register 32.
[0033] Furthermore, in this embodiment, in the checksum calculation process of step S303, the checksum calculation unit 203 calculates a checksum by including the command obtained in step S301, the address obtained in step S301, and the data read in step S302 in the calculation targets.
[0034] (First example of communication data) 4 is a diagram showing a first example of communication data transmitted and received by the communication unit 34 according to an embodiment. This first example shows communication data and a communication order transmitted and received between the communication unit 34 and the MCU 40 when a READ command is transmitted from the MCU 40.
[0035] 4 to 6, colored data represents data transmitted from the MCU 40 to the communication unit 34, and non-colored data represents data transmitted from the communication unit 34 to the MCU 40.
[0036] 4, first, the MCU 40 transmits to the communication unit 34 a slave address followed by the register address (Address) of the register 32 in which the data to be read is stored. The slave address (Slave address) is an address unique to the IC 20. Next, the MCU 40 transmits to the communication unit 34 a READ command (R) followed by the slave address (Slave address).
[0037] Next, in response to receiving the READ command (R), the communication unit 34 reads one piece of data (Data1) of a predetermined data unit (8 bits) from the specified address of the register 32. The communication unit 34 then calculates a checksum (CRC1) for the one piece of data (Data1) read from the register 32, the slave address, the register address (Address), and the command (R). Furthermore, the communication unit 34 transmits the one piece of data (Data1) to the MCU 40, and then transmits the checksum (CRC1) to the MCU 40.
[0038] (Second example of communication data) 5 is a diagram showing a second example of communication data transmitted and received by the communication unit 34 according to an embodiment. This second example shows communication data and a communication order transmitted and received between the communication unit 34 and the MCU 40 when a BURST READ command is transmitted from the MCU 40.
[0039] 5, first, the MCU 40 transmits a slave address followed by the register address (Address) of the register 32 in which the data to be read is stored to the communication unit 34. Next, the MCU 40 transmits a BURST READ command (R) to the communication unit 34 following the slave address (Slave address).
[0040] Next, in response to receiving the BURST READ command (R), the communication unit 34 reads out a plurality of data (Data1, DATA2) of a predetermined data unit (8 bits) from the specified address of the register 32. Then, the communication unit 34 calculates checksums (CRC1, CRC2) for each of the plurality of data (Data1, DATA2) read out from the register 32. At this time, for the checksum (CRC1) of the first data (Data1), the communication unit 34 calculates the checksum (CRC1) for the first data (Data1), the slave address (Slave address), the register address (Address), and the command (R). Furthermore, the communication unit 34 transmits the first data (Data1), the checksum (CRC1) of the first data, the second data (Data2), and the checksum (CRC2) of the second data to the MCU 40 in that order.
[0041] (Third example of communication data) 6 is a diagram showing a third example of communication data transmitted and received by the communication unit 34 according to an embodiment. This third example shows communication data and a communication order transmitted and received between the communication unit 34 and the MCU 40 when a RESULT READ command is transmitted from the MCU 40.
[0042] 6, first, the MCU 40 transmits a slave address followed by the register address (Address) of the register 32 in which the data to be read is stored to the communication unit 34. Next, the MCU 40 transmits a RESULT READ command (R) to the communication unit 34 following the slave address (Slave address).
[0043] Next, in response to receiving the RESULT READ command (R), the communication unit 34 reads out a group of data (24 bits) including a plurality of data (Data1, DATA2, DATA3) of a predetermined data unit (8 bits) from the specified address of the register 32. The communication unit 34 then calculates a checksum (CRC1) for the group of data read out from the register 32, the slave address, the register address, and the command (R). Furthermore, the communication unit 34 transmits the first data (Data1), the second data (Data2), the third data (Data3), and the checksum (CRC1) of the group of data in order to the MCU 40. Note that the communication unit 34 may also read out a group of data (16 bits) including a plurality of data (Data1, DATA2) of a predetermined data unit (8 bits) from the specified address of the register 32.
[0044] In this embodiment, the communication unit 34 sets the initial value to "0xFF" and converts the data (8 bits) to be calculated using a generating polynomial for CRC-8 {X 8 +X 5 +X 4 +1} and calculate the remainder as the checksum.
[0045] In this embodiment, the communication unit 34 adds checksums to three types of READ commands (the READ command, the BURST READ command, and the RESULT READ command).
[0046] (Checksum calculation example) Fig. 7 is a diagram showing an example of a checksum calculation performed by the communication unit 34 according to an embodiment. Fig. 7 shows an example in which the communication unit 34 calculates the checksums (CRC1, CRC2) of the first data (Data1) and the second data (Data2) read from the register 32 in response to receiving a BURST READ command (R).
[0047] 7, the communication unit 34 calculates the checksum (CRC1) of the first data (Data1) in the order of an initial value, a slave address (Slave address)+command (R), a register address (Address), and the first data (Data1). The initial value is "0xFF" and the first data (Data1) is "0x00". In this case, the communication unit 34 calculates "0xA2" as the checksum (CRC1) of the first data (Data1).
[0048] 7, the communication unit 34 calculates the checksum (CRC2) of the second data (Data2) using an initial value and the second data (Data2). The initial value is "0xFF" and the second data (Data2) is "0x00". In this case, the communication unit 34 calculates "0xAC" as the checksum (CRC2) of the second data (Data2).
[0049] As described above, the communication unit 34 in one embodiment includes a command acquisition unit 201 that acquires a command and address transmitted from the MCU 40, a data reading unit 202 that reads data from the address in accordance with the command, a checksum calculation unit 203 that calculates a checksum to be added to the data, and a data transmission unit 204 that transmits the checksum and data to the MCU 40, and the checksum calculation unit 203 calculates the checksum in data units according to the type of command.
[0050] As a result, when the communication unit 34 of one embodiment transmits data read in response to a command transmitted from the MCU 40 to the MCU 40, the communication unit 34 can add a checksum to the data in a more appropriate manner in response to the command.
[0051] In addition, in one embodiment of the communication unit 34, when the command acquired by the command acquisition unit 201 is a READ command, the data reading unit 202 reads out one piece of data of a predetermined data unit (8 bits) from the address, and the checksum calculation unit 203 calculates a checksum for the one piece of data.
[0052] As a result, when the communication unit 34 in one embodiment transmits data read in response to a READ command transmitted from the MCU 40 to the MCU 40, the communication unit 34 can add a checksum to the data in a more appropriate manner in response to the READ command.
[0053] Furthermore, in one embodiment of the communication unit 34, when the command acquired by the command acquisition unit 201 is a BURST READ command, the data reading unit 202 reads out multiple data of a predetermined data unit (8 bits) from the address, and the checksum calculation unit 203 calculates a checksum for each of the multiple data.
[0054] As a result, when the communication unit 34 in one embodiment transmits data read in response to a BURST READ command transmitted from the MCU 40 to the MCU 40, the communication unit 34 can add a checksum to the data in a more appropriate manner in response to the BURST READ command.
[0055] Furthermore, in a communication unit 34 according to one embodiment, when the command acquired by the command acquisition unit 201 is a RESULT READ command, a data reading unit 202 reads out a group of data including a plurality of data of a predetermined data unit (8 bits) from an address, and a checksum calculation unit 203 calculates a checksum for the group of data.
[0056] As a result, when the communication unit 34 in one embodiment transmits data read in response to a RESULT READ command sent from the MCU 40 to the MCU 40, it can add a checksum to the data in a more appropriate manner in response to the RESULT READ command.
[0057] Furthermore, in the communication unit 34 according to one embodiment, the checksum calculation unit 203 calculates a checksum including the command, address, and data as calculation targets.
[0058] This allows the communication section 34 according to the embodiment to check for code errors including commands, addresses, and data.
[0059] Although one embodiment of the present invention has been described in detail above, the present invention is not limited to these embodiments, and various modifications and changes are possible within the scope of the gist of the present invention described in the claims.
[0060] The IC20 described in the above embodiment is used as a so-called AFE (Analog Front End) that connects a strain gauge that outputs an analog signal and a microcomputer that performs digital processing in a load detection device that detects a load applied to an object. However, the IC20 is not limited to this, and may be connected to a sensor other than a strain gauge, and may be used in a system configuration other than the detection system 10 described in the above embodiment. [Explanation of symbols]
[0061] 10 Detection system (sensor system) 12,14 Sensors 20 IC 22 Multiplexer 24 PGA 26 A / D converter 30 Digital Processing Circuit 32 Registers 34 Communications Department 40 MCU (request source, external device)
Claims
1. a command acquisition step of acquiring a command transmitted from a request source, a register address which is an address of a register in which data to be read is stored, and a slave address which is a unique address; a data reading step of reading data from the register in response to the command and the register address; a checksum calculation step of calculating a checksum to be added to the data; a data transmission step of transmitting the checksum and the data to the requester; Including, In the checksum calculation step, Calculating the checksum based on the register address, the slave address, the command, and the data. A checksum adding method comprising the steps of:
2. When the command acquired by the command acquiring step is a first read command, In the data reading step, reading one data of a predetermined data unit from the address; In the checksum calculation step, Calculating the checksum for the one data 2. The method for adding a checksum according to claim 1.
3. When the command acquired by the command acquiring step is a second read command, In the data reading step, reading out a plurality of data of a predetermined data unit from the address; In the checksum calculation step, Calculating the checksum for each of the plurality of data 3. The checksum adding method according to claim 1 or 2.
4. When the command acquired by the command acquiring step is a third read command, In the data reading step, reading a group of data including a plurality of data of a predetermined data unit from the address; In the checksum calculation step, Calculating the checksum for the group of data 4. The checksum adding method according to claim 1, wherein the checksum adding method is a method for adding a checksum to a plurality of checksums.
5. a command acquisition unit that acquires a command transmitted from a request source, a register address that is the address of a register in which data to be read is stored, and a slave address that is a unique address; a data reading unit that reads data from the register in response to the command and the register address; A checksum calculation unit that calculates a checksum to be added to the data; a data transmission unit that transmits the checksum and the data to the requester; Equipped with The checksum calculation unit Calculating the checksum based on the register address, the slave address, the command, and the data.
2. A checksum adding device comprising:
6. A sensor; an integrated circuit that performs a predetermined process on the output signal of the sensor; an external device that obtains necessary data from the integrated circuit; A sensor system comprising: The external device is Transmitting to the integrated circuit an arbitrary command for acquiring the necessary data from among a plurality of types of commands, a register address which is an address of a register in which the data to be read is stored, and a slave address which is a unique address; The integrated circuit comprises: a command acquisition unit that acquires a command transmitted from the external device, a register address that is an address of the register, and the slave address; a data reading unit that reads data from the register in response to the command and the register address; A checksum calculation unit that calculates a checksum to be added to the data; a data transmission unit that transmits the checksum and the data to the external device; Equipped with The checksum calculation unit Calculating the checksum based on the register address, the slave address, the command, and the data. A sensor system comprising:
Citation Information
Patent Citations
Data communication method and data communication system
JP2013058845A
Communication control device and communication control method
JP2014023013A
I2C bus protocol controller with fault tolerance
US6728908B1
