Adding a DAC to the MSP432 Launchpad


3rd of March 2018
The code in this example has been updated. See here:

The MSP432 Launchpad features quite a powerful low energy processor (the MSP432P401R).  This should make it ideal for a little DSP but for one problem: there is no DAC.  I decided that I should remedy this by adding an SPI DAC in the form of a TLV5618A. This 12-bit IC has two DAC outputs and can be driven at a speed sufficient for some pretty decent audio.  Wiring is as shown below:


Code was developed in Energia – an experience that left me wondering about the completeness and documentation of the MSP432 port to this environment.


#define SS_PIN 17
void setup()
  // put your setup code here, to run once:
  pinMode(15,OUTPUT); // MOSI
  pinMode(7,OUTPUT); // SCK
  SPI.setBitOrder(MSBFIRST);   //
  SPI.setClockDivider(SPI_CLOCK_DIV2); // DIV2 = 8MHz, DIV4 = 4MHz, DIV8 = 2MHz etc. (from measurement)
void writeDACA(int Value)
  Value=Value & 0xfff;
  Value = Value | 0xc000; // Write DAC A
  SPI.transfer( (Value >> 8) & 0xff);
  SPI.transfer( Value  & 0xff);
int i=0;
void loop()
  // put your main code here, to run repeatedly:
    if (i > 0xfff)
      i = 0;


This produces the following output waveform:


This is a little noisy but more to the point : SLOW!  The pair of SPI writes are taking more than 70 microseconds which makes me wonder about the efficiency of the underlying libraries.  I hope to remedy this in a later post (Edit: you can read about this here:

5 thoughts on “Adding a DAC to the MSP432 Launchpad

  1. Abraham Munguia March 1, 2017 / 5:22 am

    Any chance to improve the performance yet? 🙂


    • fduignan March 1, 2017 / 7:01 am

      Did you read the follow up article “Speedier DACs with the MSP432 Launchpad”?


  2. Gopal May 9, 2017 / 5:16 am

    what does the SS_pin in the code also can you comment and explain the code for me??


    • fduignan May 9, 2017 / 8:19 am

      The SS_PIN is a “Slave Select” pin. You need to drive this low to signal the beginning of an SPI transaction. You bring it high when the transfer is complete. The setup function configures this pin as an output (along with a few others). It also sets up the USCI (USART) hardware to operate as an SPI Master with a clock speed of 8MHz.
      The DAC in question is a 12-bit one. The function writeDACA begins by zeroing any bits in the desired output value after bit 11 as the higher bits are for control purposes. It then sets the two MSB’s to indicate that it intends to write to DACA (see page 11 in The SPI transaction is then started by dropping the SS_PIN to logic 0. The most significant byte of the 16 bit output value is transferred first followed by the least significant byte. Finally the SS_Pin is raised to logic 1 to signal the end of the SPI transaction.
      The main simply calls on writeDACA to write out an sawtooth waveform with the DAC.
      A faster version of the code (with more comments) is available here:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s