9 years, 10 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:

  1. 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:

The nRF51822-mKIT is a low cost ARM mbed enabled development board for Bluetooth® Smart designs with the nRF51822 SoC. The kit gives access to all GPIO pins via pin headers …

1 Answer

9 years, 10 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/

Accepted Answer