MAX11410 high speed 24-bit Delta-Sigma ADC

Dependents:   MAX11410BOB_24bit_ADC MAX11410BOB_Serial_Tester

Files at this revision

API Documentation at this revision

Comitter:
whismanoid
Date:
Tue Oct 27 00:53:50 2020 +0000
Parent:
34:1b72865fa71f
Commit message:
improve response time Measure_Voltage (for MAX11410 EMC testing)

Changed in this revision

MAX11410.cpp Show annotated file Show diff for this revision Revisions of this file
MAX11410.h Show annotated file Show diff for this revision Revisions of this file
diff -r 1b72865fa71f -r f94470c95dde MAX11410.cpp
--- a/MAX11410.cpp	Fri Jun 05 00:30:52 2020 +0000
+++ b/MAX11410.cpp	Tue Oct 27 00:53:50 2020 +0000
@@ -1860,6 +1860,30 @@
         futility_countdown--)
     {
         RegRead(CMD_r011_1000_dddd_dddd_dddd_dddd_dxxx_dddd_STATUS, &status);
+#if 1
+        // improve response time at the cost of more program size
+        if (futility_countdown < (loop_limit - 5)) {
+            wait_ms(1); // timing delay function, platform-specific
+        }
+        if (futility_countdown < (loop_limit - 10)) {
+            wait_ms(2); // timing delay function, platform-specific
+        }
+        if (futility_countdown < (loop_limit - 15)) {
+            wait_ms(5); // timing delay function, platform-specific
+        }
+        if (futility_countdown < (loop_limit - 20)) {
+            wait_ms(10); // timing delay function, platform-specific
+        }
+        if (futility_countdown < (loop_limit - 25)) {
+            wait_ms(20); // timing delay function, platform-specific
+        }
+        if (futility_countdown < (loop_limit - 30)) {
+            wait_ms(50); // timing delay function, platform-specific
+        }
+        if (futility_countdown < (loop_limit - 35)) {
+            wait_ms(100); // timing delay function, platform-specific
+        }
+#else
         if (loop_limit > 5) {
             wait_ms(20); // timing delay function, platform-specific
         }
@@ -1869,6 +1893,7 @@
         if (loop_limit > 30) {
             wait_ms(100); // timing delay function, platform-specific
         }
+#endif
     }
     
     //----------------------------------------
diff -r 1b72865fa71f -r f94470c95dde MAX11410.h
--- a/MAX11410.h	Fri Jun 05 00:30:52 2020 +0000
+++ b/MAX11410.h	Tue Oct 27 00:53:50 2020 +0000
@@ -94,9 +94,20 @@
 //      - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
 //      - not tested yet
 //   - MAX32625PICO
+//      - #include "max32625pico.h"
+//      - add https://os.mbed.com/users/switches/code/max32625pico/
 //      - remove max32630fthr library (if present)
 //      - remove MAX32620FTHR library (if present)
 //      - not tested yet
+//      - see https://os.mbed.com/users/switches/code/max32625pico/
+//      - see https://os.mbed.com/users/switches/code/PICO_board_demo/
+//      - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/
+//      - see https://os.mbed.com/users/switches/code/SerialInterface/
+//      - Note: To load the MAX32625PICO firmware, hold the button while
+//        connecting the USB cable, then copy firmware bin file 
+//        to the MAINTENANCE drive.
+//      - see https://os.mbed.com/platforms/MAX32625PICO/
+//      - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates
 //
 // end Platform_Include_Boilerplate
 
@@ -146,9 +157,20 @@
  * //      - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
  * //      - not tested yet
  * //   - MAX32625PICO
+ * //      - #include "max32625pico.h"
+ * //      - add https://os.mbed.com/users/switches/code/max32625pico/
  * //      - remove max32630fthr library (if present)
  * //      - remove MAX32620FTHR library (if present)
  * //      - not tested yet
+ * //      - see https://os.mbed.com/users/switches/code/max32625pico/
+ * //      - see https://os.mbed.com/users/switches/code/PICO_board_demo/
+ * //      - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/
+ * //      - see https://os.mbed.com/users/switches/code/SerialInterface/
+ * //      - Note: To load the MAX32625PICO firmware, hold the button while
+ * //        connecting the USB cable, then copy firmware bin file
+ * //        to the MAINTENANCE drive.
+ * //      - see https://os.mbed.com/platforms/MAX32625PICO/
+ * //      - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates
  * //
  * // end Platform_Include_Boilerplate
  * #include "MAX11410.h"
@@ -179,12 +201,36 @@
  * #define D11 P1_1
  * #define D12 P1_2
  * #define D13 P1_0
+ * #elif defined(TARGET_MAX32625PICO)
+ * #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
+ * #define A0 AIN_1
+ * #define A1 AIN_2
+ * // #define A2 AIN_3
+ * // #define A3 AIN_0
+ * #define D0 P0_0
+ * #define D1 P0_1
+ * #define D2 P0_2
+ * #define D3 P0_3
+ * #define D4 P1_7
+ * #define D5 P1_6
+ * #define D6 P4_4
+ * #define D7 P4_5
+ * #define D8 P4_6
+ * #define D9 P4_7
+ * #define D10 P0_7
+ * #define D11 P0_6
+ * #define D12 P0_5
+ * #define D13 P0_4
  * #endif
  *
  * // example code declare SPI interface (GPIO controlled CS)
  * #if defined(TARGET_MAX32625MBED)
  * SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13
  * DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
+ * #elif defined(TARGET_MAX32625PICO)
+ * #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
+ * SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
+ * DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
  * #elif defined(TARGET_MAX32600MBED)
  * SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
  * DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
@@ -265,6 +311,8 @@
  * // example code main function
  * int main()
  * {
+ *     // setup: put your setup code here, to run once
+ *
  *     // example code: serial port banner message
  *     wait(3); // 3000ms timing delay function, platform-specific
  *     cmdLine.serial().printf("\r\nHello_MAX11410\r\n");
@@ -305,11 +353,25 @@
  *
  *     while (1)
  *     {
+ *         // loop: put your main code here, to run repeatedly
+ *
  *         // CODE GENERATOR: example code: has no member function REF
  *         // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
  *         // CODE GENERATOR: ResolutionBits = 24
- *         // CODE GENERATOR: FScode = None
+ *         // CODE GENERATOR: FScode = 0xffffff
  *         // CODE GENERATOR: NumChannels = 10
+ *         // CODE GENERATOR: banner before helloCppCodeList while(1)
+ *         cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
+ *
+ *         cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
+ *
+ *         cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
+ *
+ *         // banner for csv data columns
+ *         cmdLine.serial().printf("\"AIN0_LSB\",\"AIN1_LSB\",\"AIN2_LSB\",\"AIN3_LSB\",\"AIN4_LSB\",\"AIN5_LSB\",\"AIN6_LSB\",\"AIN7_LSB\",\"AIN8_LSB\",\"AIN9_LSB\"");
+ *
+ *         cmdLine.serial().printf("\r\n");
+ *
  *         while(1) { // this code repeats forever
  *             // this code repeats forever
  *             // CODE GENERATOR: example code: has no member function ScanStandardExternalClock