reading 8 channel adc, LPC1768, CMSIS

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

reading 8 channel adc, LPC1768, CMSIS

1,549 次查看
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

标签 (1)
0 项奖励
回复
2 回复数

1,542 次查看
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 项奖励
回复

1,519 次查看
Alexshea
Contributor III

Thank you so much

0 项奖励
回复