Maxim Integrated MAX5715 12-bit 4-channel voltage-output DAC
Dependents: MAX5715BOB_Tester MAX5715BOB_12bit_4ch_SPI_DAC MAX5715BOB_Serial_Tester
Diff: MAX5715.cpp
- Revision:
- 3:a3f0518094f4
- Parent:
- 0:777851395940
- Child:
- 4:500c80398f90
--- a/MAX5715.cpp Mon Jun 17 05:29:29 2019 +0000 +++ b/MAX5715.cpp Sun Aug 04 01:47:26 2019 -0700 @@ -154,6 +154,7 @@ //#define SPI_SCLK_Hz 48000000 // 48MHz //#define SPI_SCLK_Hz 24000000 // 24MHz //#define SPI_SCLK_Hz 12000000 // 12MHz + //#define SPI_SCLK_Hz 6000000 // 6MHz //#define SPI_SCLK_Hz 4000000 // 4MHz //#define SPI_SCLK_Hz 2000000 // 2MHz //#define SPI_SCLK_Hz 1000000 // 1MHz @@ -173,7 +174,7 @@ } // CODE GENERATOR: spi_frequency setter definition -// set SPI SCLK frequency +/// set SPI SCLK frequency void MAX5715::spi_frequency(int spi_sclk_Hz) { m_SPI_SCLK_Hz = spi_sclk_Hz; @@ -859,6 +860,9 @@ //---------------------------------------- // CMD_0100_0000_0000_dcba_0000_0000_POWERn_Normal +// CMD_0100_0001_0000_dcba_0000_0000_POWERn_PD1k +// CMD_0100_0010_0000_dcba_0000_0000_POWERn_PD100k +// CMD_0100_0011_0000_dcba_0000_0000_POWERn_PDHiZ // // Sets the power mode of the selected DACs // (DACs selected with a 1 in the corresponding DACn bit are updated, @@ -897,14 +901,14 @@ uint8_t command_regAddress = CMD_0100_0000_0000_dcba_0000_0000_POWERn_Normal; // diagnostic uint16_t regValue = ((channels_bitmask_DCBA & 0x0F) << 8); // 0000_dcba_0000_0000 // select command_regAddress from list of 4 values, based on condition - if (powerValue == POWERn_PD100k) { - command_regAddress = CMD_0100_0010_0000_dcba_0000_0000_POWERn_PD100k; + if (powerValue == POWERn_Normal) { + command_regAddress = CMD_0100_0000_0000_dcba_0000_0000_POWERn_Normal; } if (powerValue == POWERn_PD1k) { command_regAddress = CMD_0100_0001_0000_dcba_0000_0000_POWERn_PD1k; } - if (powerValue == POWERn_Normal) { - command_regAddress = CMD_0100_0000_0000_dcba_0000_0000_POWERn_Normal; + if (powerValue == POWERn_PD100k) { + command_regAddress = CMD_0100_0010_0000_dcba_0000_0000_POWERn_PD100k; } if (powerValue == POWERn_PDHiZ) { command_regAddress = CMD_0100_0011_0000_dcba_0000_0000_POWERn_PDHiZ; @@ -940,22 +944,26 @@ uint8_t command_regAddress = CMD_0111_0110_0000_0000_0000_0000_REF_AlwaysOn_2V048; // diagnostic uint16_t regValue = 0; // 0000_0000_0000_0000 // select command_regAddress from list of 8 values, based on condition + if (value == REF_EXT) { + command_regAddress = CMD_0111_0000_0000_0000_0000_0000_REF_EXT; + } + if (value == REF_2V500) { + command_regAddress = CMD_0111_0001_0000_0000_0000_0000_REF_2V500; + VRef = 2.500; + } + if (value == REF_2V048) { + command_regAddress = CMD_0111_0010_0000_0000_0000_0000_REF_2V048; + VRef = 2.048; + } if (value == REF_4V096) { command_regAddress = CMD_0111_0011_0000_0000_0000_0000_REF_4V096; VRef = 4.096; } - if (value == REF_AlwaysOn_2V500) { - command_regAddress = CMD_0111_0101_0000_0000_0000_0000_REF_AlwaysOn_2V500; - VRef = 2.500; - } - if (value == REF_EXT) { - command_regAddress = CMD_0111_0000_0000_0000_0000_0000_REF_EXT; - } if (value == REF_AlwaysOn_EXT) { command_regAddress = CMD_0111_0100_0000_0000_0000_0000_REF_AlwaysOn_EXT; } - if (value == REF_2V500) { - command_regAddress = CMD_0111_0001_0000_0000_0000_0000_REF_2V500; + if (value == REF_AlwaysOn_2V500) { + command_regAddress = CMD_0111_0101_0000_0000_0000_0000_REF_AlwaysOn_2V500; VRef = 2.500; } if (value == REF_AlwaysOn_2V048) { @@ -966,10 +974,6 @@ command_regAddress = CMD_0111_0111_0000_0000_0000_0000_REF_AlwaysOn_4V096; VRef = 4.096; } - if (value == REF_2V048) { - command_regAddress = CMD_0111_0010_0000_0000_0000_0000_REF_2V048; - VRef = 2.048; - } //---------------------------------------- // SPI write 8-bit regAddress and 16-bit regValue