LPC802 ADC issue running sequence A & sequence B

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

LPC802 ADC issue running sequence A & sequence B

Jump to solution
721 Views
asier
Contributor III

Hi,

I have defined sequence A with adc channel 5 and channel 10 for working as single conversion mode without interrupt, and sequence B with channel 6 for working as burst conversion mode and compare interrupt. 

When I run sequence A alone it works fine but the problem is when I enable burst mode bit in sequence B. In that case, sequence A does not complet single conversion.

I post my code example next:

static void ADC_Configuration(void)
{
adc_config_t adcConfigStruct;
adc_conv_seq_config_t adcConvSeqConfigStruct;
adc_conv_seq_config_t adcConvSeqBConfigStruct;

// Sequence A.
adcConvSeqConfigStruct.channelMask =
((1U << DEMO_ADC_SAMPLE_CHANNEL_10_TEMP) | (1U << DEMO_ADC_SAMPLE_CHANNEL_5_VDD));
adcConvSeqConfigStruct.triggerMask = 0U;
adcConvSeqConfigStruct.triggerPolarity = kADC_TriggerPolarityPositiveEdge;
adcConvSeqConfigStruct.enableSingleStep = false;
adcConvSeqConfigStruct.enableSyncBypass = false;
adcConvSeqConfigStruct.interruptMode = kADC_InterruptForEachSequence;
ADC_SetConvSeqAConfig(DEMO_ADC_BASE, &adcConvSeqConfigStruct);
ADC_EnableConvSeqA(DEMO_ADC_BASE, true); // Enable the conversion sequence A.


// Sequence B.
adcConvSeqBConfigStruct.channelMask =
(1U << DEMO_ADC_SAMPLE_CHANNEL_6_INDUC);
adcConvSeqBConfigStruct.triggerMask = 0U;
adcConvSeqBConfigStruct.triggerPolarity = kADC_TriggerPolarityPositiveEdge;
adcConvSeqBConfigStruct.enableSingleStep = false;
adcConvSeqBConfigStruct.enableSyncBypass = false;
adcConvSeqBConfigStruct.interruptMode = kADC_InterruptForEachSequence;
ADC_SetConvSeqBConfig(DEMO_ADC_BASE, &adcConvSeqBConfigStruct);

// Initialize 0. pair of threshold setting
ADC_SetThresholdPair0(DEMO_ADC_BASE, 0U, 1241U);
// Assign threshold setting pairs to channels
//ADC_SetChannelWithThresholdPair0(DEMO_ADC_BASE, 64U);
ADC_SetChannelWithThresholdPair0(DEMO_ADC_BASE, (1U << DEMO_ADC_SAMPLE_CHANNEL_6_INDUC));
// Configure threshold compare interrupt on channel 6
ADC_EnableThresholdCompareInterrupt(DEMO_ADC_BASE, 6U, kADC_ThresholdInterruptOnOutside);
// Enable interrupt ADC0_THCMP_IRQn request in the NVIC
EnableIRQ(ADC0_THCMP_IRQn);

/* Clear the result register. */
ADC_DoSoftwareTriggerConvSeqA(DEMO_ADC_BASE);
while (!ADC_GetChannelConversionResult(DEMO_ADC_BASE, DEMO_ADC_SAMPLE_CHANNEL_10_TEMP, &adcResultInfoStruct[0]))  // CORRECT
{
}
ADC_GetConvSeqAGlobalConversionResult(DEMO_ADC_BASE, &adcResultInfoStruct[0]);

//Remark: Set the BURST and SEQU_ENA bits at the same time
DEMO_ADC_BASE->SEQ_CTRL[1] |= 0x88000000U; // Enables Seq B and starts burst

wait(500);
ADC_DoSoftwareTriggerConvSeqA(DEMO_ADC_BASE); 

while (!ADC_GetChannelConversionResult(DEMO_ADC_BASE, DEMO_ADC_SAMPLE_CHANNEL_10_TEMP, &adcResultInfoStruct[0]))  // FAIL !!!
{
}

}

Why sequence A conversion stops working after starting burst conversión of sequence B ? Aren't they independent ?

Thanks for helping,

Asier-

Labels (2)
0 Kudos
1 Solution
711 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Asier,

At the same time, you can enable either sequence_A or sequence_B, but not both. After the Sequence_A is completed, if you want to start sequence_B, you should disable sequence_A.

For the line DEMO_ADC_BASE->SEQ_CTRL[1] |= 0x88000000U; // Enables Seq B and starts burst,you start sequence_B and sequence_B is set up as burst mode, so the sequence_B will sample analog channel repeatedly. If you do not want to start sequence_B, you can write DEMO_ADC_BASE->SEQ_CTRL[1] |= 0x08000000U; instead of 0x88000000U

In conclusion, sequence_A and B are independent, but they can not work at the same time.

BR

XiangJun Rong

View solution in original post

1 Reply
712 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Asier,

At the same time, you can enable either sequence_A or sequence_B, but not both. After the Sequence_A is completed, if you want to start sequence_B, you should disable sequence_A.

For the line DEMO_ADC_BASE->SEQ_CTRL[1] |= 0x88000000U; // Enables Seq B and starts burst,you start sequence_B and sequence_B is set up as burst mode, so the sequence_B will sample analog channel repeatedly. If you do not want to start sequence_B, you can write DEMO_ADC_BASE->SEQ_CTRL[1] |= 0x08000000U; instead of 0x88000000U

In conclusion, sequence_A and B are independent, but they can not work at the same time.

BR

XiangJun Rong