Programming STM32F4DISC Board With ArduinoIDE (STM32Duino)
by teukuzikrifatahillah in Circuits > Arduino
221 Views, 4 Favorites, 0 Comments
Programming STM32F4DISC Board With ArduinoIDE (STM32Duino)
![20240605_150456.jpg](/proxy/?url=https://content.instructables.com/FHY/6M6U/LX39Q17W/FHY6M6ULX39Q17W.jpg&filename=20240605_150456.jpg)
Reference : https://github.com/stm32duino/Arduino_Core_STM32
Accelerating your stm32 projects with stm32duino.
Supplies
- PC / Laptop with ArduinoIDE software
- STM32F4DISC Board
- Downloader Cable (Mini USB)
- AWG30 Cable 20 cm (Optional for Serial Debugging)
Add Board Support URLs
![1.png](/proxy/?url=https://content.instructables.com/FYC/86X7/LX39Q04Y/FYC86X7LX39Q04Y.png&filename=1.png)
![2.png](/proxy/?url=https://content.instructables.com/FLA/FZAL/LX39Q05B/FLAFZALLX39Q05B.png&filename=2.png)
![3.png](/proxy/?url=https://content.instructables.com/F0A/4M9E/LX39Q05C/F0A4M9ELX39Q05C.png&filename=3.png)
- Click File -> preference
- In the "Additional Board Manager URLs" add this link: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
- click OK
Install STM32 Based MCU
![4.png](/proxy/?url=https://content.instructables.com/FCE/I7B0/LX39Q09G/FCEI7B0LX39Q09G.png&filename=4.png)
![5.png](/proxy/?url=https://content.instructables.com/FC2/O4ID/LX39Q09T/FC2O4IDLX39Q09T.png&filename=5.png)
- Go to Tools -> Boards -> Boards Manager
- Search for "stm32duino"
- Click Install on the "STM32 Based MCU Boards"
- Wait for the instalation process to complete
Install Driver
![6.png](/proxy/?url=https://content.instructables.com/FVZ/31DP/LX39Q0TP/FVZ31DPLX39Q0TP.png&filename=6.png)
![10.png](/proxy/?url=https://content.instructables.com/FR4/VOBE/LX39Q0UK/FR4VOBELX39Q0UK.png&filename=10.png)
![12.png](/proxy/?url=https://content.instructables.com/FE8/YVK5/LX39Q0W2/FE8YVK5LX39Q0W2.png&filename=12.png)
![14.png](/proxy/?url=https://content.instructables.com/F6S/7M90/LX39Q0WK/F6S7M90LX39Q0WK.png&filename=14.png)
![driver_instalation.png](/proxy/?url=https://content.instructables.com/FB2/2F3P/LX39PXPS/FB22F3PLX39PXPS.png&filename=driver_instalation.png)
We will install STM32CubeProg to solve driver problems.
- First, go to this link
- Download STM32CubeProg. You will need to log in, or you can download it as a guest. The download link will be sent to your email. Make sure you use the same browser to open the link as the one you used to request it previously.
- Extract the file and install STM32CubeProg by following the steps until the instalation is complete
Try Blink
![28.png](/proxy/?url=https://content.instructables.com/F3B/HMX5/LX39Q0YC/F3BHMX5LX39Q0YC.png&filename=28.png)
![29.png](/proxy/?url=https://content.instructables.com/FND/H25C/LX39Q0YW/FNDH25CLX39Q0YW.png&filename=29.png)
![blink.gif](/proxy/?url=https://content.instructables.com/F1I/OMTM/LX39PXJS/F1IOMTMLX39PXJS.gif&filename=blink.gif)
- Write the code below
- Click Tools -> Boards -> STM32 Based MCU Boards -> Generic STM32F4 Boards
- Make sure the downloader cable is plugged in
- Click Upload or press CTRL+U on keyboard
const int led_pin[4] = {PD12, PD13, PD14, PD15};
void setup() {
// put your setup code here, to run once:
for(int i = 0; i < 4; i++)
{
pinMode(led_pin[i], OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
for(int i = 0; i < 4; i++)
{
digitalWrite(led_pin[i], HIGH);
delay(100);
digitalWrite(led_pin[i], LOW);
delay(100);
}
}
Downloads
Try Serial Communication (Useful for Debugging)
![30.jpg](/proxy/?url=https://content.instructables.com/F69/YC42/LX39Q1R7/F69YC42LX39Q1R7.jpg&filename=30.jpg)
![31.jpg](/proxy/?url=https://content.instructables.com/F0M/RA05/LX39Q1V1/F0MRA05LX39Q1V1.jpg&filename=31.jpg)
![32.png](/proxy/?url=https://content.instructables.com/FP7/J1H0/LX39Q2B9/FP7J1H0LX39Q2B9.png&filename=32.png)
![33.png](/proxy/?url=https://content.instructables.com/FAW/8OJ4/LX39Q2BW/FAW8OJ4LX39Q2BW.png&filename=33.png)
![34.png](/proxy/?url=https://content.instructables.com/FOV/WSM2/LX39Q2OK/FOVWSM2LX39Q2OK.png&filename=34.png)
- Configure the hardware, Use flying wires to connect (ST-LINK VCP pin 12 and 13) to (STM32F407 USART2 pin PA2 and PA3) as shown in the figure
- Click Tools -> Boards -> STM32 Based MCU Boards -> Generic STM32F4 Boards
- Write the code below
- Make sure the downloader cable is plugged in
- Click Upload or press CTRL+U on keyboard
- Click Serial Monitor in the top right corner or press CTRL+M on keyboard
- Change the baudrate to 115200 to match what we programmed
#include <HardwareSerial.h>
HardwareSerial Serial2(PA3,PA2);
void setup() {
// put your setup code here, to run once:
Serial2.begin(115200); // Initialization
}
void loop() {
// put your main code here, to run repeatedly:
Serial2.println("Hello World!");
delay(1000);
}