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.

MSP-EXP432P401R: How Analog Channels Map to Pins in MSP432 launchpad

Part Number: MSP-EXP432P401R

I am using an MSP432 launchpad to control and read from a linear CCD, then send the values over a serial USB connection. I found this code on the forum at https://e2e.ti.com/support/microcontrollers/msp430/f/166/t/531322#pi316701=3

and modified it to focus on my needs and questions.

//Clock_Signal is a 100 kHz external clock that is read by a digital I/O pin
uint16_ Data[2048];
P9SEL1 |= BIT1;
P9SEL0 |= BIT1;  // Set pin 9.0 to tertiary module function (analog input?)

ADC14CTL0 &= ~ADC14ENC;  // Turn off enable to modify bits. 

ADC14CTL0 |= ADC14ON | ADC14SHP | ADC14CONSEQ_2 | ADC14MSC  | ADC14SHT04;  // Turn on ADC14, set sample and hold, repeat single channel, convert continuously, and sample-and-hold for 64 clocks
ADC14CTL1 |= ADC14RES__14BIT;   // Set resolution to 14-bits
ADC14MCTL0 |= ADC14VRSEL_0 | ADC14INCH_14; // A0 ADC input select; Vref=AVCC=3.3V

ADC14CTL0 |= ADC14ENC | ADC14SC; // Enable ADC14 and start first conversion

// Read one value during each up cycle of the clock until 2048 values are read
for(int i=0; i<2048; i++){
    while(Clock_Signal=0);  // Wait until the up cycle of the clock begins (100kHz)
    Data[i] = ADC14MEM0;  // Store the most recent conversion result
    while(Clock_Signal=1);  // Wait until the end of this clock's up cycle
}

// Or alternatively, attach an interrupt to the Clock_Signal rising edge
void Clock_Signal_ISR(){
    if (index < 2048){  // index will be reset to 0 when a new scan begins
        Data[index] = ADC14MEM0;  // Store the most recent conversion result
        index += 1;
    }
}
What are the primary, secondary, and tertiary module functions? Is the tertiary module function an analog input? Have I properly configured P9.0 to be an analog input?
Is setting ADC14MSC all I need to set the ADC14 into free-running mode (continuously converting)? Does this mode reduce the life of the ADC14, or have any other drawbacks besides more power consumption?
Can the ADC14 be triggered to start a conversion based on an external signal? I am only running it continuously because it looked like the only options were triggering off of internal counters or through software. In that case, continuous conversions seem like a more fail-safe approach.
How do I set the input in register ACD14MCTL0 to be pin P9.0 on the launchpad? How does this pin correlate to A0, A1, etc.? I couldn't find anything in the technical reference.
What is the advantage to sampling and holding for more clock cycles? Specifically, does the time-constant of the sample-and-hold circuit change to match the sample time, or do the gains of sampling longer diminish due to a fixed fast time-constant?
The interrupt service routine seems cleaner and more best-practice, but I've had trouble using interrupts together with Serial USB communication before. This trouble was on an Arduino DUE, and I don't know if the same problems apply here. If my clock signal is continuous, it will be triggering interrupts during any serial transmissions, which caused the problem before. Would I need to detach this interrupt before I send Serial (then re-attach it later)?
Thanks to anyone for your input!
  • if youre using a launchpad, it's a 100-pin QFP so p9.0 is ADC Channel 17; pin 52 of the device.

    See SLAS86 Figure 4-1.

  • Lynnelle,

      A lot of questions! Let me try to answer them in order:

    Slight typo in the above post. The latest MSP432P401R datasheet is SLAS826G. (follow the link). Table 4.1 shows the mapping of pins to functions (including the mapping of the Ax (x=0-23) analog inputs. If you search from that point for P9.0, you will find that yes, P9.0 tertiary function is an analog input for that port (A17 in this case). 

    For the rest of the Pin Functions, you'll need to look at the tables in section 6.12 (Input/Output Diagrams). For example, Table 6-62 shows the functions for P1.0-P1.7 based on the settings of the P1SEL0/1 bits. 

    For the rest of the questions, I'd suggest you start by going to TI Resource Explorer and trying the MSP432P401R driverlib examples there. That should get you started.

    Regards,

      Bob

  • To set the function for P9.0, you should set "P9SELx |= BIT0", not BIT1.

    I'm supposing(?) the clock signal is the CCD input multiplexor clock.

    The sampling time is driven primarily by the output impedance of the CCD multiplexor -- a lower impedance allows a lower sampling time. (See also SLAU356G Fig. 20-5, and the formula below it.) Your CCD data sheet should have this somewhere. My guess is that it's fairly low since CCDs are usually closely coupled with the host; 64 clocks seems a bit high.

    As far as I know the ADC14 can't be triggered directly from an external source. At 100ksps you have a fairly tight budget (particularly if you have other interrupts going off), so I see why you've chosen to do continuous conversions. However, I'm pretty sure you will get poor results since the sampling isn't synchronized with the CCD clock -- if the multiplexor switches during a sample you'll get a "mush" of two pixels.

    One thing I haven't seen tried (I haven't been watching closely), but it seems like it would work: Connect the CCD clock to the (e.g.) TA2CLK input pin (TASSEL=0) then set TA2CCR2=1 (and TA2CCR0=1) and SHS=6 (TA2_C2 according to SLAS826G Table 6-51) so the timer (thence the ADC) triggers on every TA2CLK input pulse. The effect should be something like a pass-through of the clock.
  • Looking more closely, that timer trick doesn't work -- the best it can do is divide the clock by 2.

    There is a solution by driving your CCD clock into DMAE0: Use the DMA to copy a pre-set word (including ADC14SC) into ADC14CTL0.
  • Thank you very much.

**Attention** This is a public forum