Sample host software for the Maxim Integrated DS1775, DS75 Digital Thermometer Thermostat IC hosted on the MAX32630FTHR. The DS1775 is suitable for PCs, cell phones, and other thermally sensitive systems.

Dependencies:   max32630fthr DS1775_Digitial_Thermometer_Thermostat USBDevice

Revision:
17:7de7da8c21c3
Parent:
16:1ebf8a6248be
Child:
18:0e25544cb810
--- a/main.cpp	Tue Apr 09 06:38:05 2019 +0000
+++ b/main.cpp	Wed Apr 10 18:08:38 2019 +0000
@@ -108,6 +108,10 @@
     printf("\r\n");
 
     for (i = 0; i < 8; i++) {
+        temp_sensor.write_cfg_reg(uint8_t(DS1775_CFG_RESOLUTION_12BIT |
+            DS1775_CFG_FAULT_FILTER_6 | DS1775_CFG_OS_POLARITY_ACT_LOW |
+            DS1775_CFG_INTERRUPT_MODE | DS1775_CFG_SHUTDOWN));
+        wait(5); /*  leave it in shutdown mode for a while */
         /* Configure for 12 bit resolution, fault filter 6, 
            active low, interrupt, continous,
         */
@@ -119,11 +123,10 @@
             temp_sensor.read_reg_as_temperature(DS1775_REG_TEMPERATURE);
         printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
-        temp_sensor.write_cfg_reg(uint8_t(DS1775_CFG_RESOLUTION_12BIT |
-            DS1775_CFG_FAULT_FILTER_6 | DS1775_CFG_OS_POLARITY_ACT_LOW |
-            DS1775_CFG_INTERRUPT_MODE | DS1775_CFG_SHUTDOWN));
-        wait(2); /*  leave it in shutdown mode for a while */
     }
+    temp_sensor.write_cfg_reg(uint8_t(DS1775_CFG_RESOLUTION_12BIT |
+        DS1775_CFG_FAULT_FILTER_6 | DS1775_CFG_OS_POLARITY_ACT_LOW |
+        DS1775_CFG_INTERRUPT_MODE | DS1775_CFG_SHUTDOWN));
     temp_sensor.read_cfg_reg(&cfg);
     printf("Configuration Register = 0x%02Xh \r\n", cfg);
 
@@ -183,6 +186,10 @@
 
     printf("\r\n");
     for (i = 0; i < 8; i++) {
+        ds1775_write_cfg_reg(uint8_t(DS1775_CFG_RESOLUTION_12BIT |
+            DS1775_CFG_FAULT_FILTER_6 | DS1775_CFG_OS_POLARITY_ACT_LOW |
+            DS1775_CFG_INTERRUPT_MODE | DS1775_CFG_SHUTDOWN), i2cBus);
+        wait(5); /*  leave it in shutdown mode for a while */
         /* Configure for 12 bit resolution, fault filter 6, 
            active low, interrupt, continous,
         */
@@ -195,11 +202,10 @@
             i2cBus);
         printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
-        ds1775_write_cfg_reg(uint8_t(DS1775_CFG_RESOLUTION_12BIT |
-            DS1775_CFG_FAULT_FILTER_6 | DS1775_CFG_OS_POLARITY_ACT_LOW |
-            DS1775_CFG_INTERRUPT_MODE | DS1775_CFG_SHUTDOWN), i2cBus);
-        wait(2); /*  leave it in shutdown mode for a while */
     }
+    ds1775_write_cfg_reg(uint8_t(DS1775_CFG_RESOLUTION_12BIT |
+        DS1775_CFG_FAULT_FILTER_6 | DS1775_CFG_OS_POLARITY_ACT_LOW |
+        DS1775_CFG_INTERRUPT_MODE | DS1775_CFG_SHUTDOWN), i2cBus);
     ds1775_read_cfg_reg(&cfg, i2cBus);
     printf("Configuration Register = 0x%02Xh \r\n", cfg);