Maxim Integrated MAX5719 20-bit, 0.05nV-sec DAC
Dependents: MAX5719BOB_20bit_DAC MAX5719BOB_FunctionGen MAX5719BOB_Serial_Tester
MAX5719.cpp@1:f7dd5b495201, 2021-03-24 (annotated)
- Committer:
- whismanoid
- Date:
- Wed Mar 24 13:29:27 2021 -0700
- Revision:
- 1:f7dd5b495201
- Parent:
- 0:49c7e35bd044
- Child:
- 2:6ffccf9a34d0
Self test adjust error tolerances for 3.3v system
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
whismanoid | 0:49c7e35bd044 | 1 | // /******************************************************************************* |
whismanoid | 0:49c7e35bd044 | 2 | // * Copyright (C) 2021 Maxim Integrated Products, Inc., All Rights Reserved. |
whismanoid | 0:49c7e35bd044 | 3 | // * |
whismanoid | 0:49c7e35bd044 | 4 | // * Permission is hereby granted, free of charge, to any person obtaining a |
whismanoid | 0:49c7e35bd044 | 5 | // * copy of this software and associated documentation files (the "Software"), |
whismanoid | 0:49c7e35bd044 | 6 | // * to deal in the Software without restriction, including without limitation |
whismanoid | 0:49c7e35bd044 | 7 | // * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
whismanoid | 0:49c7e35bd044 | 8 | // * and/or sell copies of the Software, and to permit persons to whom the |
whismanoid | 0:49c7e35bd044 | 9 | // * Software is furnished to do so, subject to the following conditions: |
whismanoid | 0:49c7e35bd044 | 10 | // * |
whismanoid | 0:49c7e35bd044 | 11 | // * The above copyright notice and this permission notice shall be included |
whismanoid | 0:49c7e35bd044 | 12 | // * in all copies or substantial portions of the Software. |
whismanoid | 0:49c7e35bd044 | 13 | // * |
whismanoid | 0:49c7e35bd044 | 14 | // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
whismanoid | 0:49c7e35bd044 | 15 | // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
whismanoid | 0:49c7e35bd044 | 16 | // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
whismanoid | 0:49c7e35bd044 | 17 | // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
whismanoid | 0:49c7e35bd044 | 18 | // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
whismanoid | 0:49c7e35bd044 | 19 | // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
whismanoid | 0:49c7e35bd044 | 20 | // * OTHER DEALINGS IN THE SOFTWARE. |
whismanoid | 0:49c7e35bd044 | 21 | // * |
whismanoid | 0:49c7e35bd044 | 22 | // * Except as contained in this notice, the name of Maxim Integrated |
whismanoid | 0:49c7e35bd044 | 23 | // * Products, Inc. shall not be used except as stated in the Maxim Integrated |
whismanoid | 0:49c7e35bd044 | 24 | // * Products, Inc. Branding Policy. |
whismanoid | 0:49c7e35bd044 | 25 | // * |
whismanoid | 0:49c7e35bd044 | 26 | // * The mere transfer of this software does not imply any licenses |
whismanoid | 0:49c7e35bd044 | 27 | // * of trade secrets, proprietary technology, copyrights, patents, |
whismanoid | 0:49c7e35bd044 | 28 | // * trademarks, maskwork rights, or any other form of intellectual |
whismanoid | 0:49c7e35bd044 | 29 | // * property whatsoever. Maxim Integrated Products, Inc. retains all |
whismanoid | 0:49c7e35bd044 | 30 | // * ownership rights. |
whismanoid | 0:49c7e35bd044 | 31 | // ******************************************************************************* |
whismanoid | 0:49c7e35bd044 | 32 | // */ |
whismanoid | 0:49c7e35bd044 | 33 | // ********************************************************************* |
whismanoid | 0:49c7e35bd044 | 34 | // @file MAX5719.cpp |
whismanoid | 0:49c7e35bd044 | 35 | // ********************************************************************* |
whismanoid | 0:49c7e35bd044 | 36 | // Device Driver file |
whismanoid | 0:49c7e35bd044 | 37 | // DO NOT EDIT; except areas designated "CUSTOMIZE". Automatically generated file. |
whismanoid | 0:49c7e35bd044 | 38 | // generated by XMLSystemOfDevicesToMBED.py |
whismanoid | 0:49c7e35bd044 | 39 | // System Name = ExampleSystem |
whismanoid | 0:49c7e35bd044 | 40 | // System Description = Device driver example |
whismanoid | 0:49c7e35bd044 | 41 | |
whismanoid | 0:49c7e35bd044 | 42 | #include "MAX5719.h" |
whismanoid | 0:49c7e35bd044 | 43 | |
whismanoid | 0:49c7e35bd044 | 44 | // Device Name = MAX5719 |
whismanoid | 0:49c7e35bd044 | 45 | // Device Description = 20-Bit, Voltage-Output DAC with SPI Interface |
whismanoid | 0:49c7e35bd044 | 46 | // Device DeviceBriefDescription = 20-bit 1-ch DAC |
whismanoid | 0:49c7e35bd044 | 47 | // Device Manufacturer = Maxim Integrated |
whismanoid | 0:49c7e35bd044 | 48 | // Device PartNumber = MAX5719AGSD+ |
whismanoid | 0:49c7e35bd044 | 49 | // Device RegValue_Width = DataWidth16bit_HL |
whismanoid | 0:49c7e35bd044 | 50 | // |
whismanoid | 0:49c7e35bd044 | 51 | // DAC NumChannels = 1 |
whismanoid | 0:49c7e35bd044 | 52 | // DAC ResolutionBits = 20 |
whismanoid | 0:49c7e35bd044 | 53 | // |
whismanoid | 0:49c7e35bd044 | 54 | // SPI CS = ActiveLow |
whismanoid | 0:49c7e35bd044 | 55 | // SPI FrameStart = CS |
whismanoid | 0:49c7e35bd044 | 56 | // SPI CPOL = 0 |
whismanoid | 0:49c7e35bd044 | 57 | // SPI CPHA = 0 |
whismanoid | 0:49c7e35bd044 | 58 | // SPI MOSI and MISO Data are both stable on Rising edge of SCLK |
whismanoid | 0:49c7e35bd044 | 59 | // SPI SCLK Idle Low |
whismanoid | 0:49c7e35bd044 | 60 | // SPI SCLKMaxMHz = 50 |
whismanoid | 0:49c7e35bd044 | 61 | // SPI SCLKMinMHz = 0 |
whismanoid | 0:49c7e35bd044 | 62 | // |
whismanoid | 0:49c7e35bd044 | 63 | // InputPin Name = RFB |
whismanoid | 0:49c7e35bd044 | 64 | // InputPin Description = Feedback Resistor. Connect to external op amp's output in bipolar mode. |
whismanoid | 0:49c7e35bd044 | 65 | // InputPin Function = Analog |
whismanoid | 0:49c7e35bd044 | 66 | // |
whismanoid | 0:49c7e35bd044 | 67 | // InputPin Name = INV |
whismanoid | 0:49c7e35bd044 | 68 | // InputPin Description = Junction of Internal Resistors. Connect to the inverting input of the external op amp in bipolar mode. |
whismanoid | 0:49c7e35bd044 | 69 | // InputPin Function = Analog |
whismanoid | 0:49c7e35bd044 | 70 | // |
whismanoid | 0:49c7e35bd044 | 71 | // InputPin Name = LDAC# |
whismanoid | 0:49c7e35bd044 | 72 | // InputPin Description = LDAC Input. A falling edge updates the internal DAC latch. |
whismanoid | 0:49c7e35bd044 | 73 | // InputPin Function = Trigger |
whismanoid | 0:49c7e35bd044 | 74 | // |
whismanoid | 0:49c7e35bd044 | 75 | // OutputPin Name = OUT |
whismanoid | 0:49c7e35bd044 | 76 | // OutputPin Description = Analog Voltage Output. High impedance in shutdown. Output voltage is limited to VDD. |
whismanoid | 0:49c7e35bd044 | 77 | // OutputPin Function = Analog |
whismanoid | 0:49c7e35bd044 | 78 | // |
whismanoid | 0:49c7e35bd044 | 79 | // SupplyPin Name = VDD |
whismanoid | 0:49c7e35bd044 | 80 | // SupplyPin Description = Positive Supply. Bypass to AGND with a 4.7uF capacitor in parallel with a 0.1uF capacitor. |
whismanoid | 0:49c7e35bd044 | 81 | // SupplyPin VinMax = 4.50 |
whismanoid | 0:49c7e35bd044 | 82 | // SupplyPin VinMin = 5.50 |
whismanoid | 0:49c7e35bd044 | 83 | // SupplyPin Function = Analog |
whismanoid | 0:49c7e35bd044 | 84 | // |
whismanoid | 0:49c7e35bd044 | 85 | // SupplyPin Name = REFF |
whismanoid | 0:49c7e35bd044 | 86 | // SupplyPin Description = Reference Input (force). Connect an external +4.096V reference. |
whismanoid | 0:49c7e35bd044 | 87 | // SupplyPin VinMax = VDD |
whismanoid | 0:49c7e35bd044 | 88 | // SupplyPin VinMin = 4 |
whismanoid | 0:49c7e35bd044 | 89 | // SupplyPin Function = Analog |
whismanoid | 0:49c7e35bd044 | 90 | // |
whismanoid | 0:49c7e35bd044 | 91 | // SupplyPin Name = REFS |
whismanoid | 0:49c7e35bd044 | 92 | // SupplyPin Description = Reference Input (sense). Connect an external +4.096V reference. |
whismanoid | 0:49c7e35bd044 | 93 | // SupplyPin VinMax = VDD |
whismanoid | 0:49c7e35bd044 | 94 | // SupplyPin VinMin = 4 |
whismanoid | 0:49c7e35bd044 | 95 | // SupplyPin Function = Analog |
whismanoid | 0:49c7e35bd044 | 96 | // |
whismanoid | 0:49c7e35bd044 | 97 | // SupplyPin Name = DGND |
whismanoid | 0:49c7e35bd044 | 98 | // SupplyPin Description = Digital Ground. |
whismanoid | 0:49c7e35bd044 | 99 | // SupplyPin VinMax = 0 |
whismanoid | 0:49c7e35bd044 | 100 | // SupplyPin VinMin = 0 |
whismanoid | 0:49c7e35bd044 | 101 | // SupplyPin Function = Analog |
whismanoid | 0:49c7e35bd044 | 102 | // |
whismanoid | 0:49c7e35bd044 | 103 | // SupplyPin Name = AGNDF |
whismanoid | 0:49c7e35bd044 | 104 | // SupplyPin Description = Analog Ground (force). |
whismanoid | 0:49c7e35bd044 | 105 | // SupplyPin VinMax = 0 |
whismanoid | 0:49c7e35bd044 | 106 | // SupplyPin VinMin = 0 |
whismanoid | 0:49c7e35bd044 | 107 | // SupplyPin Function = Analog |
whismanoid | 0:49c7e35bd044 | 108 | // |
whismanoid | 0:49c7e35bd044 | 109 | // SupplyPin Name = AGNDS |
whismanoid | 0:49c7e35bd044 | 110 | // SupplyPin Description = Analog Ground (sense). |
whismanoid | 0:49c7e35bd044 | 111 | // SupplyPin VinMax = 0 |
whismanoid | 0:49c7e35bd044 | 112 | // SupplyPin VinMin = 0 |
whismanoid | 0:49c7e35bd044 | 113 | // SupplyPin Function = Analog |
whismanoid | 0:49c7e35bd044 | 114 | // |
whismanoid | 0:49c7e35bd044 | 115 | |
whismanoid | 0:49c7e35bd044 | 116 | MAX5719::MAX5719(SPI &spi, DigitalOut &cs_pin, // SPI interface |
whismanoid | 0:49c7e35bd044 | 117 | // AnalogOut &RFB_pin, // Analog Input to MAX5719 device |
whismanoid | 0:49c7e35bd044 | 118 | // AnalogOut &INV_pin, // Analog Input to MAX5719 device |
whismanoid | 0:49c7e35bd044 | 119 | DigitalOut &LDACb_pin, // Digital Trigger Input to MAX5719 device |
whismanoid | 0:49c7e35bd044 | 120 | // AnalogIn &OUT_pin, // Analog Output from MAX5719 device |
whismanoid | 0:49c7e35bd044 | 121 | MAX5719_ic_t ic_variant) |
whismanoid | 0:49c7e35bd044 | 122 | : m_spi(spi), m_cs_pin(cs_pin), // SPI interface |
whismanoid | 0:49c7e35bd044 | 123 | // m_RFB_pin(RFB_pin), // Analog Input to MAX5719 device |
whismanoid | 0:49c7e35bd044 | 124 | // m_INV_pin(INV_pin), // Analog Input to MAX5719 device |
whismanoid | 0:49c7e35bd044 | 125 | m_LDACb_pin(LDACb_pin), // Digital Trigger Input to MAX5719 device |
whismanoid | 0:49c7e35bd044 | 126 | // m_OUT_pin(OUT_pin), // Analog Output from MAX5719 device |
whismanoid | 0:49c7e35bd044 | 127 | m_ic_variant(ic_variant) |
whismanoid | 0:49c7e35bd044 | 128 | { |
whismanoid | 0:49c7e35bd044 | 129 | // SPI CS = ActiveLow |
whismanoid | 0:49c7e35bd044 | 130 | // SPI FrameStart = CS |
whismanoid | 0:49c7e35bd044 | 131 | m_SPI_cs_state = 1; |
whismanoid | 0:49c7e35bd044 | 132 | if (m_cs_pin.is_connected()) { // avoid mbed runtime error if pin is NC not connected |
whismanoid | 0:49c7e35bd044 | 133 | m_cs_pin = m_SPI_cs_state; |
whismanoid | 0:49c7e35bd044 | 134 | } |
whismanoid | 0:49c7e35bd044 | 135 | |
whismanoid | 0:49c7e35bd044 | 136 | // SPI CPOL = 0 |
whismanoid | 0:49c7e35bd044 | 137 | // SPI CPHA = 0 |
whismanoid | 0:49c7e35bd044 | 138 | // SPI MOSI and MISO Data are both stable on Rising edge of SCLK |
whismanoid | 0:49c7e35bd044 | 139 | // SPI SCLK Idle Low |
whismanoid | 0:49c7e35bd044 | 140 | m_SPI_dataMode = 0; //SPI_MODE0; // CPOL=0,CPHA=0: Rising Edge stable; SCLK idle Low |
whismanoid | 0:49c7e35bd044 | 141 | m_spi.format(8,m_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 |
whismanoid | 0:49c7e35bd044 | 142 | |
whismanoid | 0:49c7e35bd044 | 143 | // SPI SCLKMaxMHz = 50 |
whismanoid | 0:49c7e35bd044 | 144 | // SPI SCLKMinMHz = 0 |
whismanoid | 0:49c7e35bd044 | 145 | //#define SPI_SCLK_Hz 48000000 // 48MHz |
whismanoid | 0:49c7e35bd044 | 146 | //#define SPI_SCLK_Hz 24000000 // 24MHz |
whismanoid | 0:49c7e35bd044 | 147 | //#define SPI_SCLK_Hz 12000000 // 12MHz |
whismanoid | 0:49c7e35bd044 | 148 | //#define SPI_SCLK_Hz 6000000 // 6MHz |
whismanoid | 0:49c7e35bd044 | 149 | //#define SPI_SCLK_Hz 4000000 // 4MHz |
whismanoid | 0:49c7e35bd044 | 150 | //#define SPI_SCLK_Hz 2000000 // 2MHz |
whismanoid | 0:49c7e35bd044 | 151 | //#define SPI_SCLK_Hz 1000000 // 1MHz |
whismanoid | 0:49c7e35bd044 | 152 | m_SPI_SCLK_Hz = 12000000; // platform limit 12MHz; MAX5719 limit is 50MHz |
whismanoid | 0:49c7e35bd044 | 153 | m_spi.frequency(m_SPI_SCLK_Hz); |
whismanoid | 0:49c7e35bd044 | 154 | |
whismanoid | 0:49c7e35bd044 | 155 | // |
whismanoid | 0:49c7e35bd044 | 156 | // RFB Analog Input to MAX5719 device |
whismanoid | 0:49c7e35bd044 | 157 | // |
whismanoid | 0:49c7e35bd044 | 158 | // INV Analog Input to MAX5719 device |
whismanoid | 0:49c7e35bd044 | 159 | // |
whismanoid | 0:49c7e35bd044 | 160 | // LDACb Trigger Input to MAX5719 device |
whismanoid | 0:49c7e35bd044 | 161 | m_LDACb_pin = 1; // output logic high -- initial value in constructor |
whismanoid | 0:49c7e35bd044 | 162 | // |
whismanoid | 0:49c7e35bd044 | 163 | // OUT Analog Output from device |
whismanoid | 0:49c7e35bd044 | 164 | } |
whismanoid | 0:49c7e35bd044 | 165 | |
whismanoid | 0:49c7e35bd044 | 166 | MAX5719::~MAX5719() |
whismanoid | 0:49c7e35bd044 | 167 | { |
whismanoid | 0:49c7e35bd044 | 168 | // do nothing |
whismanoid | 0:49c7e35bd044 | 169 | } |
whismanoid | 0:49c7e35bd044 | 170 | |
whismanoid | 0:49c7e35bd044 | 171 | /// set SPI SCLK frequency |
whismanoid | 0:49c7e35bd044 | 172 | void MAX5719::spi_frequency(int spi_sclk_Hz) |
whismanoid | 0:49c7e35bd044 | 173 | { |
whismanoid | 0:49c7e35bd044 | 174 | m_SPI_SCLK_Hz = spi_sclk_Hz; |
whismanoid | 0:49c7e35bd044 | 175 | m_spi.frequency(m_SPI_SCLK_Hz); |
whismanoid | 0:49c7e35bd044 | 176 | } |
whismanoid | 0:49c7e35bd044 | 177 | |
whismanoid | 0:49c7e35bd044 | 178 | // Assert SPI Chip Select |
whismanoid | 0:49c7e35bd044 | 179 | // SPI chip-select for MAX5719 |
whismanoid | 0:49c7e35bd044 | 180 | // |
whismanoid | 0:49c7e35bd044 | 181 | inline void MAX5719::SPIoutputCS(int isLogicHigh) |
whismanoid | 0:49c7e35bd044 | 182 | { |
whismanoid | 0:49c7e35bd044 | 183 | m_SPI_cs_state = isLogicHigh; |
whismanoid | 0:49c7e35bd044 | 184 | if (m_cs_pin.is_connected()) { // avoid mbed runtime error if pin is NC not connected |
whismanoid | 0:49c7e35bd044 | 185 | m_cs_pin = m_SPI_cs_state; |
whismanoid | 0:49c7e35bd044 | 186 | } |
whismanoid | 0:49c7e35bd044 | 187 | } |
whismanoid | 0:49c7e35bd044 | 188 | |
whismanoid | 0:49c7e35bd044 | 189 | // SPI write 24 bits |
whismanoid | 0:49c7e35bd044 | 190 | // SPI interface to MAX5719 shift 24 bits mosiData into MAX5719 DIN |
whismanoid | 0:49c7e35bd044 | 191 | // |
whismanoid | 0:49c7e35bd044 | 192 | void MAX5719::SPIwrite24bits(int8_t mosiData8_FF0000, int16_t mosiData16_00FFFF) |
whismanoid | 0:49c7e35bd044 | 193 | { |
whismanoid | 0:49c7e35bd044 | 194 | size_t byteCount = 3; |
whismanoid | 0:49c7e35bd044 | 195 | static char mosiData[3]; |
whismanoid | 0:49c7e35bd044 | 196 | static char misoData[3]; |
whismanoid | 0:49c7e35bd044 | 197 | mosiData[0] = mosiData8_FF0000; |
whismanoid | 0:49c7e35bd044 | 198 | mosiData[1] = (char)((mosiData16_00FFFF >> 8) & 0xFF); // MSByte |
whismanoid | 0:49c7e35bd044 | 199 | mosiData[2] = (char)((mosiData16_00FFFF >> 0) & 0xFF); // LSByte |
whismanoid | 0:49c7e35bd044 | 200 | // |
whismanoid | 0:49c7e35bd044 | 201 | // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() |
whismanoid | 0:49c7e35bd044 | 202 | //~ noInterrupts(); |
whismanoid | 0:49c7e35bd044 | 203 | // |
whismanoid | 0:49c7e35bd044 | 204 | //~ digitalWrite(Scope_Trigger_Pin, LOW); // diagnostic Scope_Trigger_Pin |
whismanoid | 0:49c7e35bd044 | 205 | // |
whismanoid | 0:49c7e35bd044 | 206 | unsigned int numBytesTransferred = m_spi.write(mosiData, byteCount, misoData, byteCount); |
whismanoid | 0:49c7e35bd044 | 207 | //~ SPI.transfer(mosiData8_FF0000); |
whismanoid | 0:49c7e35bd044 | 208 | //~ SPI.transfer(mosiData16_00FF00); |
whismanoid | 0:49c7e35bd044 | 209 | //~ SPI.transfer(mosiData16_0000FF); |
whismanoid | 0:49c7e35bd044 | 210 | // |
whismanoid | 0:49c7e35bd044 | 211 | //~ digitalWrite(Scope_Trigger_Pin, HIGH); // diagnostic Scope_Trigger_Pin |
whismanoid | 0:49c7e35bd044 | 212 | // |
whismanoid | 0:49c7e35bd044 | 213 | // Arduino: begin critical section: noInterrupts() masks all interrupt sources; end critical section with interrupts() |
whismanoid | 0:49c7e35bd044 | 214 | //~ interrupts(); |
whismanoid | 0:49c7e35bd044 | 215 | // Optional Diagnostic function to print SPI transactions |
whismanoid | 0:49c7e35bd044 | 216 | if (onSPIprint) |
whismanoid | 0:49c7e35bd044 | 217 | { |
whismanoid | 0:49c7e35bd044 | 218 | onSPIprint(byteCount, (uint8_t*)mosiData, (uint8_t*)misoData); |
whismanoid | 0:49c7e35bd044 | 219 | } |
whismanoid | 0:49c7e35bd044 | 220 | // |
whismanoid | 0:49c7e35bd044 | 221 | // VERIFY: SPIwrite24bits print diagnostic information |
whismanoid | 0:49c7e35bd044 | 222 | //cmdLine.serial().printf(" MOSI->")); |
whismanoid | 0:49c7e35bd044 | 223 | //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:49c7e35bd044 | 224 | //Serial.print( (mosiData8_FF0000 & 0xFF), HEX); |
whismanoid | 0:49c7e35bd044 | 225 | //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:49c7e35bd044 | 226 | //Serial.print( (mosiData16_00FF00 & 0xFF), HEX); |
whismanoid | 0:49c7e35bd044 | 227 | //cmdLine.serial().printf(" 0x")); |
whismanoid | 0:49c7e35bd044 | 228 | //Serial.print( (mosiData16_0000FF & 0xFF), HEX); |
whismanoid | 0:49c7e35bd044 | 229 | // hex dump mosiData[0..byteCount-1] |
whismanoid | 0:49c7e35bd044 | 230 | #if HAS_MICROUSBSERIAL |
whismanoid | 0:49c7e35bd044 | 231 | cmdLine_microUSBserial.serial().printf("\r\nSPI"); |
whismanoid | 0:49c7e35bd044 | 232 | if (byteCount > 7) { |
whismanoid | 0:49c7e35bd044 | 233 | cmdLine_microUSBserial.serial().printf(" byteCount:%d", byteCount); |
whismanoid | 0:49c7e35bd044 | 234 | } |
whismanoid | 0:49c7e35bd044 | 235 | cmdLine_microUSBserial.serial().printf(" MOSI->"); |
whismanoid | 0:49c7e35bd044 | 236 | for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 0:49c7e35bd044 | 237 | { |
whismanoid | 0:49c7e35bd044 | 238 | cmdLine_microUSBserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 0:49c7e35bd044 | 239 | } |
whismanoid | 0:49c7e35bd044 | 240 | // hex dump misoData[0..byteCount-1] |
whismanoid | 0:49c7e35bd044 | 241 | cmdLine_microUSBserial.serial().printf(" MISO<-"); |
whismanoid | 0:49c7e35bd044 | 242 | for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) |
whismanoid | 0:49c7e35bd044 | 243 | { |
whismanoid | 0:49c7e35bd044 | 244 | cmdLine_microUSBserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 0:49c7e35bd044 | 245 | } |
whismanoid | 0:49c7e35bd044 | 246 | cmdLine_microUSBserial.serial().printf(" "); |
whismanoid | 0:49c7e35bd044 | 247 | #endif |
whismanoid | 0:49c7e35bd044 | 248 | #if HAS_DAPLINK_SERIAL |
whismanoid | 0:49c7e35bd044 | 249 | cmdLine_DAPLINKserial.serial().printf("\r\nSPI"); |
whismanoid | 0:49c7e35bd044 | 250 | if (byteCount > 7) { |
whismanoid | 0:49c7e35bd044 | 251 | cmdLine_DAPLINKserial.serial().printf(" byteCount:%d", byteCount); |
whismanoid | 0:49c7e35bd044 | 252 | } |
whismanoid | 0:49c7e35bd044 | 253 | cmdLine_DAPLINKserial.serial().printf(" MOSI->"); |
whismanoid | 0:49c7e35bd044 | 254 | for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++) |
whismanoid | 0:49c7e35bd044 | 255 | { |
whismanoid | 0:49c7e35bd044 | 256 | cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", mosiData[byteIndex]); |
whismanoid | 0:49c7e35bd044 | 257 | } |
whismanoid | 0:49c7e35bd044 | 258 | // hex dump misoData[0..byteCount-1] |
whismanoid | 0:49c7e35bd044 | 259 | cmdLine_DAPLINKserial.serial().printf(" MISO<-"); |
whismanoid | 0:49c7e35bd044 | 260 | for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred; byteIndex++) |
whismanoid | 0:49c7e35bd044 | 261 | { |
whismanoid | 0:49c7e35bd044 | 262 | cmdLine_DAPLINKserial.serial().printf(" 0x%2.2X", misoData[byteIndex]); |
whismanoid | 0:49c7e35bd044 | 263 | } |
whismanoid | 0:49c7e35bd044 | 264 | cmdLine_DAPLINKserial.serial().printf(" "); |
whismanoid | 0:49c7e35bd044 | 265 | #endif |
whismanoid | 0:49c7e35bd044 | 266 | // VERIFY: DIAGNOSTIC: print MAX5715 device register write |
whismanoid | 0:49c7e35bd044 | 267 | // TODO: MAX5715_print_register_verbose(mosiData8_FF0000, mosiData16_00FFFF); |
whismanoid | 0:49c7e35bd044 | 268 | // |
whismanoid | 0:49c7e35bd044 | 269 | // int misoData16 = (misoData16_FF00 << 8) | misoData16_00FF; |
whismanoid | 0:49c7e35bd044 | 270 | // return misoData16; |
whismanoid | 0:49c7e35bd044 | 271 | } |
whismanoid | 0:49c7e35bd044 | 272 | |
whismanoid | 0:49c7e35bd044 | 273 | // Assert MAX5719 LDAC pin : High = inactive, Low = load DAC. |
whismanoid | 0:49c7e35bd044 | 274 | // |
whismanoid | 0:49c7e35bd044 | 275 | void MAX5719::LDACboutputValue(int isLogicHigh) |
whismanoid | 0:49c7e35bd044 | 276 | { |
whismanoid | 0:49c7e35bd044 | 277 | // m_LDACb_pin.output(); // only applicable to DigitalInOut |
whismanoid | 0:49c7e35bd044 | 278 | m_LDACb_pin = isLogicHigh; |
whismanoid | 0:49c7e35bd044 | 279 | } |
whismanoid | 0:49c7e35bd044 | 280 | |
whismanoid | 0:49c7e35bd044 | 281 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 282 | // Menu item '!' |
whismanoid | 0:49c7e35bd044 | 283 | // Initialize device |
whismanoid | 0:49c7e35bd044 | 284 | // |
whismanoid | 0:49c7e35bd044 | 285 | // // |
whismanoid | 0:49c7e35bd044 | 286 | // // Device Testing: DAC commands, verify using on-board ADC inputs |
whismanoid | 0:49c7e35bd044 | 287 | // // |
whismanoid | 0:49c7e35bd044 | 288 | // @test group CODE_LOAD // Verify function CODE_LOAD vs platform AIN0 analog input (enabled by default) |
whismanoid | 0:49c7e35bd044 | 289 | // @test group CODE_LOAD tinyTester.print("VRef = 4.096 MAX5719 20-bit LSB = 0.000004V = 3.90625uV") |
whismanoid | 0:49c7e35bd044 | 290 | // @test group CODE_LOAD tinyTester.print("Wire MAX5719 OUT to platform AIN0 for analog loopback tests...") |
whismanoid | 0:49c7e35bd044 | 291 | // @test group CODE_LOAD VRef = 4.096 |
whismanoid | 0:49c7e35bd044 | 292 | // @test group CODE_LOAD tinyTester.blink_time_msec = 75 // default 75 resume hardware self test |
whismanoid | 0:49c7e35bd044 | 293 | // @test group CODE_LOAD tinyTester.settle_time_msec = 500 |
whismanoid | 0:49c7e35bd044 | 294 | // @test Init() |
whismanoid | 0:49c7e35bd044 | 295 | // @test VRef expect 4.096 // Nominal Full-Scale Voltage Reference |
whismanoid | 0:49c7e35bd044 | 296 | // // |
whismanoid | 0:49c7e35bd044 | 297 | // @test group CODE_LOAD tinyTester.err_threshold = 0.050 |
whismanoid | 0:49c7e35bd044 | 298 | // // |
whismanoid | 0:49c7e35bd044 | 299 | // @test group CODE_LOAD tinyTester.print("0x000000 = 0.000V") |
whismanoid | 0:49c7e35bd044 | 300 | // @test group CODE_LOAD CODE_LOAD(0x000000) // 0.000V |
whismanoid | 0:49c7e35bd044 | 301 | // @test group CODE_LOAD tinyTester.Wait_Output_Settling() |
whismanoid | 0:49c7e35bd044 | 302 | // @test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(0.000000) |
whismanoid | 0:49c7e35bd044 | 303 | // // |
whismanoid | 0:49c7e35bd044 | 304 | // @test group CODE_LOAD tinyTester.print("0x01f400 = 0.500V") |
whismanoid | 0:49c7e35bd044 | 305 | // @test group CODE_LOAD CODE_LOAD(0x01f400) // 0.500V |
whismanoid | 0:49c7e35bd044 | 306 | // @test group CODE_LOAD tinyTester.Wait_Output_Settling() |
whismanoid | 0:49c7e35bd044 | 307 | // @test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(0.500000) |
whismanoid | 0:49c7e35bd044 | 308 | // // |
whismanoid | 0:49c7e35bd044 | 309 | // @test group CODE_LOAD tinyTester.print("0x03e800 = 1.000V") |
whismanoid | 0:49c7e35bd044 | 310 | // @test group CODE_LOAD CODE_LOAD(0x03e800) // 1.000V |
whismanoid | 0:49c7e35bd044 | 311 | // @test group CODE_LOAD tinyTester.Wait_Output_Settling() |
whismanoid | 0:49c7e35bd044 | 312 | // @test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(1.000000) |
whismanoid | 0:49c7e35bd044 | 313 | // // |
whismanoid | 1:f7dd5b495201 | 314 | // @test group CODE_LOAD tinyTester.err_threshold = 0.075 |
whismanoid | 1:f7dd5b495201 | 315 | // // |
whismanoid | 0:49c7e35bd044 | 316 | // @test group CODE_LOAD tinyTester.print("0x05dc00 = 1.500V") |
whismanoid | 0:49c7e35bd044 | 317 | // @test group CODE_LOAD CODE_LOAD(0x05dc00) // 1.500V |
whismanoid | 0:49c7e35bd044 | 318 | // @test group CODE_LOAD tinyTester.Wait_Output_Settling() |
whismanoid | 0:49c7e35bd044 | 319 | // @test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(1.500000) |
whismanoid | 0:49c7e35bd044 | 320 | // // |
whismanoid | 1:f7dd5b495201 | 321 | // @test group CODE_LOAD tinyTester.err_threshold = 0.100 |
whismanoid | 1:f7dd5b495201 | 322 | // // |
whismanoid | 0:49c7e35bd044 | 323 | // @test group CODE_LOAD tinyTester.print("0x07d000 = 2.000V") |
whismanoid | 0:49c7e35bd044 | 324 | // @test group CODE_LOAD CODE_LOAD(0x07d000) // 2.000V |
whismanoid | 0:49c7e35bd044 | 325 | // @test group CODE_LOAD tinyTester.Wait_Output_Settling() |
whismanoid | 0:49c7e35bd044 | 326 | // @test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(2.000000) |
whismanoid | 0:49c7e35bd044 | 327 | // // |
whismanoid | 1:f7dd5b495201 | 328 | // @test group CODE_LOAD tinyTester.err_threshold = 0.150 |
whismanoid | 1:f7dd5b495201 | 329 | // // |
whismanoid | 0:49c7e35bd044 | 330 | // @test group CODE_LOAD tinyTester.print("0x09c400 = 2.500V") |
whismanoid | 0:49c7e35bd044 | 331 | // @test group CODE_LOAD CODE_LOAD(0x09c400) // 2.500V |
whismanoid | 0:49c7e35bd044 | 332 | // @test group CODE_LOAD tinyTester.Wait_Output_Settling() |
whismanoid | 0:49c7e35bd044 | 333 | // @test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(2.500000) |
whismanoid | 0:49c7e35bd044 | 334 | // // |
whismanoid | 1:f7dd5b495201 | 335 | // @test group CODE_LOAD tinyTester.err_threshold = 0.200 |
whismanoid | 1:f7dd5b495201 | 336 | // // |
whismanoid | 0:49c7e35bd044 | 337 | // @test group CODE_LOAD tinyTester.print("0x0bb800 = 3.000V") |
whismanoid | 0:49c7e35bd044 | 338 | // @test group CODE_LOAD CODE_LOAD(0x0bb800) // 3.000V |
whismanoid | 0:49c7e35bd044 | 339 | // @test group CODE_LOAD tinyTester.Wait_Output_Settling() |
whismanoid | 0:49c7e35bd044 | 340 | // @test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(3.000000) |
whismanoid | 0:49c7e35bd044 | 341 | // // |
whismanoid | 1:f7dd5b495201 | 342 | // @test group CODE_LOAD tinyTester.err_threshold = 0.250 |
whismanoid | 1:f7dd5b495201 | 343 | // // |
whismanoid | 0:49c7e35bd044 | 344 | // @test group CODE_LOAD tinyTester.print("0x0dac00 = 3.500V") |
whismanoid | 0:49c7e35bd044 | 345 | // @test group CODE_LOAD CODE_LOAD(0x0dac00) // 3.500V |
whismanoid | 0:49c7e35bd044 | 346 | // @test group CODE_LOAD tinyTester.Wait_Output_Settling() |
whismanoid | 0:49c7e35bd044 | 347 | // @test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(3.500000) |
whismanoid | 0:49c7e35bd044 | 348 | // // |
whismanoid | 1:f7dd5b495201 | 349 | // @test group CODE_LOAD tinyTester.err_threshold = 0.500 |
whismanoid | 1:f7dd5b495201 | 350 | // // |
whismanoid | 0:49c7e35bd044 | 351 | // @test group CODE_LOAD tinyTester.print("0x0fa000 = 4.000V") |
whismanoid | 0:49c7e35bd044 | 352 | // @test group CODE_LOAD CODE_LOAD(0x0fa000) // 4.000V |
whismanoid | 0:49c7e35bd044 | 353 | // @test group CODE_LOAD tinyTester.Wait_Output_Settling() |
whismanoid | 0:49c7e35bd044 | 354 | // @test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(4.000000) |
whismanoid | 0:49c7e35bd044 | 355 | // // |
whismanoid | 1:f7dd5b495201 | 356 | // @test group CODE_LOAD tinyTester.err_threshold = 0.750 |
whismanoid | 1:f7dd5b495201 | 357 | // // |
whismanoid | 0:49c7e35bd044 | 358 | // @test group CODE_LOAD tinyTester.print("0x0fffff = 4.095V") |
whismanoid | 0:49c7e35bd044 | 359 | // @test group CODE_LOAD CODE_LOAD(0x0fffff) // 4.095V |
whismanoid | 0:49c7e35bd044 | 360 | // @test group CODE_LOAD tinyTester.Wait_Output_Settling() |
whismanoid | 0:49c7e35bd044 | 361 | // @test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(4.095000) |
whismanoid | 0:49c7e35bd044 | 362 | // // |
whismanoid | 1:f7dd5b495201 | 363 | // @test group CODE_LOAD tinyTester.err_threshold = 0.200 |
whismanoid | 1:f7dd5b495201 | 364 | // // |
whismanoid | 0:49c7e35bd044 | 365 | // @test group CODE_LOAD tinyTester.print("0x080000 // 2.048V") |
whismanoid | 0:49c7e35bd044 | 366 | // @test group CODE_LOAD CODE_LOAD(0x080000) // 2.048V |
whismanoid | 0:49c7e35bd044 | 367 | // @test group CODE_LOAD tinyTester.Wait_Output_Settling() |
whismanoid | 0:49c7e35bd044 | 368 | // @test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(2.048000) |
whismanoid | 0:49c7e35bd044 | 369 | // // |
whismanoid | 0:49c7e35bd044 | 370 | // |
whismanoid | 0:49c7e35bd044 | 371 | // |
whismanoid | 0:49c7e35bd044 | 372 | void MAX5719::Init(void) |
whismanoid | 0:49c7e35bd044 | 373 | { |
whismanoid | 0:49c7e35bd044 | 374 | |
whismanoid | 0:49c7e35bd044 | 375 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 376 | // Nominal Full-Scale Voltage Reference |
whismanoid | 0:49c7e35bd044 | 377 | VRef = 4.096; |
whismanoid | 0:49c7e35bd044 | 378 | } |
whismanoid | 0:49c7e35bd044 | 379 | |
whismanoid | 0:49c7e35bd044 | 380 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 381 | // Return the DAC register value corresponding to physical voltage. |
whismanoid | 0:49c7e35bd044 | 382 | // Does not perform any offset or gain correction. |
whismanoid | 0:49c7e35bd044 | 383 | // |
whismanoid | 0:49c7e35bd044 | 384 | // @pre VRef = Voltage of REF input, in Volts |
whismanoid | 0:49c7e35bd044 | 385 | // @param[in] voltage = physical voltage in Volts |
whismanoid | 0:49c7e35bd044 | 386 | // @return raw 20-bit MAX5719 code (right justified). |
whismanoid | 0:49c7e35bd044 | 387 | // |
whismanoid | 0:49c7e35bd044 | 388 | // @test group DACCodeOfVoltage // Verify function DACCodeOfVoltage (enabled by default) |
whismanoid | 0:49c7e35bd044 | 389 | // @test group DACCodeOfVoltage tinyTester.blink_time_msec = 20 // quickly speed through the software verification |
whismanoid | 0:49c7e35bd044 | 390 | // @test group DACCodeOfVoltage tinyTester.print("VRef = 4.096 MAX5719 20-bit LSB = 0.000004V = 3.90625uV") |
whismanoid | 0:49c7e35bd044 | 391 | // @test group DACCodeOfVoltage VRef = 4.096 |
whismanoid | 0:49c7e35bd044 | 392 | // @test group DACCodeOfVoltage tinyTester.print("test_voltage_sweep V = 0.000000V to 4.096000V precision 0.100000V step 0.500000V") |
whismanoid | 0:49c7e35bd044 | 393 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.000000) expect 0x000000 // 0.000V |
whismanoid | 0:49c7e35bd044 | 394 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.500000) expect 0x01f400 // 0.500V |
whismanoid | 0:49c7e35bd044 | 395 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.000000) expect 0x03e800 // 1.000V |
whismanoid | 0:49c7e35bd044 | 396 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.500000) expect 0x05dc00 // 1.500V |
whismanoid | 0:49c7e35bd044 | 397 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.000000) expect 0x07d000 // 2.000V |
whismanoid | 0:49c7e35bd044 | 398 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.500000) expect 0x09c400 // 2.500V |
whismanoid | 0:49c7e35bd044 | 399 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.000000) expect 0x0bb800 // 3.000V |
whismanoid | 0:49c7e35bd044 | 400 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.500000) expect 0x0dac00 // 3.500V |
whismanoid | 0:49c7e35bd044 | 401 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.000000) expect 0x0fa000 // 4.000V |
whismanoid | 0:49c7e35bd044 | 402 | // @test group DACCodeOfVoltage tinyTester.print("test_voltage_sweep V = -0.010000V to 0.100000V precision 0.010000V step 0.010000V") |
whismanoid | 0:49c7e35bd044 | 403 | // @test group DACCodeOfVoltage DACCodeOfVoltage(-0.010000) expect 0x000000 // -0.010V |
whismanoid | 0:49c7e35bd044 | 404 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.000000) expect 0x000000 // 0.000V |
whismanoid | 0:49c7e35bd044 | 405 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.010000) expect 0x000a00 // 0.010V |
whismanoid | 0:49c7e35bd044 | 406 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.020000) expect 0x001400 // 0.020V |
whismanoid | 0:49c7e35bd044 | 407 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.030000) expect 0x001e00 // 0.030V |
whismanoid | 0:49c7e35bd044 | 408 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.040000) expect 0x002800 // 0.040V |
whismanoid | 0:49c7e35bd044 | 409 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.050000) expect 0x003200 // 0.050V |
whismanoid | 0:49c7e35bd044 | 410 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.060000) expect 0x003c00 // 0.060V |
whismanoid | 0:49c7e35bd044 | 411 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.070000) expect 0x004600 // 0.070V |
whismanoid | 0:49c7e35bd044 | 412 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.080000) expect 0x005000 // 0.080V |
whismanoid | 0:49c7e35bd044 | 413 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.090000) expect 0x005a00 // 0.090V |
whismanoid | 0:49c7e35bd044 | 414 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.100000) expect 0x006400 // 0.100V |
whismanoid | 0:49c7e35bd044 | 415 | // @test group DACCodeOfVoltage tinyTester.print("test_voltage_sweep V = 2.047900V to 2.048100V precision 0.000010V step 0.000010V") |
whismanoid | 0:49c7e35bd044 | 416 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047890) expect 0x07ffe4 // 2.048V |
whismanoid | 0:49c7e35bd044 | 417 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047900) expect 0x07ffe6 // 2.048V |
whismanoid | 0:49c7e35bd044 | 418 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047910) expect 0x07ffe9 // 2.048V |
whismanoid | 0:49c7e35bd044 | 419 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047920) expect 0x07ffec // 2.048V |
whismanoid | 0:49c7e35bd044 | 420 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047930) expect 0x07ffee // 2.048V |
whismanoid | 0:49c7e35bd044 | 421 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047940) expect 0x07fff1 // 2.048V |
whismanoid | 0:49c7e35bd044 | 422 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047950) expect 0x07fff3 // 2.048V |
whismanoid | 0:49c7e35bd044 | 423 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047960) expect 0x07fff6 // 2.048V |
whismanoid | 0:49c7e35bd044 | 424 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047970) expect 0x07fff8 // 2.048V |
whismanoid | 0:49c7e35bd044 | 425 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047980) expect 0x07fffb // 2.048V |
whismanoid | 0:49c7e35bd044 | 426 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047990) expect 0x07fffd // 2.048V |
whismanoid | 0:49c7e35bd044 | 427 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048000) expect 0x080000 // 2.048V |
whismanoid | 0:49c7e35bd044 | 428 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048010) expect 0x080003 // 2.048V |
whismanoid | 0:49c7e35bd044 | 429 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048020) expect 0x080005 // 2.048V |
whismanoid | 0:49c7e35bd044 | 430 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048030) expect 0x080008 // 2.048V |
whismanoid | 0:49c7e35bd044 | 431 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048040) expect 0x08000a // 2.048V |
whismanoid | 0:49c7e35bd044 | 432 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048050) expect 0x08000d // 2.048V |
whismanoid | 0:49c7e35bd044 | 433 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048060) expect 0x08000f // 2.048V |
whismanoid | 0:49c7e35bd044 | 434 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048070) expect 0x080012 // 2.048V |
whismanoid | 0:49c7e35bd044 | 435 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048080) expect 0x080014 // 2.048V |
whismanoid | 0:49c7e35bd044 | 436 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048090) expect 0x080017 // 2.048V |
whismanoid | 0:49c7e35bd044 | 437 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048100) expect 0x08001a // 2.048V |
whismanoid | 0:49c7e35bd044 | 438 | // @test group DACCodeOfVoltage tinyTester.print("test_voltage_sweep V = 3.996000V to 4.106000V precision 0.010000V step 0.010000V") |
whismanoid | 0:49c7e35bd044 | 439 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.990000) expect 0x0f9600 // 3.990V |
whismanoid | 0:49c7e35bd044 | 440 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.000000) expect 0x0fa000 // 4.000V |
whismanoid | 0:49c7e35bd044 | 441 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.010000) expect 0x0faa00 // 4.010V |
whismanoid | 0:49c7e35bd044 | 442 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.020000) expect 0x0fb400 // 4.020V |
whismanoid | 0:49c7e35bd044 | 443 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.030000) expect 0x0fbe00 // 4.030V |
whismanoid | 0:49c7e35bd044 | 444 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.040000) expect 0x0fc800 // 4.040V |
whismanoid | 0:49c7e35bd044 | 445 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.050000) expect 0x0fd200 // 4.050V |
whismanoid | 0:49c7e35bd044 | 446 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.060000) expect 0x0fdc00 // 4.060V |
whismanoid | 0:49c7e35bd044 | 447 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.070000) expect 0x0fe600 // 4.070V |
whismanoid | 0:49c7e35bd044 | 448 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.080000) expect 0x0ff000 // 4.080V |
whismanoid | 0:49c7e35bd044 | 449 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.090000) expect 0x0ffa00 // 4.090V |
whismanoid | 0:49c7e35bd044 | 450 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.100000) expect 0x0fffff // 4.100V |
whismanoid | 0:49c7e35bd044 | 451 | // @test group DACCodeOfVoltage tinyTester.print("test_lsb_sweep V = 4.096000V LSBradius = 3LSB") |
whismanoid | 0:49c7e35bd044 | 452 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.095988) expect 0x0ffffd // 4.096V + -3.0LSB |
whismanoid | 0:49c7e35bd044 | 453 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.095990) expect 0x0ffffd // 4.096V + -2.5LSB 0x0ffffd not 0x0ffffe |
whismanoid | 0:49c7e35bd044 | 454 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.095992) expect 0x0ffffe // 4.096V + -2.0LSB |
whismanoid | 0:49c7e35bd044 | 455 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.095994) expect 0x0ffffe // 4.096V + -1.5LSB |
whismanoid | 0:49c7e35bd044 | 456 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.095996) expect 0x0fffff // 4.096V + -1.0LSB |
whismanoid | 0:49c7e35bd044 | 457 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.095998) expect 0x0fffff // 4.096V + -0.5LSB |
whismanoid | 0:49c7e35bd044 | 458 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.096000) expect 0x0fffff // 4.096V + 0.0LSB |
whismanoid | 0:49c7e35bd044 | 459 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.096002) expect 0x0fffff // 4.096V + 0.5LSB |
whismanoid | 0:49c7e35bd044 | 460 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.096004) expect 0x0fffff // 4.096V + 1.0LSB |
whismanoid | 0:49c7e35bd044 | 461 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.096006) expect 0x0fffff // 4.096V + 1.5LSB |
whismanoid | 0:49c7e35bd044 | 462 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.096008) expect 0x0fffff // 4.096V + 2.0LSB |
whismanoid | 0:49c7e35bd044 | 463 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.096010) expect 0x0fffff // 4.096V + 2.5LSB |
whismanoid | 0:49c7e35bd044 | 464 | // @test group DACCodeOfVoltage DACCodeOfVoltage(4.096012) expect 0x0fffff // 4.096V + 3.0LSB |
whismanoid | 0:49c7e35bd044 | 465 | // @test group DACCodeOfVoltage tinyTester.print("test_lsb_sweep V = 3.072000V LSBradius = 3LSB") |
whismanoid | 0:49c7e35bd044 | 466 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.071988) expect 0x0bfffd // 3.072V + -3.0LSB |
whismanoid | 0:49c7e35bd044 | 467 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.071990) expect 0x0bfffd // 3.072V + -2.5LSB 0x0bfffd not 0x0bfffe |
whismanoid | 0:49c7e35bd044 | 468 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.071992) expect 0x0bfffe // 3.072V + -2.0LSB |
whismanoid | 0:49c7e35bd044 | 469 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.071994) expect 0x0bfffe // 3.072V + -1.5LSB 0x0bfffe not 0x0bffff |
whismanoid | 0:49c7e35bd044 | 470 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.071996) expect 0x0bffff // 3.072V + -1.0LSB |
whismanoid | 0:49c7e35bd044 | 471 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.071998) expect 0x0bffff // 3.072V + -0.5LSB 0x0bffff not 0x0c0000 |
whismanoid | 0:49c7e35bd044 | 472 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.072000) expect 0x0c0000 // 3.072V + 0.0LSB |
whismanoid | 0:49c7e35bd044 | 473 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.072002) expect 0x0c0001 // 3.072V + 0.5LSB |
whismanoid | 0:49c7e35bd044 | 474 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.072004) expect 0x0c0001 // 3.072V + 1.0LSB |
whismanoid | 0:49c7e35bd044 | 475 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.072006) expect 0x0c0002 // 3.072V + 1.5LSB |
whismanoid | 0:49c7e35bd044 | 476 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.072008) expect 0x0c0002 // 3.072V + 2.0LSB |
whismanoid | 0:49c7e35bd044 | 477 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.072010) expect 0x0c0003 // 3.072V + 2.5LSB |
whismanoid | 0:49c7e35bd044 | 478 | // @test group DACCodeOfVoltage DACCodeOfVoltage(3.072012) expect 0x0c0003 // 3.072V + 3.0LSB |
whismanoid | 0:49c7e35bd044 | 479 | // @test group DACCodeOfVoltage tinyTester.print("test_lsb_sweep V = 2.048000V LSBradius = 3LSB") |
whismanoid | 0:49c7e35bd044 | 480 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047988) expect 0x07fffd // 2.048V + -3.0LSB |
whismanoid | 0:49c7e35bd044 | 481 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047990) expect 0x07fffd // 2.048V + -2.5LSB |
whismanoid | 0:49c7e35bd044 | 482 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047992) expect 0x07fffe // 2.048V + -2.0LSB |
whismanoid | 0:49c7e35bd044 | 483 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047994) expect 0x07fffe // 2.048V + -1.5LSB 0x07fffe not 0x07ffff |
whismanoid | 0:49c7e35bd044 | 484 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047996) expect 0x07ffff // 2.048V + -1.0LSB |
whismanoid | 0:49c7e35bd044 | 485 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.047998) expect 0x07ffff // 2.048V + -0.5LSB 0x07ffff not 0x080000 |
whismanoid | 0:49c7e35bd044 | 486 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048000) expect 0x080000 // 2.048V + 0.0LSB |
whismanoid | 0:49c7e35bd044 | 487 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048002) expect 0x080001 // 2.048V + 0.5LSB |
whismanoid | 0:49c7e35bd044 | 488 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048004) expect 0x080001 // 2.048V + 1.0LSB |
whismanoid | 0:49c7e35bd044 | 489 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048006) expect 0x080002 // 2.048V + 1.5LSB |
whismanoid | 0:49c7e35bd044 | 490 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048008) expect 0x080002 // 2.048V + 2.0LSB |
whismanoid | 0:49c7e35bd044 | 491 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048010) expect 0x080003 // 2.048V + 2.5LSB |
whismanoid | 0:49c7e35bd044 | 492 | // @test group DACCodeOfVoltage DACCodeOfVoltage(2.048012) expect 0x080003 // 2.048V + 3.0LSB |
whismanoid | 0:49c7e35bd044 | 493 | // @test group DACCodeOfVoltage tinyTester.print("test_lsb_sweep V = 1.024000V LSBradius = 3LSB") |
whismanoid | 0:49c7e35bd044 | 494 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.023988) expect 0x03fffd // 1.024V + -3.0LSB |
whismanoid | 0:49c7e35bd044 | 495 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.023990) expect 0x03fffd // 1.024V + -2.5LSB 0x03fffd not 0x03fffe |
whismanoid | 0:49c7e35bd044 | 496 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.023992) expect 0x03fffe // 1.024V + -2.0LSB |
whismanoid | 0:49c7e35bd044 | 497 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.023994) expect 0x03fffe // 1.024V + -1.5LSB |
whismanoid | 0:49c7e35bd044 | 498 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.023996) expect 0x03ffff // 1.024V + -1.0LSB |
whismanoid | 0:49c7e35bd044 | 499 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.023998) expect 0x03ffff // 1.024V + -0.5LSB 0x03ffff not 0x040000 |
whismanoid | 0:49c7e35bd044 | 500 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.024000) expect 0x040000 // 1.024V + 0.0LSB |
whismanoid | 0:49c7e35bd044 | 501 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.024002) expect 0x040001 // 1.024V + 0.5LSB |
whismanoid | 0:49c7e35bd044 | 502 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.024004) expect 0x040001 // 1.024V + 1.0LSB |
whismanoid | 0:49c7e35bd044 | 503 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.024006) expect 0x040002 // 1.024V + 1.5LSB |
whismanoid | 0:49c7e35bd044 | 504 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.024008) expect 0x040002 // 1.024V + 2.0LSB |
whismanoid | 0:49c7e35bd044 | 505 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.024010) expect 0x040003 // 1.024V + 2.5LSB |
whismanoid | 0:49c7e35bd044 | 506 | // @test group DACCodeOfVoltage DACCodeOfVoltage(1.024012) expect 0x040003 // 1.024V + 3.0LSB |
whismanoid | 0:49c7e35bd044 | 507 | // @test group DACCodeOfVoltage tinyTester.print("test_lsb_sweep V = 0.000000V LSBradius = 3LSB") |
whismanoid | 0:49c7e35bd044 | 508 | // @test group DACCodeOfVoltage DACCodeOfVoltage(-0.000012) expect 0x000000 // 0.000V + -3.0LSB |
whismanoid | 0:49c7e35bd044 | 509 | // @test group DACCodeOfVoltage DACCodeOfVoltage(-0.000010) expect 0x000000 // 0.000V + -2.5LSB |
whismanoid | 0:49c7e35bd044 | 510 | // @test group DACCodeOfVoltage DACCodeOfVoltage(-0.000008) expect 0x000000 // 0.000V + -2.0LSB |
whismanoid | 0:49c7e35bd044 | 511 | // @test group DACCodeOfVoltage DACCodeOfVoltage(-0.000006) expect 0x000000 // 0.000V + -1.5LSB |
whismanoid | 0:49c7e35bd044 | 512 | // @test group DACCodeOfVoltage DACCodeOfVoltage(-0.000004) expect 0x000000 // 0.000V + -1.0LSB |
whismanoid | 0:49c7e35bd044 | 513 | // @test group DACCodeOfVoltage DACCodeOfVoltage(-0.000002) expect 0x000000 // 0.000V + -0.5LSB |
whismanoid | 0:49c7e35bd044 | 514 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.000000) expect 0x000000 // 0.000V + 0.0LSB |
whismanoid | 0:49c7e35bd044 | 515 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.000002) expect 0x000001 // 0.000V + 0.5LSB |
whismanoid | 0:49c7e35bd044 | 516 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.000004) expect 0x000001 // 0.000V + 1.0LSB |
whismanoid | 0:49c7e35bd044 | 517 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.000006) expect 0x000002 // 0.000V + 1.5LSB |
whismanoid | 0:49c7e35bd044 | 518 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.000008) expect 0x000002 // 0.000V + 2.0LSB |
whismanoid | 0:49c7e35bd044 | 519 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.000010) expect 0x000003 // 0.000V + 2.5LSB |
whismanoid | 0:49c7e35bd044 | 520 | // @test group DACCodeOfVoltage DACCodeOfVoltage(0.000012) expect 0x000003 // 0.000V + 3.0LSB |
whismanoid | 0:49c7e35bd044 | 521 | // |
whismanoid | 0:49c7e35bd044 | 522 | // @test group DACCodeOfVoltage tinyTester.blink_time_msec = 75 // default 75 resume hardware self test |
whismanoid | 0:49c7e35bd044 | 523 | // |
whismanoid | 0:49c7e35bd044 | 524 | // |
whismanoid | 0:49c7e35bd044 | 525 | uint32_t MAX5719::DACCodeOfVoltage(double voltageV) |
whismanoid | 0:49c7e35bd044 | 526 | { |
whismanoid | 0:49c7e35bd044 | 527 | |
whismanoid | 0:49c7e35bd044 | 528 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 529 | // Linear map min and max endpoints |
whismanoid | 0:49c7e35bd044 | 530 | const double MaxScaleVoltage = VRef; // voltage of maximum code 0xfffff |
whismanoid | 0:49c7e35bd044 | 531 | const double MinScaleVoltage = 0.0; // voltage of minimum code 0x000 |
whismanoid | 0:49c7e35bd044 | 532 | const uint32_t FULL_SCALE_CODE_20BIT = 0xfffff; |
whismanoid | 0:49c7e35bd044 | 533 | const uint32_t MaxCode = FULL_SCALE_CODE_20BIT; |
whismanoid | 0:49c7e35bd044 | 534 | const uint32_t MinCode = 0x000; |
whismanoid | 0:49c7e35bd044 | 535 | double codeFraction = (voltageV - MinScaleVoltage) / (MaxScaleVoltage - MinScaleVoltage); |
whismanoid | 0:49c7e35bd044 | 536 | double dacRegValueIdeal = ((codeFraction * (double)(MaxCode - MinCode + 1)) + MinCode + 0.5); |
whismanoid | 0:49c7e35bd044 | 537 | uint32_t dacRegValue = (uint32_t)dacRegValueIdeal; |
whismanoid | 0:49c7e35bd044 | 538 | if (dacRegValueIdeal > MaxCode) |
whismanoid | 0:49c7e35bd044 | 539 | { |
whismanoid | 0:49c7e35bd044 | 540 | dacRegValue = MaxCode; |
whismanoid | 0:49c7e35bd044 | 541 | } else if (dacRegValueIdeal < MinCode) |
whismanoid | 0:49c7e35bd044 | 542 | { |
whismanoid | 0:49c7e35bd044 | 543 | dacRegValue = MinCode; |
whismanoid | 0:49c7e35bd044 | 544 | } |
whismanoid | 0:49c7e35bd044 | 545 | return dacRegValue; |
whismanoid | 0:49c7e35bd044 | 546 | } |
whismanoid | 0:49c7e35bd044 | 547 | |
whismanoid | 0:49c7e35bd044 | 548 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 549 | // Menu item 'A' |
whismanoid | 0:49c7e35bd044 | 550 | // CODE |
whismanoid | 0:49c7e35bd044 | 551 | // |
whismanoid | 0:49c7e35bd044 | 552 | // Load input register, but DAC registers are not updated until LOAD. |
whismanoid | 0:49c7e35bd044 | 553 | // @return 1 on success; 0 on failure |
whismanoid | 0:49c7e35bd044 | 554 | uint8_t MAX5719::CODE(uint32_t dacCodeLsbs) |
whismanoid | 0:49c7e35bd044 | 555 | { |
whismanoid | 0:49c7e35bd044 | 556 | |
whismanoid | 0:49c7e35bd044 | 557 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 558 | // SPI write 20-bit dacCodeLsbs in mosiData24 |
whismanoid | 0:49c7e35bd044 | 559 | SPIoutputCS(0); |
whismanoid | 0:49c7e35bd044 | 560 | SPIwrite24bits(((dacCodeLsbs << 4) >> 16), ((dacCodeLsbs << 4) & 0xFFFF)); // 20-bit dacCodeLsbs in mosiData24 |
whismanoid | 0:49c7e35bd044 | 561 | SPIoutputCS(1); |
whismanoid | 0:49c7e35bd044 | 562 | |
whismanoid | 0:49c7e35bd044 | 563 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 564 | // write-only DAC ouptut code |
whismanoid | 0:49c7e35bd044 | 565 | DACCode = dacCodeLsbs; |
whismanoid | 0:49c7e35bd044 | 566 | |
whismanoid | 0:49c7e35bd044 | 567 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 568 | // success |
whismanoid | 0:49c7e35bd044 | 569 | return 1; |
whismanoid | 0:49c7e35bd044 | 570 | } |
whismanoid | 0:49c7e35bd044 | 571 | |
whismanoid | 0:49c7e35bd044 | 572 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 573 | // Menu item 'C' |
whismanoid | 0:49c7e35bd044 | 574 | // CODE_LOAD |
whismanoid | 0:49c7e35bd044 | 575 | // |
whismanoid | 0:49c7e35bd044 | 576 | // Load input register; DAC registers are updated. |
whismanoid | 0:49c7e35bd044 | 577 | // @return 1 on success; 0 on failure |
whismanoid | 0:49c7e35bd044 | 578 | uint8_t MAX5719::CODE_LOAD(uint32_t dacCodeLsbs) |
whismanoid | 0:49c7e35bd044 | 579 | { |
whismanoid | 0:49c7e35bd044 | 580 | |
whismanoid | 0:49c7e35bd044 | 581 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 582 | // SPI write 20-bit dacCodeLsbs in mosiData24 |
whismanoid | 0:49c7e35bd044 | 583 | SPIoutputCS(0); |
whismanoid | 0:49c7e35bd044 | 584 | SPIwrite24bits(((dacCodeLsbs << 4) >> 16), ((dacCodeLsbs << 4) & 0xFFFF)); // 20-bit dacCodeLsbs in mosiData24 |
whismanoid | 0:49c7e35bd044 | 585 | SPIoutputCS(1); |
whismanoid | 0:49c7e35bd044 | 586 | |
whismanoid | 0:49c7e35bd044 | 587 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 588 | // write-only DAC ouptut code |
whismanoid | 0:49c7e35bd044 | 589 | DACCode = dacCodeLsbs; |
whismanoid | 0:49c7e35bd044 | 590 | |
whismanoid | 0:49c7e35bd044 | 591 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 592 | // call low-level GPIO function |
whismanoid | 0:49c7e35bd044 | 593 | LDACboutputValue(0); // LDAC# Active |
whismanoid | 0:49c7e35bd044 | 594 | |
whismanoid | 0:49c7e35bd044 | 595 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 596 | // call low-level GPIO function |
whismanoid | 0:49c7e35bd044 | 597 | LDACboutputValue(1); // LDAC# Inactive |
whismanoid | 0:49c7e35bd044 | 598 | |
whismanoid | 0:49c7e35bd044 | 599 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 600 | // success |
whismanoid | 0:49c7e35bd044 | 601 | return 1; |
whismanoid | 0:49c7e35bd044 | 602 | } |
whismanoid | 0:49c7e35bd044 | 603 | |
whismanoid | 0:49c7e35bd044 | 604 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 605 | // Menu item 'B' |
whismanoid | 0:49c7e35bd044 | 606 | // LOAD |
whismanoid | 0:49c7e35bd044 | 607 | // |
whismanoid | 0:49c7e35bd044 | 608 | // Update DAC registers from input registers. |
whismanoid | 0:49c7e35bd044 | 609 | // @return 1 on success; 0 on failure |
whismanoid | 0:49c7e35bd044 | 610 | uint8_t MAX5719::LOAD(void) |
whismanoid | 0:49c7e35bd044 | 611 | { |
whismanoid | 0:49c7e35bd044 | 612 | |
whismanoid | 0:49c7e35bd044 | 613 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 614 | // call low-level GPIO function |
whismanoid | 0:49c7e35bd044 | 615 | LDACboutputValue(0); // LDAC# Active |
whismanoid | 0:49c7e35bd044 | 616 | |
whismanoid | 0:49c7e35bd044 | 617 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 618 | // call low-level GPIO function |
whismanoid | 0:49c7e35bd044 | 619 | LDACboutputValue(1); // LDAC# Inactive |
whismanoid | 0:49c7e35bd044 | 620 | |
whismanoid | 0:49c7e35bd044 | 621 | //---------------------------------------- |
whismanoid | 0:49c7e35bd044 | 622 | // success |
whismanoid | 0:49c7e35bd044 | 623 | return 1; |
whismanoid | 0:49c7e35bd044 | 624 | } |
whismanoid | 0:49c7e35bd044 | 625 | |
whismanoid | 0:49c7e35bd044 | 626 | |
whismanoid | 0:49c7e35bd044 | 627 | // End of file |