This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to use the output gain on a MSP430F5336 DAC?

Other Parts Discussed in Thread: MSP430F5336

I am trying to use the output gain on a MSP430F5336 DAC and it isn't working.  With all the settings, I am only getting a 1x gain instead of the 2x and 3x gains advertised in the users guide.

On page 792 of the SLAU208K MSP430x5xx and MSP430x6xx Family Users Guide, it has the following (with formatting errors caused by the cut and paste):

30.2.1 DAC12_A Core
The DAC12_A can be configured to operate in 8-bit or 12-bit mode using the DAC12RES bit. The full-scale
output is programmable to be 1x, 2x, or 3x the selected reference voltage via the DAC12IR and
DAC12OG bits. This feature allows the user to control the dynamic range of the DAC. The DAC12DF bit
allows the user to select between straight binary data and 2's complement data for the DAC. When using
straight binary data format, the formula for the output voltage is given in Table 30-1.
Table 30-1. DAC Full-Scale Range (Vref = VeREF+ or VREF+)
Resolution DAC12RES DAC12OG DAC12IR Output Voltage Formula
12 bit 0 0 0 Vout = Vref × 3 × (DAC12_xDAT/4096)
12 bit 0 1 0 Vout = Vref × 2 x (DAC12_xDAT/4096)
12 bit 0 x 1 Vout = Vref × (DAC12_xDAT/4096)
8 bit 1 0 0 Vout = Vref × 3 × (DAC12_xDAT/256)
8 bit 1 1 0 Vout = Vref × 2 × (DAC12_xDAT/256)
8 bit 1 x 1 Vout = Vref × (DAC12_xDAT/256)
In 8-bit mode the maximum useable value for DAC12_xDAT is 0FFh and in 12-bit mode the maximum
useable value for DAC12_xDAT is 0FFFh.

As far as I understand it, I should be able to use the internal reference block and be able to bump it by 2x or 3x to get higher reference voltages.  I am wanting a 3.0 V reference and thought I could get it by setting the reference module to output 1.5V and use the 2nd entry in the table (DAC12RES=0; DAC12OG=1; DAC12IR=0) to double it to 3.0V.  I am only getting 1.5V out regardless of the gain settings (with maximum settings of 4095 for the DAC12_DAT register).

In my application, AVcc is 3.3V so there is plenty of headroom for the output to reach 3.0V.  I am using the 12 bit resolution setting.  I also have the DAC12SREFx set to 0 to select the VREF+ reference.

Am I misunderstanding the users guide?  Is there something else I need to do to get 3.0V out?

Thanks,

Brent

  • Hi Brent,

    Can you post your code?  Specifically how you are setting the DAC registers when you expect 2x and only get 1x.

    Jeff

  •   // turn on reference - set to 1.5V
      REFCTL0 = REFMSTR+REFON;


      DAC12_0DAT = 0;            // turn DAC output off
      DAC12_0CTL1 = DAC12DFJ+        // left justified
                                      DAC12OG;          // 2x gain
      DAC12_0CTL0 = DAC12AMP_5;        // med speed, med current; 1.5V ref
      DAC12_0CALCTL = DAC12PW;        // unlock for calibration
      DAC12_0CTL0 |= DAC12CALON;        // start calibration

      // wait for calibration to finish
      while (DAC12_0CTL0 & DAC12CALON);
      DAC12_0CALCTL = DAC12PW+DAC12LOCK;    // lock

    .......

    I then have a DMA set up using TB0 as the trigger to write to the DAC12_0DAT register.  I can show that code too, if you like, but I don't think it has any bearing on the issue here.

    I break the code using my debugger and manually write a 0xffff to the DAC12_0DAT register and measure the output.  That is where I get the 1.5 V reading (1.498V to be exact) and changing the OG and IR registers using the debugger does not affect the output any.  (I also see the same behavior letting the code run normally and this was an easier way to take the rest of the code out of the equation.)

    Brent

  • I was really hoping something would stick out in your code, but it looks great.  Plus I would have tried the exact experiments you did.

    Maybe write a standalone application with just these few statements in it.  Also eliminate the calibration.  Eliminate the left justification.  Eliminate anything unnecessary.

    Then use a breakpoint at the end to #1 verify register contents and #2 experiment as you have already done.  Especially watch out for the DAC12ENC bit (should be clear) and the DAC12DF bit (should be clear) and of course the DAC12IR bit (should be clear).

    Good luck.

    Jeff

  • Hi Jeff,

    I have tried all that already.  I have done the standalone code that did just the setup - no change.  I have also tried changing all the registers I could think of.  It appears that the data sheet is incorrect and you really can not get 2x references.

    One thing I did notice that in the block diagram of the DAC12 blocks, there is a divider after the mux for the reference before the reference voltage is fed into the DAC12_0 block.  The output is then multiplied back up.  I was wondering if the two canceled each other out.  The text in the users guide seemed to indicate that it did not but the results don't match the text.  I am believing at this point that the users guide is incorrect and the gain does not work.

    Brent

**Attention** This is a public forum