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.

MSP432P401R: MSP432P401R: MSP432 ADC14 Multiple Channel only converts the first value in the sequence, I don't see the next memory interrupt

Part Number: MSP432P401R

Hi,

  I configure a multi channel thread but only the 1st memory space triggers.

  I am using the lauchpad as a debug platform (real hardware will have different gpio pins and channels),

   I tied p6.1 and p4.0 to 5v and 0v on the launcpad, to generate a pattern

  if I set ADC_INT1 as the interrupt on init and in the handler, I see the value, any other interrupt, I do not see the interrupt,

   which makes me think the "multi" function isn't going past the first memory.

Any help?

code is below:

uint32_t g_adc_mem_first;

uint32_t g_adc_mem_last;

#define ADC_MULTI_MAX 16

uint16_t g_ADCResult_multi[ADC_MULTI_MAX];

int g_adc_mem[8]  = {ADC_MEM1,ADC_MEM2,ADC_MEM3,ADC_MEM4,

                     ADC_MEM5,ADC_MEM6,ADC_MEM7,ADC_MEM8};

static volatile bool a2d_multi_f = 0;

int config_multi_ll(int mcnt, int *achanp, int *memp)

{

    int status = 0;

    int predivider;        // simplifies changes across conditional compilation

    int postdivider;

    int ii;

    unsigned int sh_param;





    predivider = ADC_PREDIVIDER_1;  // MCLK may be too fast (was _1) 1,4,32,64

    postdivider = ADC_DIVIDER_8;  // _1.. _8



    MAP_REF_A_setReferenceVoltage(REF_A_VREF2_5V);  // initial: REF_A_VREF2_5V, alternate: REF_A_VREF1_2V

    MAP_REF_A_enableReferenceVoltage();

    MAP_REF_A_disableTempSensor();



    MAP_ADC14_enableModule();



    MAP_ADC14_disableConversion();              /* don't know if a2d was active prior to this call */



                                              /* ADC_NOROUTE = map to external pin */

    MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, predivider, postdivider,ADC_NOROUTE);



     /* Configuring ADC Memory */



    if (mcnt > ADC_MULTI_MAX)  // more than declared array

    {

        mcnt = ADC_MULTI_MAX;

        status = -1;

        sprintf(g_info,"config multi: memory count too big, %d, max=%d.\r\n",mcnt,ADC_MULTI_MAX);

        putUsart(g_info);

    }

    for (ii = 0; ii < mcnt; ii++)

    {

        MAP_ADC14_configureConversionMemory(memp[ii],

                                            ADC_VREFPOS_AVCC_VREFNEG_VSS,

                                            achanp[ii],

                                            ADC_NONDIFFERENTIAL_INPUTS);

    }



    ii = ii -1; // point to last

    g_adc_mem_first = memp[0];

    g_adc_mem_last = memp[ii];



    // MEM0 reserved for single shot ADC

    if ((g_adc_mem_first > g_adc_mem_last) || (g_adc_mem_first < ADC_MEM1) || (g_adc_mem_last > ADC_MEM31) )

    {

       status = -2;

       sprintf(g_info,"config multi: memory first, last error, first=%d, last=%d.\r\n",

               g_adc_mem_first,g_adc_mem_last);

       putUsart(g_info);

    }

    if (status == 0)

    {

      MAP_ADC14_configureMultiSequenceMode(g_adc_mem_first, g_adc_mem_last, true);



      MAP_ADC14_enableInterrupt(ADC_INT1);         /* Enabling interrupts */

      MAP_Interrupt_enableInterrupt(INT_ADC14);

      MAP_Interrupt_enableMaster();



      a2d_multi_f = false;              // global, see ADC14_IRQHandler()



      sh_param = ADC_PULSE_WIDTH_192;  // range _8 .. _192



      MAP_ADC14_setSampleHoldTime(sh_param,sh_param);

                                                         /* Configuring Sample Timer */

      MAP_ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);

                                                         /* Enabling/Toggling Conversion */

      MAP_ADC14_enableConversion();



      MAP_ADC14_toggleConversionTrigger();

    }

    return status;

} // end config_multi_ll



int a2d_config_multi(void)

