ADC Sequencing in LPC546xx

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

ADC Sequencing in LPC546xx

1,037 Views
prasannanaik
Contributor III

Hi,

   I want to use LPC54605J256BD100 microcontroller in an applicaion where a pulseon an external pin will trigger an ADC and ADC should sample 12 channels on that single pulse input and give output at the end of the sampling of all the 12 channels. 

   I was going through the user manual of LPC546xx but couldn't find appropriate description for the required functionality. I have follwoing queries regarding Sequencing feature of ADC in LPC546xx:

1) In busrt mode,

            a) Conversion will start after trigger only right?

            b) After one sequence(i.e 12 channels sampled), does it stop sampling or initiates a new conversion sequence without any trigger?

 2) What is the use of start bit in SEQA_CTRL register?

 3) How to acheive the required functionality for my application?

 4) Any example code would be helpful

Thanks in advance,

Prasanna

Labels (1)
0 Kudos
9 Replies

874 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,  Prasanna,

Regarding your question, pls refer to the following:

Q1) In busrt mode,

            a) Conversion will start after trigger only right?

            b) After one sequence(i.e 12 channels sampled), does it stop sampling or initiates a new conversion sequence

without any trigger?

>>>>>Burst mode means that the ADC will convert continuously once the ADC is triggered, it do not stop sampling when all 12 channels are sampled. For your application, DO NOT use burst mode.

Q 2) What is the use of start bit in SEQA_CTRL register?

>>>>>>The Start bit in SEQA_CTRL register is just used in Software Trigger mode, whne the bit is set by software, ADC convert will be triggered once.

 Q3) How to acheive the required functionality for my application?

>>>>>>>Your application requires that the ADC converter is triggered by external signal from GPIO pins, once ADC is triggered, the ADC will sample all 12 channels, then stop sampling, wait for next external trigger signal. I suggest you use the example code in the LPC SDK package:

In the case, I think you can modify the void ADC_Configuration(void), change it from software triggering mode to pin hardware triggering mode.

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

/* Configure the converter. */
#if defined(FSL_FEATURE_ADC_HAS_CTRL_ASYNMODE) & FSL_FEATURE_ADC_HAS_CTRL_ASYNMODE
    adcConfigStruct.clockMode = kADC_ClockSynchronousMode; /* Using sync clock source. */
#endif                                                     /* FSL_FEATURE_ADC_HAS_CTRL_ASYNMODE */
    adcConfigStruct.clockDividerNumber = DEMO_ADC_CLOCK_DIVIDER;
#if defined(FSL_FEATURE_ADC_HAS_CTRL_RESOL) & FSL_FEATURE_ADC_HAS_CTRL_RESOL
    adcConfigStruct.resolution = kADC_Resolution12bit;
#endif /* FSL_FEATURE_ADC_HAS_CTRL_RESOL */
#if defined(FSL_FEATURE_ADC_HAS_CTRL_BYPASSCAL) & FSL_FEATURE_ADC_HAS_CTRL_BYPASSCAL
    adcConfigStruct.enableBypassCalibration = false;
#endif /* FSL_FEATURE_ADC_HAS_CTRL_BYPASSCAL */
#if defined(FSL_FEATURE_ADC_HAS_CTRL_TSAMP) & FSL_FEATURE_ADC_HAS_CTRL_TSAMP
    adcConfigStruct.sampleTimeNumber = 0U;
#endif /* FSL_FEATURE_ADC_HAS_CTRL_TSAMP */
#if defined(FSL_FEATURE_ADC_HAS_CTRL_LPWRMODE) & FSL_FEATURE_ADC_HAS_CTRL_LPWRMODE
    adcConfigStruct.enableLowPowerMode = false;
#endif /* FSL_FEATURE_ADC_HAS_CTRL_LPWRMODE */
#if defined(FSL_FEATURE_ADC_HAS_TRIM_REG) & FSL_FEATURE_ADC_HAS_TRIM_REG
    adcConfigStruct.voltageRange = kADC_HighVoltageRange;
#endif /* FSL_FEATURE_ADC_HAS_TRIM_REG */
    ADC_Init(DEMO_ADC_BASE, &adcConfigStruct);

