Example host software for the Maxim Integrated MAX541 16-Bit, Unbuffered Output Voltage DAC. Hosted on the MAX32625MBED.
Dependencies: MAX541
main.cpp@2:9bb1f977c3e5, 2019-05-09 (annotated)
- Committer:
- whismanoid
- Date:
- Thu May 09 06:19:52 2019 +0000
- Revision:
- 2:9bb1f977c3e5
- Parent:
- 1:6382a70336f4
MAX541 class documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
whismanoid | 0:416025725155 | 1 | /******************************************************************************* |
whismanoid | 0:416025725155 | 2 | * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved. |
whismanoid | 0:416025725155 | 3 | * |
whismanoid | 0:416025725155 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
whismanoid | 0:416025725155 | 5 | * copy of this software and associated documentation files (the "Software"), |
whismanoid | 0:416025725155 | 6 | * to deal in the Software without restriction, including without limitation |
whismanoid | 0:416025725155 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
whismanoid | 0:416025725155 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
whismanoid | 0:416025725155 | 9 | * Software is furnished to do so, subject to the following conditions: |
whismanoid | 0:416025725155 | 10 | * |
whismanoid | 0:416025725155 | 11 | * The above copyright notice and this permission notice shall be included |
whismanoid | 0:416025725155 | 12 | * in all copies or substantial portions of the Software. |
whismanoid | 0:416025725155 | 13 | * |
whismanoid | 0:416025725155 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
whismanoid | 0:416025725155 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
whismanoid | 0:416025725155 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
whismanoid | 0:416025725155 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
whismanoid | 0:416025725155 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
whismanoid | 0:416025725155 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
whismanoid | 0:416025725155 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
whismanoid | 0:416025725155 | 21 | * |
whismanoid | 0:416025725155 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
whismanoid | 0:416025725155 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
whismanoid | 0:416025725155 | 24 | * Products, Inc. Branding Policy. |
whismanoid | 0:416025725155 | 25 | * |
whismanoid | 0:416025725155 | 26 | * The mere transfer of this software does not imply any licenses |
whismanoid | 0:416025725155 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
whismanoid | 0:416025725155 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
whismanoid | 0:416025725155 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
whismanoid | 0:416025725155 | 30 | * ownership rights. |
whismanoid | 0:416025725155 | 31 | ******************************************************************************* |
whismanoid | 0:416025725155 | 32 | */ |
whismanoid | 0:416025725155 | 33 | |
whismanoid | 0:416025725155 | 34 | #include "mbed.h" |
whismanoid | 0:416025725155 | 35 | #include "MAX541.h" |
whismanoid | 0:416025725155 | 36 | |
whismanoid | 2:9bb1f977c3e5 | 37 | // Connect MAX541 to Arduino compatible connector as shown: |
whismanoid | 2:9bb1f977c3e5 | 38 | // MAX541BCPA+ |
whismanoid | 2:9bb1f977c3e5 | 39 | // --------__-------- |
whismanoid | 2:9bb1f977c3e5 | 40 | // output --| 1 OUT VDD 8 |-- IOREF (3V3 or 5V logic supply) |
whismanoid | 2:9bb1f977c3e5 | 41 | // GND --| 2 AGND DGND 7 |-- GND |
whismanoid | 2:9bb1f977c3e5 | 42 | // V3.3 --| 3 REF DIN 6 |-- D11/SPI_MOSI |
whismanoid | 2:9bb1f977c3e5 | 43 | // D10/SPI_SS --| 4 CS SCLK 5 |-- D13/SPI_SCLK |
whismanoid | 2:9bb1f977c3e5 | 44 | // ------------------ |
whismanoid | 2:9bb1f977c3e5 | 45 | |
whismanoid | 1:6382a70336f4 | 46 | // example code declare SPI interface |
whismanoid | 1:6382a70336f4 | 47 | #if defined(TARGET_MAX32625MBED) |
whismanoid | 1:6382a70336f4 | 48 | SPI spi_max541(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 |
whismanoid | 1:6382a70336f4 | 49 | DigitalOut spi_max541_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10 |
whismanoid | 0:416025725155 | 50 | // alternate spi connection |
whismanoid | 1:6382a70336f4 | 51 | // SPI spi2_max541(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 TARGET_MAX32625MBED: P2_5 P2_6 P2_4 Arduino 2x3-pin header; microSD |
whismanoid | 1:6382a70336f4 | 52 | // DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32625MBED: P2_7 Arduino 2x3-pin header |
whismanoid | 1:6382a70336f4 | 53 | #elif defined(TARGET_MAX32600MBED) |
whismanoid | 2:9bb1f977c3e5 | 54 | SPI spi_max541(SPI2_MOSI, SPI2_MISO, SPI2_SCK); |
whismanoid | 2:9bb1f977c3e5 | 55 | DigitalOut spi_max541_cs(SPI2_SS); |
whismanoid | 1:6382a70336f4 | 56 | #else |
whismanoid | 2:9bb1f977c3e5 | 57 | SPI spi_max541(D11, D12, D13); // Arduino 10-pin header |
whismanoid | 2:9bb1f977c3e5 | 58 | DigitalOut spi_max541_cs(D10); // Arduino 10-pin header |
whismanoid | 1:6382a70336f4 | 59 | #endif |
whismanoid | 0:416025725155 | 60 | |
whismanoid | 0:416025725155 | 61 | int main() |
whismanoid | 0:416025725155 | 62 | { |
whismanoid | 0:416025725155 | 63 | MAX541 max541(spi_max541, spi_max541_cs); |
whismanoid | 0:416025725155 | 64 | max541.VRef = 3.30; |
whismanoid | 0:416025725155 | 65 | |
whismanoid | 0:416025725155 | 66 | double voltageV = 1.0f; |
whismanoid | 0:416025725155 | 67 | max541.Set_Voltage(voltageV); |
whismanoid | 0:416025725155 | 68 | |
whismanoid | 0:416025725155 | 69 | //wait(1.0); |
whismanoid | 0:416025725155 | 70 | } |