Arduino IDE settings for STM32 MCU
Follow these steps to set up your STM32 MCU development environment.
Next
Install the software needed to write programs to LeafonyWhat to prepare
- STM32 MCU Leaf
- Basic Kit
- PC (Windows, Mac OS X or Linux)
Installing the Arduino IDE
For instructions on how to install the Arduino IDE, please here.
Connect to PC
Connect it to your PC with a USB cable.
Configuration of the microcontroller board
To use the STM32 MCU leaf with the Arduino IDE, the STM32 Cores must be installed. Please follow the steps below to configure the settings. (For more information about STM32 Cores, see here).
- Open the
File → Preferences
in the Arduino IDE and enter the following URL in theAdditional Board Manager URL:
field.
https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json
-
Select
Tools -> Board -> Board Manager
, search for STM32 Cores and press theInstall
button.
-
Go to
Tools → Board→ STM32 Boards (Selected from submenu)→ Nucleo-64
. -
Go to
Tools → Board part number: *****→ Nucleo L452RE
. -
Go to
Tools → Upload method: ***** → STM32CubeProgrammer(Serial)
. -
Go to
Tools → Serial Port
and select the serial port to which Leafony is connected.
Installing the STM32CubeProg
To be able to write programs to the STM32 MCU leaf, you need to install STM32CubeProg 1.The STM32CubeProg can be downloaded and installed on your PC here.
Checking the operation of the microcontroller board
-
When the
program switch
on the STM32 MCU leaf is set to the program side, the LED will light up. -
Next, refer to the sample application “Temperature and humidity sensor” and write the program. If it is written successfully, the message
Start operation achieved successfully
will be displayed.If it is not displayed 2, be careful. -
When writing is complete, turn the STM32 MCU leaf’s
Program switch
to the Run side to turn off the LED. -
Press the
Reset switch
on the STM32 MCU leaf.
Specifying pins for a sketch
Since the pin layout of the STM32 MCU is different from that of the Nucleo L452RE, it is not possible to use names when specifying pins. For STM32 MCU leaf, specify pins by port (Port)。
Installing libraries
To use some of the leaves, you will need to install additional libraries. Here to install all libraries in advance. However, you cannot use the timer interrupt library (MsTimer2.h) because it is an AVR MCU library. Please refer to the following HardwareTimer.
HardwareTimer
An example of use is given below. For more information here.
Initialization
HardwareTimer *timer2 = new HardwareTimer (TIM2);
timer2->setOverflow(LOOP_INTERVAL, MICROSEC_FORMAT); // 125ms
timer2->attachInterrupt(intTimer);
timer2->resume();
Interrupt routine
void intTimer(void){
bInterval = true;
:
:
}
When in doubt
You can find the solution in “If it doesn’t work…”.
Next step
Sample app has several programs.To make development easier, please install the library before you begin.
-
We have confirmed that V2.6.0 and V2.4.0 work on Windows 64bit. However, please note that V2.5.0 will not work. ↩︎
-
When writing without the program switch on the program side, the message
Writing to the board is complete
is also displayed, but the bottom of the screen showsTimeout error occured while waiting for acknowledgement
. ↩︎