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

Committer:
coreyharris
Date:
Tue Aug 22 14:10:58 2017 +0000
Revision:
4:4899e8165b98
Parent:
3:b3fbff9ab12e
Child:
5:2edbaf7fcf7b
Updated serial print statement to reflect new potentiometer setup

Who changed what in which revision?

UserRevisionLine numberNew contents of line
coreyharris 0:6727152ebfbb 1 #include "mbed.h"
coreyharris 0:6727152ebfbb 2 #include "max32630fthr.h"
coreyharris 0:6727152ebfbb 3 #include "MAX113XX_Pixi.h"
coreyharris 0:6727152ebfbb 4 #include "MAX11301Hex.h"
coreyharris 0:6727152ebfbb 5
coreyharris 0:6727152ebfbb 6 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
coreyharris 0:6727152ebfbb 7
coreyharris 0:6727152ebfbb 8 int main()
coreyharris 0:6727152ebfbb 9 {
coreyharris 1:c161bde4496f 10 Serial pc(USBTX, USBRX); // Use USB debug probe for serial link
coreyharris 1:c161bde4496f 11 pc.baud(115200); // Baud rate = 115200
coreyharris 0:6727152ebfbb 12
coreyharris 1:c161bde4496f 13 I2C i2cBus(I2C1_SDA, I2C1_SCL); // I2C bus, P3_4 = SDA, P3_5 = SCL
coreyharris 0:6727152ebfbb 14
coreyharris 0:6727152ebfbb 15 MAX113XX_I2C * pixi;
coreyharris 0:6727152ebfbb 16 pixi = new MAX113XX_I2C(i2cBus, MAX113XX_I2C::MAX11301, 0x38, P5_5);
coreyharris 3:b3fbff9ab12e 17
coreyharris 3:b3fbff9ab12e 18 pixi->dacWrite(MAX113XX_Pixi::PORT0, 0x000); // Pixi PORT0 is -5V
coreyharris 3:b3fbff9ab12e 19 pixi->dacWrite(MAX113XX_Pixi::PORT1, 0xFFF); // Pixi PORT1 is +5V
coreyharris 1:c161bde4496f 20
coreyharris 1:c161bde4496f 21 uint16_t adcData, idx;
coreyharris 0:6727152ebfbb 22 float adcVoltage;
coreyharris 0:6727152ebfbb 23 while(1) {
coreyharris 0:6727152ebfbb 24
coreyharris 3:b3fbff9ab12e 25 pixi->singleEndedADCRead(MAX113XX_Pixi::PORT9, adcData); // Read value from PORT9
coreyharris 3:b3fbff9ab12e 26 adcVoltage = -5 + 2.442e-3 * adcData; // Convert ADC val to a voltage
coreyharris 4:4899e8165b98 27 pc.printf("ADC Read is : %i,\tVoltage is %1.3f V \r\n", adcData, adcVoltage);
coreyharris 3:b3fbff9ab12e 28 wait(0.05);
coreyharris 0:6727152ebfbb 29 }
coreyharris 0:6727152ebfbb 30 }
coreyharris 0:6727152ebfbb 31