We are customizing ADC channel in LPC 55S16 to use multiple channel
Here we are using following pins
P1_9 (ADC0_12), P1_8(ADC0_4), P0_16(ADC0_8) )
How we can configure multiple channels for those pins
i) Is any relation between ADC channel and SWTRIG
How we can choose the value of ADC0->SWTRIG = ?
ii) Is any relation between TCTRL and SWTRIG
How we can choose the element and value of of ADC0->TCTRL[?] = ?
Kindly give the solution to solve the problem
Hi,
The LPC55ss ADC support command chain, each command register includes the ADC channel, and Next Command bit field which point to next command.
In the first command, you can define the ADC channel, in the next command bit field, you can set up the chained command index. In the chained command, you can define the second ADC channel and secondly chained next-command. In the secondly-chained command register, you can define the third ADC analog channel, if this is the last channel, set the third-chained next-command bits as 0, which means chaining ends up.
The following is the command chain, hope it can help you.
lpadc_conv_command_config_t mLpadcCommandConfigStruct0,mLpadcCommandConfigStruct1,mLpadcCommandConfigStruct2;
LPADC_GetDefaultConvCommandConfig(&mLpadcCommandConfigStruct0);
mLpadcCommandConfigStruct0.channelNumber = DEMO_LPADC_USER_CHANNEL; //adc channel0
mLpadcCommandConfigStruct0.chainedNextCommandNumber=DEMO_LPADC_USER_CMDID2;
LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, DEMO_LPADC_USER_CMDID1, &mLpadcCommandConfigStruct0);
///////////////Rong added another adc channel
LPADC_GetDefaultConvCommandConfig(&mLpadcCommandConfigStruct1);
mLpadcCommandConfigStruct1.channelNumber = DEMO_LPADC_USER_CHANNEL+1; //DEMO_LPADC_USER_CHANNEL+1=1, adc channel1
mLpadcCommandConfigStruct1.chainedNextCommandNumber=DEMO_LPADC_USER_CMDID3;
LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, DEMO_LPADC_USER_CMDID2, &mLpadcCommandConfigStruct1);
LPADC_GetDefaultConvCommandConfig(&mLpadcCommandConfigStruct2);
mLpadcCommandConfigStruct2.channelNumber = DEMO_LPADC_USER_CHANNEL+2; //DEMO_LPADC_USER_CHANNEL+1=1, adc channel1
mLpadcCommandConfigStruct2.chainedNextCommandNumber=0;
LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, DEMO_LPADC_USER_CMDID3, &mLpadcCommandConfigStruct2);
hope it can help you.
BR
XiangJun Rong
Thanks for the support.
could you help me to configure ADC for channel 8 (i.e, ADC0_8 P0_16)
Kindly forward the ADC driver to configuring ADC0_8
I need to configure ADC for these PINS
P1_9 (ADC0_12), P1_8(ADC0_4), P0_16(ADC0_8)
Hi,
For the P1_9 (ADC0_12), it's channel index is CH4B. For the P1_8(ADC0_4), it's channel index is CH4A.
If you sample P1_9 (ADC0_12, CH4B), you can use the code:
LPADC_GetDefaultConvCommandConfig(&mLpadcCommandConfigStruct1);
mLpadcCommandConfigStruct1.sampleChannelMode=kLPADC_SampleChannelSingleEndSideB;
mLpadcCommandConfigStruct1.channelNumber = 4; //CH4A
mLpadcCommandConfigStruct1.chainedNextCommandNumber=DEMO_LPADC_USER_CMDID3;
LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, DEMO_LPADC_USER_CMDID2, &mLpadcCommandConfigStruct1);
If you sample P1_8(ADC0_12, CH4A), you can use the code:
LPADC_GetDefaultConvCommandConfig(&mLpadcCommandConfigStruct1);
mLpadcCommandConfigStruct1.sampleChannelMode=kLPADC_SampleChannelSingleEndSideA;
mLpadcCommandConfigStruct1.channelNumber = 4; //CH4A
mLpadcCommandConfigStruct1.chainedNextCommandNumber=DEMO_LPADC_USER_CMDID3;
LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, DEMO_LPADC_USER_CMDID2, &mLpadcCommandConfigStruct1);
Hope it can help you
BR
XiangJun Rong
could you help me to configure ADC for channel 8 (i.e, ADC0_8 , PIN P0_16)