Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 11 months ago.
Question about multichannel AnalogIn
Hello,
I test the AnalogIn on the nRF51822. It works fine when I just need one channel of ADC. But when I want two or more channels, the results aren't correct. The last channel is correct and the others are not.
My codes:
- include "mbed.h"
Serial uart(P0_9,P0_11);
AnalogIn analog[]={p2,p4};
int main()
{ uart.baud(38400);
while(1)
{
uart.printf("A2:%d , A4:%d\r\n",analog[0].read_u16(),analog[1].read_u16());
wait(1);
} }
In these codes, just the result of A4 is correct.The result of A2 seems to be random. So why do this happen? I use this method on LPC1768, it works fine.I confused.Bugs in the library?
Thank you!
Question relating to:
1 Answer
9 years, 11 months ago.
That is indeed a bug in the library. I believe it is already fixed in mbed-src, and should then also be fixed in next regular mbed lib. So try removing your mbed lib and importing: http://mbed.org/users/mbed_official/code/mbed-src/