Demo code for the MAX11301WING. Programs a +5V on Port 0, -5V on Port 1 and a single-ended ADC on Port 9.

Dependencies:   MAX113XX_Pixi max32630fthr

Fork of MAX11301_Demo by John Greene

Revision:
1:c161bde4496f
Parent:
0:6727152ebfbb
Child:
2:5362460b01ef
--- a/main.cpp	Thu Aug 17 15:24:05 2017 +0000
+++ b/main.cpp	Thu Aug 17 16:27:07 2017 +0000
@@ -5,38 +5,30 @@
 
 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
 
-
 int main()
 {
-    Serial pc(USBTX, USBRX);
-    pc.baud(115200);
+    Serial pc(USBTX, USBRX);            // Use USB debug probe for serial link
+    pc.baud(115200);                    // Baud rate = 115200
     
-    DigitalOut rLed(LED1, LED_OFF);
-    DigitalOut gLed(LED2, LED_OFF);
-    DigitalOut bLed(LED3, LED_OFF);
-    
-    I2C i2cBus(I2C1_SDA, I2C1_SCL);                 // I2C bus
+    I2C i2cBus(I2C1_SDA, I2C1_SCL);     // I2C bus, P3_4 = SDA, P3_5 = SCL
 
     MAX113XX_I2C * pixi;
     pixi = new MAX113XX_I2C(i2cBus, MAX113XX_I2C::MAX11301, 0x38, P5_5);
     
-    uint16_t adcData;
+    
+    uint16_t adcData, idx;
     float adcVoltage;
-    
     while(1) {
-        
-        for( int idx = 0; idx <= 0xFFF; idx++ ) {
-            
-            pixi->dacWrite(MAX113XX_Pixi::PORT0, idx);
+    
+        for(idx = 0; idx <= 0xFFF; idx++) {
+            pixi->dacWrite(MAX113XX_Pixi::PORT0, idx);             
             pixi->singleEndedADCRead(MAX113XX_Pixi::PORT9, adcData);  
-            adcVoltage = -5 + 2.4414e-3 * adcData;
-            
+            adcVoltage = -5 + 2.442e-3  * adcData;
             pc.printf("ADC Voltage is %1.3f V, Count is 0x%x \r\n", adcVoltage, idx);  
         }
         
-        pc.printf("\r\n\r\nSweep complete, starting new sweep \r\n\r\n");
-        wait(2.0);
-               
+        pc.printf("\r\n\r\nSweep complete, starting new sweep\r\n\r\n");
+        wait(2.0);       
     }
 }