TWR-K20D72M can't read the multiple ADC channels from one ADC(ADC0 or ADC1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am working with TWR-K20D72M EVM as controller and IAREW(IAR Embedded Workbench) software for programming.i download the sample codes for this board from the below link :
i am working on ADC so i take the reference of those sample codes.in above linked sample codes ADC sample code is given on interrupt bases but i want to make the ADC code on polling bases and it works properly with one channel.i attached my code for your reference.in this code i select the ADC channel no-19 in board this channel is connected with the potentiometer.in this code i continuously read the ADC1_RA and ADC1_RB(ADC Data registers) and it works properly when i change the potentiometer's pot it's readings also changes.but i am facing one problem which i mention below please try to solve my below query:
- i wants to read continuously two or more channels from one ADC(ADC0 or ADC1).for that in my attached code to change the channel i make the Change_channel() function.i tried this function to change the ADC channel but it not works.so give me suggestion to change the ADC channel and i can read the multiple ADC channels continuously.
Thank You
Bhavin
Original Attachment has been moved to: ADC.zip
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there any update on this issue?
please help me i am stuck in this issue and its urgent for me.
Any help in this will be appreciated more.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Regarding your problem, I suggest you modify the code as following:
void Change_channel(uint8 channelA,uint8 channelB)
{
Master_Adc_Config.STATUS1A = AIEN_OFF | DIFF_SINGLE | ADC_SC1_ADCH(channelA);
Master_Adc_Config.STATUS1B = AIEN_OFF | DIFF_SINGLE | ADC_SC1_ADCH(channelB);
ADC_Config_Alt(ADC1_BASE_PTR, &Master_Adc_Config); // config ADC1
}
uint8_t hw_adc_test(void)
{
sim_init();
pdb_init();
adc_init(19);
lptmr_init(0x01110,3);
enable_irq(INT_LPTimer-16);
PDB0_SC |= PDB_SC_SWTRIG_MASK; // kick off the PDB - just once
while(1)
{
printf("R0A=%d R0B=%d\n",ADC1_RA, ADC1_RB);
time_delay_ms(3000);
Change_channel(5,18); //sample channel 5 and channel18
}
// disable the PDB
PDB0_SC = 0;
}
But the ADC16 can only sample two channels triggered by PDB, if you use software triggering, you can only sample one channel one times, the ADC16 does not support scan mode. If you want to sample multiple channel, you can change the channel by calling Change_channe().
Hope it can help you
BR
Xiangjun Rong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Xiangjun Rong,
Thank you for your reply as per your suggestion i change the code but it still not works and it continuously prints "R0A=0 R0B=0" so ADC data register not getting update.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Bhavin,
The code I gave you just demos how to change the channels, which ADC channels do you want to sample so that I can check you how to configure the pin as ADC pin?
BR
XiangJun Rong
