5 years, 4 months ago.

AnalogIn: First declared AnalogIn not working

Hi,

I'm working with some nucleo boards and platformio on linux. Platformio reports the installed mbed version as: 5.51001.1 which I guess would be 5.10.1?

This bug affects my L433rc-p and L432kc boards.

Testprogram

#include <mbed.h>

AnalogIn aA( A0 ), aB( A1 ), aC( A2 ), aD( A3 );

Serial com( USBTX, USBRX, 115200 );

int main() {

    while(1) {

        float a = aA.read(), b = aB.read(), c = aC.read(), d = aD.read();

        printf( "%.4f - %.4f - %.4f - %.4f\n", a, b, c, d );

        wait( .1 );
    }
}

The output looks like:

Output

0.6618 - 0.4398 - 0.3729 - 0.4154
0.5194 - 0.3707 - 0.3309 - 0.3560
0.5126 - 0.3646 - 0.3233 - 0.4200
...

If I connect one of the analog pins to GCC it should output: 0.0000. If pulled to 3V3 it should read 1.000.

This works except for aA( A0 ) which is completely unaffected.

If I change the definition to e.g.

AnalogIn aA( A2 ), aB( A3 ), aC( A4 ), aD( A5 );

Every port works *except aA( A2 )*

Same thing for

AnalogIn aA( A3 ), aB( A2 ), aC( A1 ), aD( A0 );

Every port works *except aA( A3 )*

The code *does work* on my F767zi board. (although this one reports GND as somwhere around 0.007)

Appendum (could only edit now):

It seems this depends not on the order of declaration but on the order of read. My current workaround for this problem is to have one analog pin as "sacrificial" pin which I read first every iteration.

Just got my F103 board. And this one doesn't have the problem.

posted by Florian Bantner 13 Dec 2018

1 Answer

5 years, 4 months ago.

Can you replicate this issue on the Mbed online compiler, you don't appear to have these boards added to your platforms?

I will try. I just created this account for reporting and didn't intent to use the online compiler. (I'm not *that* kind of guy ;)

posted by Florian Bantner 13 Dec 2018

It works with the L432 Board. Cant compile it for the L433 because the compiler says "Target NUCLEO_L433RC_P is not recognized". But I guess it would work. So what's the next step? I did try downloading mbed and copying it over platformios installed version which didn't fix the problem. (But I'm not 100% sure that did what I intended.)

posted by Florian Bantner 13 Dec 2018