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.

MSP430F5132: MSP430F5132

Part Number: MSP430F5132

Hi ,
We are using MSP430F5132 and PMP7647 source code.

In PMP7647 sources ..ADC configuration as below:

P1.0 -- Analog input A0 – 10-bit ADC(3)  -- Panel Voltage
P1.1 -- Analog input A1 – 10-bit ADC(3)  --  Battery Voltage
P1.2 -- Analog input A2 – 10-bit ADC(3)  -- Battery Current
P1.3 --Analog input A3 – 10-bit ADC(3)  --  Load voltage
P1.4 -- Analog input A4 – 10-bit ADC(3)  -- Load Current

//ADC INITIALISATION//
void init_ADC (void)
{
ADC10CTL0 = ADC10SHT_2 + ADC10MSC + ADC10ON; // 8clk cycles, Single trigger, conversion disabled
ADC10CTL1 = ADC10SHP + ADC10CONSEQ_1;     // Sampling timer, Sequence of channels
ADC10CTL2 |= ADC10RES;                     // 10-bit conversion results
ADC10MCTL0 = ADC10INCH_4 + ADC10SREF_1; // A4,A3,A2,A1,A0(EoS), Vref+ = Vref, Vref- = gnd

REFCTL0 |= REFVSEL_2+REFON;               // Select internal ref = 2.5V
//CONFIGURE DMA
DMACTL0 = DMA0TSEL_24;                     // ADC10IFG trigger

__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &ADC10MEM0);
// Source single address
__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &ADC_Readings[0]);
// Destination array address

DMA0SZ = 0x05;                             // 5 WORDS(Conversion Results) transferred
DMA0CTL = DMADT_4 + DMADSTINCR_3 + DMAEN + DMAIE; // Source unchanged, Destination increments, enabled, interrupts enabled
}

ADC sampling and conversion in WDT interrupt

//WDT to restart ADC
void init_WDT (void)
{

WDTCTL = WDT_MDLY_32;                     // WDT 32ms from 1MHz, SMCLK, interval timer
SFRIE1 |= WDTIE;                           // Enable WDT interrupt
}

// Watchdog Timer interrupt service routine
#pragma vector=WDT_VECTOR
__interrupt void WDT_ISR(void)
{

__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &ADC_Readings[0]);
ADC10CTL0 |= ADC10ENC + ADC10SC;         // Sampling and conversion start
}

Now in present design , we have slightly changed ADC channel allocation

P1.0 -- Analog input A0 – 10-bit ADC(3)  -- Panel Voltage
P1.1 -- Analog input A1 – 10-bit ADC(3)  --  Battery Voltage
P1.2 -- Analog input A2 – 10-bit ADC(3)  -- Battery Current
P1.3 --Analog input A3 – 10-bit ADC(3)  --  Load voltage
P1.4 -- SDA for I2C  
P3.6 -- Analog input A7 – 10-bit ADC(3)  -- Load current

it is not possible to configure  multi channel conversion. Can you suggest ADC configuration

  • Hi Yogesh Sutar

    Please refer to MSP430x5xx and MSP430x6xx Family User's Guide (Rev. Q)

    May I know the multi channel conversion is Sequence-of-channels (autoscan) or Repeat-sequence-of-channels (repeated autoscan)

    Thanks!

  • Hi Xiaodong Li,

    It is Repeat-sequence-of-channels (repeated autoscan) ...

    We want to convert values using A0,A1,A2,A3 and A6... these channel are not in sequence so  we need some suggestions here

  • Hi Yogesh Sutar

    Please find the code example MSP430F51x2_adc10_14.c on https://dev.ti.com/tirex/explore/node?node=A__AE9eFMaqVmXndZ9X1mezcg__msp430ware__IOGqZri__LATEST

    >> We want to convert values using A0,A1,A2,A3 and A6... these channel are not in sequence

    Repeat-sequence-of-channels doesn't support the channels not in sequence. Please refer to ADC10INCHx.ADC10MCTL0 resgiter description

    Thanks


  • Tnanks for the update. Below configuration works for A0,A1 and A7 conversion?


    // Configure ADC10; pulse sample mode, s/w trigger, rpt seq of channels
    ADC10CTL0 = ADC10SHT_2 + ADC10MSC + ADC10ON; // 16ADCclks, ADC on
    ADC10CTL1 = ADC10SHP + ADC10CONSEQ_3; // Sampling timer, rpt seq of ch
    ADC10CTL2 = ADC10RES; // 10-bit resolution

    ADC10MCTL0 = ADC10INCH_7; //A7

    ADC10MCTL0 |= ADC10INCH_1; // AVCC ref, A0, A1(EOS)

    // Configure DMA0 (ADC10IFG trigger)
    DMACTL0 = DMA0TSEL_24; // ADC10IFG trigger
    __data20_write_long((uintptr_t) &DMA0SA,(uintptr_t) &ADC10MEM0);
    // Source single address
    DMA0SZ = 0x03; // 2x32 conversions
    DMA0CTL = DMADT_4 + DMADSTINCR_3 + DMAEN + DMAIE;
    // Rpt, inc dest, byte access,
    // enable int after seq of convs

  • The ADC10 (with CONSEQ=1 or =3) always counts down from ADC10INCH to A0 [Ref User Guide (SLAU208Q) Sec 27.2.7.4]. If your channel range is not consecutive, you will sample some channels you aren't interested in, and just ignore the results. Generally, the tiny sip of current that the ADC draws during sample/hold won't be noticed by any digital pins it runs across.

    In your case, you will be sampling 8 channels (A7->A0), so DMA0SZ needs to be =8.

  • Hi Bruce,

    Thanks for the update. 

    P1.0 -- Analog input A0 – 10-bit ADC(3)  -- Panel Voltage
    P1.1 -- Analog input A1 – 10-bit ADC(3)  --  Battery Voltage
    P1.2 -- Analog input A2 – 10-bit ADC(3)  -- Battery Current
    P1.3 --Analog input A3 – 10-bit ADC(3)  --  Load voltage
    P1.4 -- SDA for I2C  
    P3.6 -- Analog input A7 – 10-bit ADC(3)  -- Load current

    other ADC channels used for other purpose like I2C ..can you suggest ADC configuration for above channel list ?

  • My expectation is that having the ADC sample P1.4 will not cause trouble for the I2C, since any disturbance will be very small and very short. [I haven't tried this with an I2C pin in particular, so test it first.] The alternative is to use CONSEQ=0 and sample the channels individually, which is more work.

    More generally: I think you don't want CONSEQ=3 (with MSC=1) since the DMA ISR won't have time to fetch the previous measurements before the next set starts. I suggest you go back to your original code (with CONSEQ=1) and just use ADC10INCH_7 (instead of ADC10INCH_4) and set DMA0SZ=8. In the DMA ISR, pick out array elements [0,4,5,6,7]. You should also set the port mapping for P3.6 to PM_ANALOG, the same way you're currently doing it for P1.0-P1.3.

    [Edit: Fixed channel array ordering.]

**Attention** This is a public forum