Page 1 of 1

Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Posted: Fri Jun 18, 2021 6:52 pm
by Vadim777
Hi all.

I'm going to use the Blink example from Arduino IDE 1.8.15 (my board is STM32F401RE).
How shall I put the names of the built-in LED into an Arduino sketch? Various names (D13, 13, LED_BUILTIN, etc.) don't work for me.
LED doesn't blink.
Upload via Mass Storage works (MBED Blink Example; .BIN export; DragNDrop to NUCLEO storage).

Thanks in advance,

Vadim.

Re: Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Posted: Sat Jun 19, 2021 12:34 am
by mrburnette
Vadim777 post_[code wrote:[/code]id=7575 time=1624042360 user_id=1506]
Hi all.

I'm going to use the Blink example from Arduino IDE 1.8.15 (my board is STM32F401RE).
How shall I put the names of the built-in LED into an Arduino sketch? Various names (D13, 13, LED_BUILTIN, etc.) don't work for me.
The LED_BUILTIN is a "board" selection in the IDE, not by chip architecture/model.

The variant header sets the variable as below: (from Example)

Code: Select all

//On-board LED pin number
#ifndef LED_BUILTIN
  #define LED_BUILTIN           PC9
#endif
So, looking at supported boards using your uC, you must select from:
https://github.com/stm32duino/Arduino_C ... -64-boards

STM32F401RE Nucleo F401RE 0.2.1
or
STM32F401RB
STM32F401RC
STM32F401RD
STM32F401RE Generic Board 1.8.0

If you are using a generic board, you likely need to define your own LED_BUILTIN

Re: Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Posted: Sat Jun 19, 2021 8:44 am
by Vadim777
So, this is the code:

Code: Select all

//On-board LED pin number
#ifndef LED_BUILTIN
  #define LED_BUILTIN PA5
#endif

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a 1000 millisecond
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a 1000 millisecond
}
It doesn't work for me.
What I'm doing wrong?

Thanks,
Vadim.

Re: Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Posted: Sat Jun 19, 2021 8:59 am
by ag123
simply use

Code: Select all

digitalWrite(PAXX, ! digitalRead(PAXX));
where PAXX is your LED pin, and are you sure your LED is at PA5?

if you buy aftermarket stm32 boards, there are all kind of goofs like that the led is soldered reverse biased, check that out.
e.g. use a simple dry cell to test it, careful about blowing your mcu though.

there is one more possibility, the sketch failed to flash or failed to run, for that check the logs or use a debugger and a st-link v2.

Re: Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Posted: Sat Jun 19, 2021 3:33 pm
by Vadim777
are you sure your LED is at PA5?
Yes, I'm sure. It's PA5 or D13, if I would like to use an Arduino convention.
use a simple dry cell to test it
Yes, that is the first thing, that I was thinking of - I have an extra LED (with 1kOhm R) that I was connecting to the other pins (with the change of code).
That was not working either. Furthermore, I have connected it to the Ground pin or to 3,3V pin with no results.

I have exported the .BIN file from Arduino IDE and have dragndropped it to the mounted NUCLEO. It was not working at all. The other .BINs (from online MBED compiler and from STM32CubeIDE) are working as expected.

Thanks,
Vadim.

Re: Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Posted: Sat Jun 19, 2021 3:37 pm
by Vadim777
the sketch failed to flash or failed to run
With the logs, is all OK. Once more, it works with the other .BINs, but not with Arduino's.

Thanks.

Re: Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Posted: Sat Jun 19, 2021 4:01 pm
by fpiSTM
If you select the generic F401RE then the LED_BUILTIN is defined as PNUM_NOT_DEFINED:
https://github.com/stm32duino/Arduino_C ... eric.h#L92

So you have to redefine it using build_opt.h

https://github.com/stm32duino/wiki/wiki ... uild_opt.h


Or if your board is a nucleo F401RE select it in nucleo64 board type.

Re: Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Posted: Sat Jun 19, 2021 4:12 pm
by Vadim777
It's a NUCLEO-64, not generic.

So, I have a partial success: the export of .BIN from Arduino IDE v2 (rev. beta 7) with the Arduino convention LED pin name D13 have succeeded.

Directly, I can not burn from Arduino IDE v2, because Arduino can not find the STM32CubeProgrammer executable, which in turn is needed for that. How can I tell IDE v2, where it is?

Thanks,
Vadim.

Re: Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Posted: Sat Jun 19, 2021 5:15 pm
by fpiSTM
You have to install it to the default location or add it to the path. See the wiki.

Re: Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Posted: Sat Jun 19, 2021 7:10 pm
by fpiSTM
Anyway the simplest way is to use the mass storage upload method with a nucleo.