![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Example main.c code for the Maxim Integrated DS7505 low voltage high accurate temperature sensor. Hosted on the MAX32630FTHR. C and C++ sample source code provided.
Dependencies: DS7505_Low_Voltage_Temperature_Sensor max32630fthr USBDevice
Diff: main.cpp
- Revision:
- 2:2236f57e3547
- Parent:
- 0:3037141e268d
--- a/main.cpp Sat Apr 27 09:58:16 2019 +0000 +++ b/main.cpp Sat Apr 27 19:45:57 2019 +0000 @@ -97,7 +97,7 @@ uint8_t i2c_addr = DS7505_I2C_SLAVE_ADR_00; DS7505 temp_sensor(i2cBus, i2c_addr); i2cBus.frequency(400000); - /* Configure for time out enabled, normal format, fault filter 6, + /* Configure for 9 bit, fault filter 6, active low polarity, comparator mode, continuous */ temp_sensor.write_cfg_reg(uint8_t( @@ -128,19 +128,20 @@ #endif pc.printf("\r\n"); - temp_sensor.write_cfg_reg(uint8_t( - DS7505_CFG_RESOLUTION_12BIT | DS7505_CFG_FAULT_FILTER_4 | - DS7505_CFG_OS_POLARITY_ACT_LOW | DS7505_CFG_INTERRUPT_MODE | - DS7505_CFG_SHUTDOWN)); for (i = 0; i < 8; i++) { + /* Configure to shutdown mode */ + temp_sensor.write_cfg_reg(uint8_t( + DS7505_CFG_RESOLUTION_12BIT | DS7505_CFG_FAULT_FILTER_4 | + DS7505_CFG_OS_POLARITY_ACT_LOW | DS7505_CFG_INTERRUPT_MODE | + DS7505_CFG_SHUTDOWN)); wait_sec_prompt(WAIT_TIME); /* leave it in shutdown mode for a while */ - /* Configure for one shot, time out disabled, extended format, fault filter 4, - active low polarity, comparator mode, shutdown + /* Configure for 12 BIT, fault filter 4, + active low polarity, interrupt mode, continuous */ temp_sensor.write_cfg_reg(uint8_t( DS7505_CFG_RESOLUTION_12BIT | DS7505_CFG_FAULT_FILTER_4 | DS7505_CFG_OS_POLARITY_ACT_LOW | DS7505_CFG_INTERRUPT_MODE | - DS7505_CFG_SHUTDOWN)); + DS7505_CFG_CONTINUOUS)); wait(DS7505_WAIT_CONV_TIME_12BIT); temperature = temp_sensor.read_reg_as_temperature(DS7505_REG_TEMPERATURE); @@ -173,7 +174,7 @@ #include "ds7505_c.h" pc.printf("C implementation of the code\r\n"); ds7505_init(i2c_addr); - /* Configure for time out enabled, normal format, fault filter 6, + /* Configure for 9 bit, fault filter 6, active low polarity, comparator mode, continuous */ ds7505_write_cfg_reg(uint8_t( @@ -206,19 +207,20 @@ #endif pc.printf("\r\n"); - ds7505_write_cfg_reg(uint8_t( - DS7505_CFG_RESOLUTION_12BIT | DS7505_CFG_FAULT_FILTER_4 | - DS7505_CFG_OS_POLARITY_ACT_LOW | DS7505_CFG_INTERRUPT_MODE | - DS7505_CFG_SHUTDOWN), i2cBus); for (i = 0; i < 8; i++) { + /* Configure for shutdown mode */ + ds7505_write_cfg_reg(uint8_t( + DS7505_CFG_RESOLUTION_12BIT | DS7505_CFG_FAULT_FILTER_4 | + DS7505_CFG_OS_POLARITY_ACT_LOW | DS7505_CFG_INTERRUPT_MODE | + DS7505_CFG_SHUTDOWN), i2cBus); wait_sec_prompt(WAIT_TIME); /* leave it in shutdown mode for a while */ - /* Configure for one shot, time out disabled, extended format, fault filter 4, - active low polarity, comparator mode, shutdown + /* Configure for 12 bits, fault filter 4, + active low polarity, interrupt mode, continuous */ ds7505_write_cfg_reg(uint8_t( DS7505_CFG_RESOLUTION_12BIT | DS7505_CFG_FAULT_FILTER_4 | DS7505_CFG_OS_POLARITY_ACT_LOW | DS7505_CFG_INTERRUPT_MODE | - DS7505_CFG_SHUTDOWN), i2cBus); + DS7505_CFG_CONTINUOUS), i2cBus); wait(DS7505_WAIT_CONV_TIME_12BIT); temperature = ds7505_read_reg_as_temperature(DS7505_REG_TEMPERATURE, i2cBus);