#if !(defined(FSL_FEATURE_ADC_HAS_NO_INSEL) && FSL_FEATURE_ADC_HAS_NO_INSEL)
    /* Use the temperature sensor input to channel 0. */
    ADC_EnableTemperatureSensor(DEMO_ADC_BASE, true);
#endif /* FSL_FEATURE_ADC_HAS_NO_INSEL. */

    /* Enable channel DEMO_ADC_SAMPLE_CHANNEL_NUMBER's conversion in Sequence A. */
    adcConvSeqConfigStruct.channelMask =
        (0xFFFU << DEMO_ADC_SAMPLE_CHANNEL_NUMBER); /* Includes channel DEMO_ADC_SAMPLE_CHANNEL_NUMBER. Rong modified*/
    adcConvSeqConfigStruct.triggerMask = 1U; //select PIN INT0 as trigger source Rong Wrote
    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. */
    /* Clear the result register. */
    ADC_DoSoftwareTriggerConvSeqA(DEMO_ADC_BASE);
    while (!ADC_GetChannelConversionResult(DEMO_ADC_BASE, DEMO_ADC_SAMPLE_CHANNEL_NUMBER, &gAdcResultInfoStruct))
    {
    }
    ADC_GetConvSeqAGlobalConversionResult(DEMO_ADC_BASE, &gAdcResultInfoStruct);
}

You also need to write the PINTSEL[0] regisyter to select the GPIO pin which can trigger ADC, even you have to configure the pin feature in the IOCON module for the pin.

 Q4) Any example code would be helpful

>>>>>>>>>>>Pls use the ADC example in the SDK package.

You can download SDK package from the link:

Welcome | MCUXpresso SDK Builder 

pastedImage_4.png

Hope it can help you

BR

XiangJun Rong

0 Kudos

874 Views
prasannanaik
Contributor III

Hi XiangJun,

   Thanks for your valuable input!!!

   Can you please elaborate your answer for question no. 3. I am not able to find that feature in user manual.

Thanks and best regards,

Prasanna

0 Kudos

874 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Prasanna,

The ADC supports external pin trigger, pls refer to the following section. For the GINT0/1 module, pls refer to the section:

Chapter 14: LPC546xx Group GPIO input interrupt (GINT0/1)

Hope it can help you

BR

XiangJun Rong

pastedImage_1.png

0 Kudos

874 Views
prasannanaik
Contributor III

Hi XiangJun,

   I need calrity on the feature that provides interrupt after completion of the sampling of all the cahnnels in the sequence.

   The manual provides details about only single select and burst mode which are not applicable to my application. I want to know the feature that provides this sampling of all channels on 1 trigger and gives an interrupt after completion of sequence.

Thanks,

Prasanna

0 Kudos

874 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Prasanna,

You require  the feature that provides interrupt after completion of the sampling of all the cahnnels in the sequence with ONE trigger, okay, this is the bit configuration in SEQA_CTRL/SEQB_CTRL

BURST bit: 0

SINGLESTEP bit: 0

MODE bit: 1

Hope it can help you

BR

XiangJun Rong

0 Kudos

874 Views
prasannanaik
Contributor III

Hi XiangJun,

   Thanks for your guidance. In short SINGLESTEP bit controls the sequencing option. If SINGLESTEP = 1, only one channel will be sampled on trigger and if SINGLESTEP = 0, all channels will be sampled on trigger right?.

Thanks,

Prasanna

0 Kudos

874 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Prasanne,

Yes, you are right, if SINGLESTEP = 0, all channels will be sampled on trigger.

BR

Xiangjun Rong

0 Kudos

874 Views
prasannanaik
Contributor III

Hi XiangJun,

   Thank you for solving this query. I have one more query regarding ADC. I couldn't find the effective number of bits in the user manual and data sheet. Could you please help me find it.

Thanks,

Prasanna

0 Kudos

874 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Prasanna,

We have not tested the ENOB(Effective Number of Bits) spec for the ADC of LPC546xx, I am sorry.

BR

XiangJun Rong

0 Kudos