ADC burst mode with multiple channels

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC burst mode with multiple channels

1,096 Views
Fan_xy
Contributor III

Hello,

LPCXpresso54114 board,  MCUXpresso IDE , SDK.

I create a ADC burst project , use two channels , CH0 and CH1, CH0 use the temperature sensor,

interrupt for each conversion mode.

Print the result by UART, while I find that, it doesn't convert in sequence like CH0, CH1, CH0,CH1....

please see my screenshot :

pastedImage_1.png

I don't know where is the problem,  I also attached my project.

Thanks in advance.

Tags (1)
0 Kudos
2 Replies

872 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi fan xy,

    From my own opinion, I think this problem may relate to the printf code in the interrupt:

void ADC_1_IRQHANDLER()
{

      if (kADC_ConvSeqAInterruptFlag == (kADC_ConvSeqAInterruptFlag & ADC_GetStatusFlags(ADC_1_PERIPHERAL)))
         {
             /* Stop the burst mode and pause the conversion. */
            // ADC_EnableConvSeqABurstMode(DEMO_ADC_BASE, false);

            // ADC_GetChannelConversionResult(ADC_1_PERIPHERAL, 0, gAdcResultInfoPtr);
             ADC_GetConvSeqAGlobalConversionResult(ADC_1_PERIPHERAL, gAdcResultInfoPtr);
            // ADC_ClearStatusFlags(ADC_1_PERIPHERAL, kADC_ConvSeqAInterruptFlag);
             gAdcConvSeqAIntFlag = true;


            PRINTF("gAdcResultInfoStruct.result        = %d\r\n", gAdcResultInfoStruct.result);
                  PRINTF("gAdcResultInfoStruct.channelNumber = %d\r\n", gAdcResultInfoStruct.channelNumber);
                 //  ADC_Init(ADC_1_PERIPHERAL, &ADC_1configStruct);
                   PRINTF("cnt = %d\r\n", cnt);
                    /* PRINTF("gAdcResultInfoStruct.overrunFlag   = %d\r\n", gAdcResultInfoStruct.overrunFlag ? 1U : 0U); */
                //    PRINTF("\r\n");
         }
     /* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
       exception return operation might vector to incorrect interrupt */
     #if defined __CORTEX_M && (__CORTEX_M == 4U)
         __DSB();
     #endif
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

  As you know, the PRINTF will consume lot of time, if in the printf code, another ADC channel already finished the ADC conversion, but this time ADC interrupt still not exit, then you will lost one Channel ADC interrupt. So, you must make sure your ADC interrupt code time smaller than the two ADC conversion time, then the test will be correct.

   So, you can try to save the channel number and the result in the variable list, then printf it together in the main code,  or you also can extend the ADC conversion time.

Wish it helps you!

If you still have question about it, please kindly let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

872 Views
Fan_xy
Contributor III

Hello Kerry,

Thanks for your help.

I have delete the PRINTF , save the channel number to a variable cnt2[], the same problme:

pastedImage_1.png

BTW, what's the time between two channels?

0 Kudos