Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Development environment specific, Arduino, Eclipse, VS2013, Em::Blocks etc
Post Reply
Vadim777
Posts: 5
Joined: Fri Jun 18, 2021 6:37 pm

Pin Names for LED_BUILTIN in Arduino 1.8.15 (STM32F401RE).

Post 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.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

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

Post 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
Vadim777
Posts: 5
Joined: Fri Jun 18, 2021 6:37 pm

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

Post 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.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

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

Post 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.
Vadim777
Posts: 5
Joined: Fri Jun 18, 2021 6:37 pm

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

Post 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.
Vadim777
Posts: 5
Joined: Fri Jun 18, 2021 6:37 pm

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

Post 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.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post 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.
Vadim777
Posts: 5
Joined: Fri Jun 18, 2021 6:37 pm

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

Post 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.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post by fpiSTM »

You have to install it to the default location or add it to the path. See the wiki.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post by fpiSTM »

Anyway the simplest way is to use the mass storage upload method with a nucleo.
Post Reply

Return to “IDE's”