Home - Knowledge - Details

MCU Technical Principles

The MCU is connected to the temperature sensor through the I2C bus. The I2C bus occupies two MCU input and output port lines, and the communication between the two is completely completed by software. The address of the temperature sensor can be set through 2 address pins, which allows 8 such sensors to be connected simultaneously on one I2C bus. In this scheme, the 7-bit address of the sensor has been set to 1001000. When the MCU needs to access the sensor, it first sends an 8-bit register pointer, and then sends the sensor address (7-bit address, low bit is WR signal). There are three registers in the sensor that can be used by the MCU, and the 8-bit register pointer is used to determine which register the MCU should use. In this scheme, the main program will continuously update the configuration register of the sensor, which will cause the sensor to operate in a single step mode and measure the temperature every time it is updated.

To read the content of the sensor measurement value register, the MCU must first send the sensor address and register pointer. The MCU sends a start signal, then sends the sensor address, and sets the RD/WR pin to high level to read the measurement value register.

In order to read the 16 bit data in the sensor measurement value register, the MCU must communicate with the sensor twice for 8-bit data. When the sensor is powered on and working, the default measurement accuracy is 9 bits, with a resolution of 0.5C/LSB (ranging from -128.5C to 128.5C). This scheme adopts the default measurement accuracy, and the sensor can be reset as needed to increase the measurement accuracy to 12 bits. If only a general temperature indication, such as an automatic temperature regulator, is required, then a resolution of 1C can meet the requirements. In this case, the low 8-bit data of the sensor can be ignored, and only the high 8-bit data can meet the design requirement of a resolution of 1C. Due to the fact that the register is read in the order of first 8 high bits and then 8 low bits, the low 8 bit data can be read or not. There are two advantages to reading only the high 8-bit data. Firstly, it can shorten the working time of MCU and sensors, and reduce power consumption; The second is that it does not affect the resolution index.

After the MCU reads the measured values of the sensor, the next step is to convert them and display the results on the LCD. The entire processing process includes determining the sign of the displayed result, converting the binary code to BCD code, and transferring the data to the relevant registers of the LCD.

After the data processing is completed and the results are displayed, the MCU will issue a single step command to the sensor. A single step command will cause the sensor to initiate a temperature test and then automatically enter the waiting mode until the analog-to-digital conversion is completed. After the MCU issues a single step command, it enters LPM3 mode, and the MCU system clock continues to work, generating a timed interrupt to wake up the CPU. The length of the timing can be adjusted through programming to meet the needs of specific applications.

Send Inquiry

You Might Also Like