Hi @xiangjun_rong,
Thank you for your reply. Sorry but i can't see any difference from your configuration and mine:
for (i=0;i<ADC_READS;i++)
{
/* Set conversion CMD configuration. */
LPADC_GetDefaultConvCommandConfig(&g_LpadcCommandConfigStruct);
g_LpadcCommandConfigStruct.channelNumber = i;
g_LpadcCommandConfigStruct.conversionResolutionMode = kLPADC_ConversionResolutionHigh;
if(i == (ADC_READS - 1))
g_LpadcCommandConfigStruct.chainedNextCommandNumber = 0;
else
g_LpadcCommandConfigStruct.chainedNextCommandNumber = i+2;
LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, i+1, &g_LpadcCommandConfigStruct);
}
with this loop, using ADC_READS 3, it is the same as your configuration:
i=0 configures command 1, which reads channel 0 with chainedNextCommandNumber = 2.
i=1 configures command 2, which reads channel 1 with chainedNextCommandNumber = 3.
i=2 configures command 3, which reads channel 2 with chainedNextCommandNumber = 0.
As i said in my question, using a number of channels <= 3 the dma transfer ends correctly. Using a number of channel grater than 4 (ADC_READS 4, ADC_READS 5 ... ADC_READS 15) the dma transfer never ends. For completeness i've also tried to add a fourth channel to your version:
/* Set conversion CMD configuration. */
//First command ID index 1 which can configue ONE ADC analog channel
LPADC_GetDefaultConvCommandConfig(&g_LpadcCommandConfigStruct);
g_LpadcCommandConfigStruct.channelNumber = ADC_CHANNEL;
//it can be 0,1,2,3,4..whatever you are samplg
g_LpadcCommandConfigStruct.conversionResolutionMode = kLPADC_ConversionResolutionHigh;
g_LpadcCommandConfigStruct.chainedNextCommandNumber = 2;
LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, 1, &g_LpadcCommandConfigStruct);
//second command ID index 2 which can configue another ADC analog channel
LPADC_GetDefaultConvCommandConfig(&g_LpadcCommandConfigStruct);
g_LpadcCommandConfigStruct.channelNumber = ANOTHER_ADC_CHANNEL;
//it can be 0,1,2,3,4..whatever you are sampling
g_LpadcCommandConfigStruct.conversionResolutionMode = kLPADC_ConversionResolutionHigh;
g_LpadcCommandConfigStruct.chainedNextCommandNumber = 3;
LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, 2, &g_LpadcCommandConfigStruct);
//third command ID index 3 which can configue another ADC analog channel
LPADC_GetDefaultConvCommandConfig(&g_LpadcCommandConfigStruct);
g_LpadcCommandConfigStruct.channelNumber = Another_ADC_CHANNEL;// it can be 0,1,2,3,4...
g_LpadcCommandConfigStruct.conversionResolutionMode = kLPADC_ConversionResolutionHigh;
g_LpadcCommandConfigStruct.chainedNextCommandNumber = 4;
LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, 3, &g_LpadcCommandConfigStruct);
//fourth command ID index 4 which can configue another ADC analog channel
LPADC_GetDefaultConvCommandConfig(&g_LpadcCommandConfigStruct);
g_LpadcCommandConfigStruct.channelNumber = Just_Another_ADC_CHANNEL;// it can be 0,1,2,3,4...
g_LpadcCommandConfigStruct.conversionResolutionMode = kLPADC_ConversionResolutionHigh;
g_LpadcCommandConfigStruct.chainedNextCommandNumber = 0;
// Rong:0 means last channel
LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, 4, &g_LpadcCommandConfigStruct);
And the result is the same as mine: main loop gets stuck in "while (false == g_DmaTransferDoneFlag)".