{

   int status = 0;

   int channel[8] = {ADC_INPUT_A7,ADC_INPUT_A6,ADC_INPUT_A5,ADC_INPUT_A4,

                     ADC_INPUT_A3,ADC_INPUT_A2,ADC_INPUT_A1,ADC_INPUT_A0};



   int debug_f = 1;



   int pattern = 1;





   if (debug_f)

   {

     switch (pattern)

     {

       case 1:

         channel[0] = ADC_INPUT_A14;   // 5v, as jumpered for testing

         channel[1] = ADC_INPUT_A13;   // 0v



         channel[2] = ADC_INPUT_A14;

         channel[3] = ADC_INPUT_A13;



         channel[4] = ADC_INPUT_A14;

         channel[5] = ADC_INPUT_A13;



         channel[6] = ADC_INPUT_A14;

         channel[7] = ADC_INPUT_A13;

         break;



       case 2:

       default:

           channel[1] = ADC_INPUT_A14;   // 5v

           channel[0] = ADC_INPUT_A13;   // 0v



           channel[3] = ADC_INPUT_A14;

           channel[2] = ADC_INPUT_A13;



           channel[5] = ADC_INPUT_A14;

           channel[4] = ADC_INPUT_A13;



           channel[7] = ADC_INPUT_A14;

           channel[6] = ADC_INPUT_A13;

           break;

     }

     MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6, GPIO_PIN1, GPIO_TERTIARY_MODULE_FUNCTION); // A14

     MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4, GPIO_PIN0, GPIO_TERTIARY_MODULE_FUNCTION); // A13



     status = config_multi_ll(8, channel, g_adc_mem);

   }

   else  // not debug

   {

     MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4, GPIO_PIN6,GPIO_TERTIARY_MODULE_FUNCTION); // 1

     MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4, GPIO_PIN7,GPIO_TERTIARY_MODULE_FUNCTION); // 2

     MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN0,GPIO_TERTIARY_MODULE_FUNCTION); // 3

     MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN1,GPIO_TERTIARY_MODULE_FUNCTION); // 4

     MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN2,GPIO_TERTIARY_MODULE_FUNCTION); // 5

     MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN3,GPIO_TERTIARY_MODULE_FUNCTION); // 6

     MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN4,GPIO_TERTIARY_MODULE_FUNCTION); // 7

     MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN5,GPIO_TERTIARY_MODULE_FUNCTION); // 8

   }



   status = config_multi_ll(8, channel, g_adc_mem);

   return status;

} // a2d_config_multi



int a2d_get_multi(int mcnt, uint16_t *adc_valp)

{

  int status = 0;





  if (!a2d_multi_f)

  {

      status = -1;                 // never triggered

      sprintf(g_info,"The A/D never triggered.\r\n");

      putUsart(g_info);         // output to known path

  }

  else

  {

     if (mcnt > ADC_MULTI_MAX)

     {

         mcnt = ADC_MULTI_MAX;

         status = -2;

     }

     MAP_ADC14_getResultArray(g_adc_mem_first, g_adc_mem_last, adc_valp);

  }

int a2d_print_multi(void)

{

    int status = 0;

    int ii;

    char *namesp[8] = {"PIM_REG_TEMP_2","PIM_3.3VAUX_CUR","PIM_VBAT_MON", "PIM_5V_CUR",

                       "PIM_5PV0_MON",  "PIM_3P3V_CUR",   "PIM_3P3V_MON", "PIM_REG_TEMP_1"};



    status = a2d_get_multi(8, g_ADCResult_multi);



    if (status ==0)

    {

      for(ii=0; ii < 8; ii++)

      {

          sprintf(g_info,"Reading ADC Register: %s, raw adc=0x%x\r\n",

                  namesp[ii], g_ADCResult_multi[ii]);

           putUsart(g_info);

      }

    }



  return status;

} // end a2d_print_multi

  return status;

} // end a2d_get_multi

void ADC14_IRQHandler(void)

{

    uint64_t status = MAP_ADC14_getEnabledInterruptStatus();

    MAP_ADC14_clearInterruptFlag(status);



    if (ADC_INT0 & status)

    {

     g_ADCResult_ss = MAP_ADC14_getResult(ADC_MEM0);

        a2d_ss_f = true;      // polled

    }

    else

    {

        if (ADC_INT1 & status)

        {

            a2d_multi_f = true;

        }

    }

} /* end ADC14_IRQHandler */