MSP430: SDA16? what would I ever use that for.

SDA16 is a 16Bit sigma-delta ADC, and is one of the options for MSP430 line of chips. But then you ask, doesn’t the mps430 have a ADC with 10 to 12 bits? Yes it does but the SDA is a different beast all together, with more settings and registers. For more information on how it works please feel free to read some application notes and the Wiki. I personally cant answer how or why you need to send your oversampled , comb filtered, decimated and modulated signal to get 16 Bit resolution.

application notes on SDADC
WIKI on how its done.

But lets get started by going over some of the Registers you will need to setup and or modify.

SD16CTL – control register
controls Clock source, power mode, clock divider, V ref selection, overflow interrupt.

SD16CCTL0 – channel register
Controls Buffer mode(no buffer in F2013), Bipolar or unipolar, conversion mode over
sampling and LSBACC enable, conversion interrupt, data format, interrupt flag and
conversion start

SD16INCTL0 – input control
Sampling rate, preamplifier gain, differential pair select

SD16AE – analog enable
Selects external Analog input

SD16IV – Interrupt vector – self explanatory

SD16MEM0 – conversion memory – where your conversion will end up when sda16 is finished with conversion.

** all these registers mentioned are reset with PUC

Yes I know it looks like a lot, but it really doesn’t take that much to start getting readings .
So the first thing you need to do is select your differential pair/ Pins you will be using. ** you will have to use the Data sheet to pick your Pairs, and remember if you are using an external VREF P1.3 will be used on the F2013 so that leaves open 7 other pairs to select from.

So the basic setup – This is the same as any other project, like turn off WDT+, then setup the pins, then the rest of the peripherals.

Basic SD16 setup – continuous read on pin, output toggles LED if VREF >.3v or 1/2 of internal ref or 1.2v.

SD16CTL = SD16REFON + SD16SSEL_1; // 1.2V ref, SMCLK
SD16INCTL0 = SD16INCH_1; // A1+/-
SD16CCTL0 = SD16UNI + SD16IE; // 256OSR, unipolar, interrupt enable
SD16AE = SD16AE2; // P1.2 A1+, A1- = VSS
SD16CCTL0 |= SD16SC; // Set bit to start conversion

this is taken from the TI SD16 code examples
Just add the ISR like so and you have a good start of something

#pragma vector = SD16_VECTOR
__interrupt void SD16ISR(void)
if (SD16MEM0 < 0x7FFF) // SD16MEM0 > 0.3V?, clears IFG
P1OUT &= ~0x01;
P1OUT |= 0x01;

***may not work for mspgcc***

msp430x20x3_sd16A_01Full code example from TI.

Now with Grace’s Point and click config tool, you would think that learning these registers are not necessary, but I think they are….what if you need to change a setting to the peripheral that grace had setup up, what if you need a new sampling rate after every conversion, or choose a different VREF. With Grace you lose this flexibility and should learn what registers modify what, so you can make the uC work for you.

So lets start with SD16CTL
options that you will need to set to get things working

SD16SSEL_x – this selects your clock source for SD16
0 MCLK – default

SD16REFON – selects if you are using the reference generator or an external VREF
Its either enabled or disabled – you will have to choose the what works best for you.

That’s all you really need to set to get that- so on to the next one

SD16CCTL0 – there’s not too many things to set here for basic setup
SD16UNI – this sets bipolar or unipolar mode, this affects your SD16 values – you will have to look at the user guide to figure out which mode is best for you.

SD16SNGL – this sets if its a single conversion or continuous conversion

SD16IE – enable interrupt – you need this if you use interrupts and not SW to poll
SD16SC — starts and stops conversion – any questions?

SD16INCTL0 – input control – where you select your gain and pins that you use
SD16INCH_x – 0 – 7 pins – your choice – don’t forget to look at the data sheet
SD16GAIN_x – pre amp gain 0-6 or 1x to 32x

SD16AE – turn on or off the differential pair or tie the (neg) to VSS

The rest of the registers you will use but don’t have to setup, but this will get you a basic understanding on how to use SD16 peripherals – remember TIs code examples can give you a great place to start coding from. —- next we will implement the SDA16 on my BPM counter for a proof of concept .

Until next time – thanks for reading
PS let me know if i need to correct or change anything

4 Responses to MSP430: SDA16? what would I ever use that for.

  1. Did you ever actually get this to work? I tried using a potentiometer where the tap was tied to A1+ (P1.2) and P1.3 to VSS.
    No matter what voltage was measured at P1.2, SD16MEM0 always gave a value of 0xFFFF.
    P.S. The sample code has an incorrect comment which confuses new user. The line
    SD16AE = SD16AE2; // P1.1 A1+, A1- = VSS
    should read
    SD16AE = SD16AE2; // P1.2 A1+, A1- = VSS

    • Yes i did get this to work, it took me a bit to figure out because i was having the same issue.
      The input voltage should be between -.6v to +.6v , try setting the input voltage at .3v or 300mV and you should get something different .(i have to edit this post to reflect my findings, i was confused for a good amount of time)..and yeah you are right about the comment, i must have missed that when testing it….thanks and it has been changed. by the way check out the last BPM counter post(should be the last post with the video), it has code that worked for me quite well for my application.

      If you are still having issues after that Post something over at forums with more info and ill help out the best i can.

      • Thanks, you saved my sanity.
        I had a basic misunderstanding of what reference voltage meant. I thought that internal ref of 1.2V meant 0 to 1.2V, now is see it means -0.6V to +0.6V. My potentiometer was set to 800mV which explains the 0xFFFF value. When I scaled back to 300mV it started working correctly.
        Having said all that, my system needs to work with an external reference of 3V and that still doesn’t work. I set A1- (P1.3) to 3V and turned SD16REFON off. Now I always get 0xFFFF even when A1+ is still at 300mV.
        I am putting together a much more user-friendly demo program which enables you to select the various options via macros. As soon as its ready I’ll send it to you, maybe it’ll help the next guy to figure out whats going on.

        • Thanks for the code, I will be updating this post with it and that same thing caught me for about a week as well.

          When using an external reference voltage, Max voltage should be 1.5 V according to the datasheet on MSP430F2013, which in my calculations for the FSR -.8V to +.8V (-+800mV)

          my suggestion for a work around would be, use a voltage divider for your 3V to get it to 1.5V and then match a another voltage divider for your input signal. ill keep digging around to see if i have any other ways to make that work