5 years, 7 months ago.

Compiler error for "STM32_read_analog" example

Hello,

The example "STM32_read_analog" provided with this board gives the following error when compiling on Mbed :

"Error: Identifier "A4" is undefined in "main.cpp", Line: 3, Col: 24" The code "AnalogIn analog_value(A4);" is not accepted. Why?

(A0 of the example has been changed in A4 as A0 can not be use as an Analog Input on this board)

Question relating to:

The STM32F334 discovery kit helps you to discover the digital power features of the STM32F334 and to develop your applications easily.

2 Answers

5 years, 6 months ago.

Not sure which example you are using but this works for me on a NUCLEO-L432KC using the imported and current Mbed(os2) rev.172

https://os.mbed.com/teams/ST/code/STM32_read_analog/

Looking at the Mbed-Dev files I can see the Arduino compatible pin defines are commented out so that would explain it, you can't use the Arduino notation on this board as indicated below.

pinNames.h snippet

    // Arduino connector namings
    // Note: The Arduino connector is not present on this board.
    // We keep these definitions for compatibility with Nucleo code examples.
    // A0          = PA_0,
    // A1          = PA_1,
    // A2          = PA_4,
    // A3          = PB_0,
    // A4          = PC_1,
    // A5          = PC_0,
    // D0          = PA_3,
    // D1          = PA_2,
    // D2          = PA_10,
    // D3          = PB_3,
    // D4          = PB_5,
    // D5          = PB_4,
    // D6          = PB_10,
    // D7          = PA_8,
    // D8          = PA_9,
    // D9          = PC_7,
    // D10         = PB_6,
    // D11         = PA_7,
    // D12         = PA_6,
    // D13         = PA_5,
    // D14         = PB_9,
    // D15         = PB_8,

If you take a look at the pin out picture, you can use pin names PA_0 to PA_7 plus others. Substitute A0 for PA_0 and try again.

https://os.mbed.com/platforms/ST-Discovery-F334C8/

Accepted Answer

Thanks very much too for this so quick answer!

posted by victor guillot 27 Apr 2019
5 years, 6 months ago.

Hi there, your board do not have the A0 pin mask because this boar do not have an arduino header like Nucleo64 boards. You can see line 119 here https://os.mbed.com/users/mbed_official/code/mbed-dev/file/f392fc9709a3/targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F334x8/TARGET_DISCO_F334C8/PinNames.h/

Change pin A0 to PA_0 but be careful in default is this pin connected to the onboard user button, how you can see on big board picture here https://os.mbed.com/platforms/ST-Discovery-F334C8/. I recommend use another analog pin like is PA_1 for example.

Maybe that help, gl.

Best regards

J.

Thanks very much for this so quick answer!

posted by victor guillot 27 Apr 2019