reading 8 channel adc, LPC1768, CMSIS

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

reading 8 channel adc, LPC1768, CMSIS

989 Views
Alexshea
Contributor III

@xiangjun_rong Hello, my problem is I want to use all adc channels, but I can only do that when 3 of them are activated and the moment I activate the 4th one my code stops. Last time you asked me to upload the intact project because of the api and LPCopen. I once again add the intact project. I understand that you might be busy and that's why you don't answer, but I thought maybe you can't see my posts. Nevertheless, I uploaded the intact project and hope this helps us figure out the problem. If you aren't able to help, I won't ask you anymore I don't want to spam you here.

Thank you in advance, 

Alex

Labels (1)
0 Kudos
Reply
2 Replies

982 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Alex,

I have downloaded the all project, and checked the code, I think you can change the code like:

uint16_t HW_ADC_Read(uint8_t channel_num)
{
uint16_t voltage;
//disable all channels
ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_0,DISABLE);
ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_1,DISABLE);
ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_2,DISABLE);
ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_3,DISABLE);
ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_4,DISABLE);
ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_5,DISABLE);
ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_6,DISABLE);
ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_7,DISABLE);
//enable the sampled channel
ADC_ChannelCmd(LPC_ADC,channel_num,ENABLE);
ADC_StartCmd(LPC_ADC,ADC_START_NOW);
while(ADC_ChannelGetStatus(LPC_ADC,channel_num,ADC_DATA_DONE)!=SET) {}
voltage=ADC_ChannelGetData(LPC_ADC,channel_num);
calcVolt=(voltage*3.6F)/4096;
temp=(calcVolt*1000.0F);

return voltage;
}

Pls have a try.

BR

XiangJun Rong

0 Kudos
Reply

959 Views
Alexshea
Contributor III

Thank you so much

0 Kudos
Reply