8.8.1. LM75B (NXP)

8.8.1.1. Introduction

The LM75B is a temperature-to-digital converter using an on-chip band gap temperature sensor and Sigma-Delta A-to-D conversion technique with an overtemperature detection output. The LM75B can be configured for different operation conditions. It can be set in normal mode to periodically monitor the ambient temperature, or in shutdown mode to minimize power consumption. The OS output operates in either of two selectable modes: OS comparator mode or OS interrupt mode. Temperature resolution of 0.125°C. I2C-bus interface with up to 8 devices on the same bus. Temperatures range from -55°C to +125°C.

8.8.1.2. Applications

High temperature resolution is particularly useful in applications of measuring precisely the thermal drift or runaway. The LM75B powers up in the normal operation mode with the OS in comparator mode, temperature threshold of 80°C and hysteresis of 75°C, so that it can be used as a stand-alone thermostat with those pre-defined temperature set points. Application domains using this device include:

  • System thermal management
  • Personal computers
  • Electronics equipment
  • Industrial controllers

8.8.1.3. Resources

8.8.1.4. Platform Integration

The sensor can be enabled by defining compile-time flag PLTFRM_LM75B_TEMP_SENSOR_ENA. An example of using this sensor is illustrated in App Examples.

8.8.1.4.1. Functions

PLTFRM_sts_t LM75B_init(UINT8_t devId)

Initializes the sensor interface by programming it via the I2C interface. The sensor is configured for normal operation (LM75B_OPN_MODE_NORMAL). This function is typically called during platform initialization.

Parameters:
  • devId – Identity of the device.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. One possible error is PLTFRM_STS_INV_DEV_ID.

PLTFRM_sts_t LM75B_startSingleConv(UINT8_t devId, SINT16_t *tempVal_p, UINT16_t *tmoVal_p)

Obtain temperature from the sensor. If the sensor is in LM75B_OPN_MODE_NORMAL, value is read immediately. If not, the sensor is configured for normal operation but the value will not be available immediately. In this case, the function updates the caller of the duration before value becomes available. The caller is expected to start a timer with a callback function to read the value later. After reading, the caller may put the sensor back to LM75B_OPN_MODE_SHUT_DOWN mode.

Parameters:
  • devId – Identity of the device.
  • tempVal_p – Points to a location where temperature value is returned. Value can be negative. Temperature is reported in centi celsius.
  • tmoVal_p – Points to a location where sensor integration time is reported. This can be NULL if sensor is in normal operation. If not, this has to be a valid address. Value returned here is in milliseconds.
Returns:

PLTFRM_STS_SUCCESS is returned when temperature is read successfully. Possible errors are PLTFRM_STS_INV_DEV_ID, PLTFRM_STS_INV_PARAM and PLTFRM_STS_I2C_BUS_WR_ERROR. If device is in shutdown mode, PLTFRM_STS_OPN_IN_PROGRESS is returned to indicate that sensor has been activated to read temperature.

PLTFRM_sts_t LM75B_shutDown(UINT8_t devId)

Sensor is put into shutdown mode to conserve power.

Parameters:
  • devId – Identity of the device.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. Possible errors are PLTFRM_STS_INV_DEV_ID, PLTFRM_STS_INV_PARAM and PLTFRM_STS_I2C_BUS_WR_ERROR.

PLTFRM_sts_t LM75B_getTempVal(UINT8_t devId, SINT16_t *tempVal_p)

Get the temperature value. This is typically called after a timeout following a call to LM75B_startSingleConv() when the sensor was in LM75B_OPN_MODE_SHUT_DOWN mode.

Parameters:
  • devId – Identity of the device.
  • tempVal_p – Points to a location where temperature value is returned. Value can be negative. Temperature is reported in centi celsius.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. Possible errors are PLTFRM_STS_INV_DEV_ID, PLTFRM_STS_INV_PARAM and PLTFRM_STS_I2C_BUS_WR_ERROR.

PLTFRM_sts_t LM75B_cfg(UINT8_t devId, LM75B_mode_t reqOpnMode)

Configure the device in either normal or shutdown mode.

Parameters:
  • devId – Identity of the device.
  • reqOpnMode – Valid values are LM75B_OPN_MODE_NORMAL and LM75B_OPN_MODE_SHUT_DOWN.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. Possible errors are PLTFRM_STS_INV_DEV_ID, PLTFRM_STS_INV_PARAM and PLTFRM_STS_I2C_BUS_WR_ERROR.

8.8.1.4.2. Macros

#define LM75B_SENSOR_OUTPUT_VALUE_SZ  2


/*
 * The LM75B slave address on the I2C-bus is partially defined
 * by the logic applied to the device address pins A2, A1 and A0.
 * Each of them is typically connected either to GND for logic 0,
 * or to VCC for logic 1. These pins represent the three LSB bits
 * of the device 7-bit address. The other four MSB bits of the
 * address data are preset to '1001' by hard wiring inside the LM75B.
 */
#define LM75B_I2C_ADDR_PREFIX  0x48    // 0 1001 xxx  (7 bit address)

/*
 * LM75B register list
 */
#define LM75B_TEMP_REG_ADDR   0x0   // RO
#define LM75B_CONF_REG_ADDR   0x1   // R/W
#define LM75B_THYST_REG_ADDR  0x2   // R/W
#define LM75B_TOS_REG_ADDR    0x3   // R/W

#define LM75B_CONF_REG_SZ     0x1
#define LM75B_TEMP_REG_SZ     0x2
#define LM75B_THYST_REG_SZ    0x2
#define LM75B_TOS_REG_SZ      0x2

/*
 * 7.4.2 Configuration register
 */
#define LM75B_CFG_REG_OPN_MODE_BM          (1 << 0)
#define LM75B_CFG_REG_OS_OPN_MODE_BM       (1 << 1)
#define LM75B_CFG_REG_POL_SELN_BM          (1 << 2)
#define LM75B_CFG_REG_OS_FLT_Q_PRGMG_BM    ((1 << 3) | (1 << 4))


/*
 * Temperatures range from -55 degree C to +125 degree C
 */
#define LM75B_MIN_OUTPUT_VAL  ((SINT8_t)-55)
#define LM75B_MAX_OUTPUT_VAL  ((SINT8_t)125)

/*
 * In normal operation mode, the temp-to-digital conversion is executed
 * every 100 ms and the "Temp" register is updated at the end of each conversion.
 */
#define LM75B_PERIODIC_TEMP_SENSING_INTERVAL   100   // 100 milliseconds

/*
 * During each 'conversion period' (Tconv) of about 100 msecs the device takes only
 * about 10 msecs, called 'temperature conversion time' (tconv(T)), to complete a
 * temperature-to-data conversion and then becomes idle for the time remaining in
 * the period.
 */
#define LM75B_TEMP_SENSING_TIME  10   // 10 milliseconds

8.8.1.4.3. Type Definitions

typedef enum
{
   LM75B_OPN_MODE_UNKNOWN,      // Implementation specific
   LM75B_OPN_MODE_NORMAL,       // Periodically monitor the ambient temperature (every 100 milli-seconds)
   LM75B_OPN_MODE_SHUT_DOWN     // Shutdown mode to minimize power consumption
} LM75B_mode_t;


typedef struct
{
   UINT8_t devId;
   LM75B_mode_t opnMode;
} LM75B_cntxt_s;