Maxim Integrated / Mbed OS MAX5719BOB_FunctionGen

Dependencies:   FunctionGenerator MAX5719

Committer:
whismanoid
Date:
Sun Jan 03 05:11:44 2021 +0000
Revision:
26:b89783422715
Initial Commit MAX5719BOB_FunctionGen (error M_PI undefined)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 26:b89783422715 1 // /*******************************************************************************
whismanoid 26:b89783422715 2 // * Copyright (C) 2021 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 26:b89783422715 3 // *
whismanoid 26:b89783422715 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 26:b89783422715 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 26:b89783422715 6 // * to deal in the Software without restriction, including without limitation
whismanoid 26:b89783422715 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 26:b89783422715 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 26:b89783422715 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 26:b89783422715 10 // *
whismanoid 26:b89783422715 11 // * The above copyright notice and this permission notice shall be included
whismanoid 26:b89783422715 12 // * in all copies or substantial portions of the Software.
whismanoid 26:b89783422715 13 // *
whismanoid 26:b89783422715 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 26:b89783422715 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 26:b89783422715 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 26:b89783422715 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 26:b89783422715 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 26:b89783422715 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 26:b89783422715 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 26:b89783422715 21 // *
whismanoid 26:b89783422715 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 26:b89783422715 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 26:b89783422715 24 // * Products, Inc. Branding Policy.
whismanoid 26:b89783422715 25 // *
whismanoid 26:b89783422715 26 // * The mere transfer of this software does not imply any licenses
whismanoid 26:b89783422715 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 26:b89783422715 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 26:b89783422715 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 26:b89783422715 30 // * ownership rights.
whismanoid 26:b89783422715 31 // *******************************************************************************
whismanoid 26:b89783422715 32 // */
whismanoid 26:b89783422715 33 // example code includes
whismanoid 26:b89783422715 34 // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 26:b89783422715 35 #include "mbed.h"
whismanoid 26:b89783422715 36 // Platforms:
whismanoid 26:b89783422715 37 // - MAX32625MBED
whismanoid 26:b89783422715 38 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 26:b89783422715 39 // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 26:b89783422715 40 // - remove max32630fthr library (if present)
whismanoid 26:b89783422715 41 // - remove MAX32620FTHR library (if present)
whismanoid 26:b89783422715 42 // - MAX32600MBED
whismanoid 26:b89783422715 43 // - Please note the last supported version is Mbed OS 6.3.
whismanoid 26:b89783422715 44 // - remove max32630fthr library (if present)
whismanoid 26:b89783422715 45 // - remove MAX32620FTHR library (if present)
whismanoid 26:b89783422715 46 // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 26:b89783422715 47 // - NUCLEO_F446RE
whismanoid 26:b89783422715 48 // - remove USBDevice library
whismanoid 26:b89783422715 49 // - remove max32630fthr library (if present)
whismanoid 26:b89783422715 50 // - remove MAX32620FTHR library (if present)
whismanoid 26:b89783422715 51 // - NUCLEO_F401RE
whismanoid 26:b89783422715 52 // - remove USBDevice library
whismanoid 26:b89783422715 53 // - remove max32630fthr library (if present)
whismanoid 26:b89783422715 54 // - remove MAX32620FTHR library (if present)
whismanoid 26:b89783422715 55 // - MAX32630FTHR
whismanoid 26:b89783422715 56 // - #include "max32630fthr.h"
whismanoid 26:b89783422715 57 // - add http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 26:b89783422715 58 // - remove MAX32620FTHR library (if present)
whismanoid 26:b89783422715 59 // - MAX32620FTHR
whismanoid 26:b89783422715 60 // - #include "MAX32620FTHR.h"
whismanoid 26:b89783422715 61 // - remove max32630fthr library (if present)
whismanoid 26:b89783422715 62 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 26:b89783422715 63 // - not tested yet
whismanoid 26:b89783422715 64 // - MAX32625PICO
whismanoid 26:b89783422715 65 // - #include "max32625pico.h"
whismanoid 26:b89783422715 66 // - add https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 26:b89783422715 67 // - remove max32630fthr library (if present)
whismanoid 26:b89783422715 68 // - remove MAX32620FTHR library (if present)
whismanoid 26:b89783422715 69 // - not tested yet
whismanoid 26:b89783422715 70 // - see https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 26:b89783422715 71 // - see https://os.mbed.com/users/switches/code/PICO_board_demo/
whismanoid 26:b89783422715 72 // - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/
whismanoid 26:b89783422715 73 // - see https://os.mbed.com/users/switches/code/SerialInterface/
whismanoid 26:b89783422715 74 // - Note: To load the MAX32625PICO firmware, hold the button while
whismanoid 26:b89783422715 75 // connecting the USB cable, then copy firmware bin file
whismanoid 26:b89783422715 76 // to the MAINTENANCE drive.
whismanoid 26:b89783422715 77 // - see https://os.mbed.com/platforms/MAX32625PICO/
whismanoid 26:b89783422715 78 // - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates
whismanoid 26:b89783422715 79 //
whismanoid 26:b89783422715 80 // end Platform_Include_Boilerplate
whismanoid 26:b89783422715 81 #include "MAX5719.h"
whismanoid 26:b89783422715 82
whismanoid 26:b89783422715 83 // example code board support
whismanoid 26:b89783422715 84 //MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 26:b89783422715 85 //DigitalOut rLED(LED1);
whismanoid 26:b89783422715 86 //DigitalOut gLED(LED2);
whismanoid 26:b89783422715 87 //DigitalOut bLED(LED3);
whismanoid 26:b89783422715 88 //
whismanoid 26:b89783422715 89 // Arduino "shield" connector port definitions (MAX32625MBED shown)
whismanoid 26:b89783422715 90 #if defined(TARGET_MAX32625MBED)
whismanoid 26:b89783422715 91 #define A0 AIN_0
whismanoid 26:b89783422715 92 #define A1 AIN_1
whismanoid 26:b89783422715 93 #define A2 AIN_2
whismanoid 26:b89783422715 94 #define A3 AIN_3
whismanoid 26:b89783422715 95 #define D0 P0_0
whismanoid 26:b89783422715 96 #define D1 P0_1
whismanoid 26:b89783422715 97 #define D2 P0_2
whismanoid 26:b89783422715 98 #define D3 P0_3
whismanoid 26:b89783422715 99 #define D4 P0_4
whismanoid 26:b89783422715 100 #define D5 P0_5
whismanoid 26:b89783422715 101 #define D6 P0_6
whismanoid 26:b89783422715 102 #define D7 P0_7
whismanoid 26:b89783422715 103 #define D8 P1_4
whismanoid 26:b89783422715 104 #define D9 P1_5
whismanoid 26:b89783422715 105 #define D10 P1_3
whismanoid 26:b89783422715 106 #define D11 P1_1
whismanoid 26:b89783422715 107 #define D12 P1_2
whismanoid 26:b89783422715 108 #define D13 P1_0
whismanoid 26:b89783422715 109 #elif defined(TARGET_MAX32625PICO)
whismanoid 26:b89783422715 110 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 26:b89783422715 111 #define A0 AIN_1
whismanoid 26:b89783422715 112 #define A1 AIN_2
whismanoid 26:b89783422715 113 // #define A2 AIN_3
whismanoid 26:b89783422715 114 // #define A3 AIN_0
whismanoid 26:b89783422715 115 #define D0 P0_0
whismanoid 26:b89783422715 116 #define D1 P0_1
whismanoid 26:b89783422715 117 #define D2 P0_2
whismanoid 26:b89783422715 118 #define D3 P0_3
whismanoid 26:b89783422715 119 #define D4 P1_7
whismanoid 26:b89783422715 120 #define D5 P1_6
whismanoid 26:b89783422715 121 #define D6 P4_4
whismanoid 26:b89783422715 122 #define D7 P4_5
whismanoid 26:b89783422715 123 #define D8 P4_6
whismanoid 26:b89783422715 124 #define D9 P4_7
whismanoid 26:b89783422715 125 #define D10 P0_7
whismanoid 26:b89783422715 126 #define D11 P0_6
whismanoid 26:b89783422715 127 #define D12 P0_5
whismanoid 26:b89783422715 128 #define D13 P0_4
whismanoid 26:b89783422715 129 #endif
whismanoid 26:b89783422715 130
whismanoid 26:b89783422715 131 // example code declare SPI interface (GPIO controlled CS)
whismanoid 26:b89783422715 132 #if defined(TARGET_MAX32625MBED)
whismanoid 26:b89783422715 133 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
whismanoid 26:b89783422715 134 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 26:b89783422715 135 #elif defined(TARGET_MAX32625PICO)
whismanoid 26:b89783422715 136 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 26:b89783422715 137 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
whismanoid 26:b89783422715 138 DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
whismanoid 26:b89783422715 139 #elif defined(TARGET_MAX32600MBED)
whismanoid 26:b89783422715 140 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 26:b89783422715 141 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 26:b89783422715 142 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 26:b89783422715 143 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 26:b89783422715 144 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 26:b89783422715 145 //
whismanoid 26:b89783422715 146 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 26:b89783422715 147 SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); // mosi, miso, sclk spi1 TARGET_NUCLEO_F446RE: Arduino 10-pin header D11 D12 D13
whismanoid 26:b89783422715 148 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 26:b89783422715 149 //
whismanoid 26:b89783422715 150 #else
whismanoid 26:b89783422715 151 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 26:b89783422715 152 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 26:b89783422715 153 #endif
whismanoid 26:b89783422715 154
whismanoid 26:b89783422715 155 // example code declare GPIO interface pins
whismanoid 26:b89783422715 156 // AnalogOut RFB_pin(Px_x_PortName_To_Be_Determined); // Analog Input to MAX5719 device
whismanoid 26:b89783422715 157 // AnalogOut INV_pin(Px_x_PortName_To_Be_Determined); // Analog Input to MAX5719 device
whismanoid 26:b89783422715 158 DigitalOut LDACb_pin(D9); // Digital Trigger Input to MAX5719 device
whismanoid 26:b89783422715 159 // AnalogIn OUT_pin(A0); // Analog Output from MAX5719 device
whismanoid 26:b89783422715 160 // example code declare device instance
whismanoid 26:b89783422715 161 MAX5719 g_MAX5719_device(spi, spi_cs, LDACb_pin, MAX5719::MAX5719_IC);
whismanoid 26:b89783422715 162
whismanoid 26:b89783422715 163 // FUTURE: Function Generator for DAC output -- declarations
whismanoid 26:b89783422715 164 //--------------------------------------------------
whismanoid 26:b89783422715 165 // Function Generator for DAC output
whismanoid 26:b89783422715 166 //
whismanoid 26:b89783422715 167 #ifndef USE_FunctionGenerator
whismanoid 26:b89783422715 168 #define USE_FunctionGenerator 1
whismanoid 26:b89783422715 169 #endif // USE_FunctionGenerator
whismanoid 26:b89783422715 170
whismanoid 26:b89783422715 171 #if USE_FunctionGenerator
whismanoid 26:b89783422715 172 //--------------------------------------------------
whismanoid 26:b89783422715 173 // Function Generator for DAC output
whismanoid 26:b89783422715 174 //
whismanoid 26:b89783422715 175 #include "FunctionGenerator.h"
whismanoid 26:b89783422715 176 #endif // USE_FunctionGenerator
whismanoid 26:b89783422715 177
whismanoid 26:b89783422715 178 #if USE_FunctionGenerator
whismanoid 26:b89783422715 179 //--------------------------------------------------
whismanoid 26:b89783422715 180 // declare a Function Generator object
whismanoid 26:b89783422715 181 //
whismanoid 26:b89783422715 182 DACFunctionGenerator DACStepFunctionGenerator;
whismanoid 26:b89783422715 183 #endif // USE_FunctionGenerator
whismanoid 26:b89783422715 184
whismanoid 26:b89783422715 185 // example code main function
whismanoid 26:b89783422715 186 int main()
whismanoid 26:b89783422715 187 {
whismanoid 26:b89783422715 188 // setup: put your setup code here, to run once
whismanoid 26:b89783422715 189
whismanoid 26:b89783422715 190 g_MAX5719_device.Init();
whismanoid 26:b89783422715 191
whismanoid 26:b89783422715 192 // FUTURE: Function Generator for DAC output -- setup
whismanoid 26:b89783422715 193 // CODE GENERATOR: ResolutionBits = 20
whismanoid 26:b89783422715 194 // CODE GENERATOR: FScode = 0xfffff
whismanoid 26:b89783422715 195 #if USE_FunctionGenerator
whismanoid 26:b89783422715 196 DACStepFunctionGenerator.Configure_Constant(
whismanoid 26:b89783422715 197 /* uint32_t code */ 0x7ffff // 50.0% of full scale
whismanoid 26:b89783422715 198 );
whismanoid 26:b89783422715 199 #if USE_FunctionGenerator_TriangleRampUpDown
whismanoid 26:b89783422715 200 DACStepFunctionGenerator.Configure_TriangleRampUpDown(
whismanoid 26:b89783422715 201 /* uint32_t code_limit_L */ 0x0000, // 0.0% of full scale
whismanoid 26:b89783422715 202 /* uint32_t code_limit_H */ 0xfffff, // 100.0% of full scale
whismanoid 26:b89783422715 203 /* int32_t increment */ 0x00001
whismanoid 26:b89783422715 204 );
whismanoid 26:b89783422715 205 #endif // USE_FunctionGenerator_TriangleRampUpDown
whismanoid 26:b89783422715 206 #if USE_FunctionGenerator_RampUp
whismanoid 26:b89783422715 207 DACStepFunctionGenerator.Configure_RampUp(
whismanoid 26:b89783422715 208 /* uint32_t code_limit_L */ 0x0000, // 0.0% of full scale
whismanoid 26:b89783422715 209 /* uint32_t code_limit_H */ 0xfffff, // 100.0% of full scale
whismanoid 26:b89783422715 210 /* int32_t increment */ 0x00001
whismanoid 26:b89783422715 211 );
whismanoid 26:b89783422715 212 #endif // USE_FunctionGenerator_RampUp
whismanoid 26:b89783422715 213 #if USE_FunctionGenerator_RampDown
whismanoid 26:b89783422715 214 DACStepFunctionGenerator.Configure_RampDown(
whismanoid 26:b89783422715 215 /* uint32_t code_limit_L */ 0x0000, // 0.0% of full scale
whismanoid 26:b89783422715 216 /* uint32_t code_limit_H */ 0xfffff, // 100.0% of full scale
whismanoid 26:b89783422715 217 /* int32_t increment */ 0x00001
whismanoid 26:b89783422715 218 );
whismanoid 26:b89783422715 219 #endif // USE_FunctionGeneratorRampDown
whismanoid 26:b89783422715 220 #if USE_FunctionGenerator_Sine
whismanoid 26:b89783422715 221 DACStepFunctionGenerator.Configure_Sine(
whismanoid 26:b89783422715 222 /* uint32_t code_limit_L */ 0x0000, // 0.0% of full scale
whismanoid 26:b89783422715 223 /* uint32_t code_limit_H */ 0xfffff, // 100.0% of full scale
whismanoid 26:b89783422715 224 /* float num_samples_per_tone_cycle */ 128.0
whismanoid 26:b89783422715 225 );
whismanoid 26:b89783422715 226 #endif // USE_FunctionGenerator_Sine
whismanoid 26:b89783422715 227 #if USE_FunctionGenerator_Table
whismanoid 26:b89783422715 228 static uint32_t waveformTable[] = {
whismanoid 26:b89783422715 229 0xfffff, // 100.0% of full scale REF(4.096V) = 4.096V
whismanoid 26:b89783422715 230 0xe6665, // 90.0% of full scale REF(4.096V) = 3.686V
whismanoid 26:b89783422715 231 0xccccc, // 80.0% of full scale REF(4.096V) = 3.277V
whismanoid 26:b89783422715 232 0xb3332, // 70.0% of full scale REF(4.096V) = 2.867V
whismanoid 26:b89783422715 233 0x99999, // 60.0% of full scale REF(4.096V) = 2.458V
whismanoid 26:b89783422715 234 0x7ffff, // 50.0% of full scale REF(4.096V) = 2.048V
whismanoid 26:b89783422715 235 0x66666, // 40.0% of full scale REF(4.096V) = 1.638V
whismanoid 26:b89783422715 236 0x4cccc, // 30.0% of full scale REF(4.096V) = 1.229V
whismanoid 26:b89783422715 237 0x33333, // 20.0% of full scale REF(4.096V) = 0.819V
whismanoid 26:b89783422715 238 0x19999, // 10.0% of full scale REF(4.096V) = 0.410V
whismanoid 26:b89783422715 239 0x00000, // 0.0% of full scale REF(4.096V) = 0.000V
whismanoid 26:b89783422715 240 };
whismanoid 26:b89783422715 241 DACStepFunctionGenerator.Configure_Table(
whismanoid 26:b89783422715 242 /* uint32_t* table_data */ waveformTable,
whismanoid 26:b89783422715 243 /* table_length */ 11 /* sizeof(waveformTable)/sizeof(uint32_t) */,
whismanoid 26:b89783422715 244 /* increment */ 0x00001
whismanoid 26:b89783422715 245 );
whismanoid 26:b89783422715 246 #endif // USE_FunctionGenerator_Table
whismanoid 26:b89783422715 247 #if USE_FunctionGenerator_Sine_Table
whismanoid 26:b89783422715 248 #define sizeof_sineWaveformTable 256
whismanoid 26:b89783422715 249 static uint32_t sineWaveformTable[sizeof_sineWaveformTable];
whismanoid 26:b89783422715 250 DACStepFunctionGenerator.Configure_Sine_Table(
whismanoid 26:b89783422715 251 /* uint32_t* table_data_buffer */ sineWaveformTable,
whismanoid 26:b89783422715 252 /* uint32_t table_length */ sizeof_sineWaveformTable, /* sizeof(sineWaveformTable)/sizeof(uint32_t) */
whismanoid 26:b89783422715 253 /* uint32_t code_limit_L */ 0x0000, // 0.0% of full scale
whismanoid 26:b89783422715 254 /* uint32_t code_limit_H */ 0xfffff, // 100.0% of full scale
whismanoid 26:b89783422715 255 /* float num_tone_cycles_in_table */ 11.0
whismanoid 26:b89783422715 256 );
whismanoid 26:b89783422715 257 #endif // USE_FunctionGenerator_Sine_Table
whismanoid 26:b89783422715 258 #endif // USE_FunctionGenerator
whismanoid 26:b89783422715 259
whismanoid 26:b89783422715 260 while (1)
whismanoid 26:b89783422715 261 {
whismanoid 26:b89783422715 262 // loop: put your main code here, to run repeatedly
whismanoid 26:b89783422715 263
whismanoid 26:b89783422715 264 // FUTURE: Function Generator for DAC output -- loop
whismanoid 26:b89783422715 265 #if USE_FunctionGenerator
whismanoid 26:b89783422715 266 //~ uint32_t code = 0xfffff; // 100.0% of full scale REF(4.096V) = 4.096V
whismanoid 26:b89783422715 267 //~ g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 268 //~ delay(1); // delay(unsigned long interval_msec)
whismanoid 26:b89783422715 269 //~ g_MAX5719_device.CODE_LOAD(0);
whismanoid 26:b89783422715 270 //~ delay(1); // delay(unsigned long interval_msec)
whismanoid 26:b89783422715 271 // DACStepFunctionGenerator
whismanoid 26:b89783422715 272 //~ g_MAX5719_device.CODE_LOAD(DACStepFunctionGenerator.code_limit_H);
whismanoid 26:b89783422715 273 //~ delay(1); // delay(unsigned long interval_msec)
whismanoid 26:b89783422715 274 //~ g_MAX5719_device.CODE_LOAD(DACStepFunctionGenerator.code_limit_L);
whismanoid 26:b89783422715 275 //~ delay(1); // delay(unsigned long interval_msec)
whismanoid 26:b89783422715 276 g_MAX5719_device.CODE_LOAD(DACStepFunctionGenerator.Next());
whismanoid 26:b89783422715 277 //~ delay(1); // delay(unsigned long interval_msec)
whismanoid 26:b89783422715 278 #else // USE_FunctionGenerator
whismanoid 26:b89783422715 279 uint32_t code;
whismanoid 26:b89783422715 280 //
whismanoid 26:b89783422715 281 // example #1
whismanoid 26:b89783422715 282 code = 0xfffff; // 100.0% of full scale REF(4.096V) = 4.096V
whismanoid 26:b89783422715 283 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 284 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 285 //
whismanoid 26:b89783422715 286 // example #2
whismanoid 26:b89783422715 287 code = 0xe6665; // 90.0% of full scale REF(4.096V) = 3.686V
whismanoid 26:b89783422715 288 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 289 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 290 //
whismanoid 26:b89783422715 291 // example #3
whismanoid 26:b89783422715 292 code = 0xccccc; // 80.0% of full scale REF(4.096V) = 3.277V
whismanoid 26:b89783422715 293 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 294 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 295 //
whismanoid 26:b89783422715 296 // example #4
whismanoid 26:b89783422715 297 code = 0xb3332; // 70.0% of full scale REF(4.096V) = 2.867V
whismanoid 26:b89783422715 298 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 299 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 300 //
whismanoid 26:b89783422715 301 // example #5
whismanoid 26:b89783422715 302 code = 0x99999; // 60.0% of full scale REF(4.096V) = 2.458V
whismanoid 26:b89783422715 303 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 304 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 305 //
whismanoid 26:b89783422715 306 // example #6
whismanoid 26:b89783422715 307 code = 0x7ffff; // 50.0% of full scale REF(4.096V) = 2.048V
whismanoid 26:b89783422715 308 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 309 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 310 //
whismanoid 26:b89783422715 311 // example #7
whismanoid 26:b89783422715 312 code = 0x66666; // 40.0% of full scale REF(4.096V) = 1.638V
whismanoid 26:b89783422715 313 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 314 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 315 //
whismanoid 26:b89783422715 316 // example #8
whismanoid 26:b89783422715 317 code = 0x4cccc; // 30.0% of full scale REF(4.096V) = 1.229V
whismanoid 26:b89783422715 318 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 319 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 320 //
whismanoid 26:b89783422715 321 // example #9
whismanoid 26:b89783422715 322 code = 0x33333; // 20.0% of full scale REF(4.096V) = 0.819V
whismanoid 26:b89783422715 323 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 324 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 325 //
whismanoid 26:b89783422715 326 // example #10
whismanoid 26:b89783422715 327 code = 0x19999; // 10.0% of full scale REF(4.096V) = 0.410V
whismanoid 26:b89783422715 328 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 329 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 330 //
whismanoid 26:b89783422715 331 // example #11
whismanoid 26:b89783422715 332 code = 0x0000; // 0.0% of full scale REF(4.096V) = 0.000V
whismanoid 26:b89783422715 333 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 334 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 335 //
whismanoid 26:b89783422715 336 // example #12
whismanoid 26:b89783422715 337 code = 0x0000; // 0.0% of full scale REF(4.096V) = 0.000V
whismanoid 26:b89783422715 338 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 339 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 340 //
whismanoid 26:b89783422715 341 // example #13
whismanoid 26:b89783422715 342 code = 0x19999; // 10.0% of full scale REF(4.096V) = 0.410V
whismanoid 26:b89783422715 343 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 344 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 345 //
whismanoid 26:b89783422715 346 // example #14
whismanoid 26:b89783422715 347 code = 0x33333; // 20.0% of full scale REF(4.096V) = 0.819V
whismanoid 26:b89783422715 348 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 349 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 350 //
whismanoid 26:b89783422715 351 // example #15
whismanoid 26:b89783422715 352 code = 0x4cccc; // 30.0% of full scale REF(4.096V) = 1.229V
whismanoid 26:b89783422715 353 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 354 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 355 //
whismanoid 26:b89783422715 356 // example #16
whismanoid 26:b89783422715 357 code = 0x66666; // 40.0% of full scale REF(4.096V) = 1.638V
whismanoid 26:b89783422715 358 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 359 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 360 //
whismanoid 26:b89783422715 361 // example #17
whismanoid 26:b89783422715 362 code = 0x7ffff; // 50.0% of full scale REF(4.096V) = 2.048V
whismanoid 26:b89783422715 363 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 364 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 365 //
whismanoid 26:b89783422715 366 // example #18
whismanoid 26:b89783422715 367 code = 0x99999; // 60.0% of full scale REF(4.096V) = 2.458V
whismanoid 26:b89783422715 368 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 369 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 370 //
whismanoid 26:b89783422715 371 // example #19
whismanoid 26:b89783422715 372 code = 0xb3332; // 70.0% of full scale REF(4.096V) = 2.867V
whismanoid 26:b89783422715 373 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 374 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 375 //
whismanoid 26:b89783422715 376 // example #20
whismanoid 26:b89783422715 377 code = 0xccccc; // 80.0% of full scale REF(4.096V) = 3.277V
whismanoid 26:b89783422715 378 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 379 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 380 //
whismanoid 26:b89783422715 381 // example #21
whismanoid 26:b89783422715 382 code = 0xe6665; // 90.0% of full scale REF(4.096V) = 3.686V
whismanoid 26:b89783422715 383 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 384 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 385 //
whismanoid 26:b89783422715 386 // example #22
whismanoid 26:b89783422715 387 code = 0xfffff; // 100.0% of full scale REF(4.096V) = 4.096V
whismanoid 26:b89783422715 388 g_MAX5719_device.CODE_LOAD(code);
whismanoid 26:b89783422715 389 wait_ms(3000); // wait_ms(unsigned long interval_msec)
whismanoid 26:b89783422715 390
whismanoid 26:b89783422715 391 // wait(3.0);
whismanoid 26:b89783422715 392 // FUTURE: Function Generator for DAC output -- loop end
whismanoid 26:b89783422715 393 #endif // USE_FunctionGenerator
whismanoid 26:b89783422715 394 }
whismanoid 26:b89783422715 395 }
whismanoid 26:b89783422715 396