Programming STM32F4DISC Board With ArduinoIDE (STM32Duino)

by teukuzikrifatahillah in Circuits > Arduino

197 Views, 4 Favorites, 0 Comments

Programming STM32F4DISC Board With ArduinoIDE (STM32Duino)

20240605_150456.jpg

Reference : https://github.com/stm32duino/Arduino_Core_STM32

Accelerating your stm32 projects with stm32duino.

Supplies

  1. PC / Laptop with ArduinoIDE software
  2. STM32F4DISC Board
  3. Downloader Cable (Mini USB)
  4. AWG30 Cable 20 cm (Optional for Serial Debugging)

Add Board Support URLs

1.png
2.png
3.png
  1. Click File -> preference
  2. In the "Additional Board Manager URLs" add this link: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json 
  3. click OK


Install STM32 Based MCU

4.png
5.png
  1. Go to Tools -> Boards -> Boards Manager
  2. Search for "stm32duino"
  3. Click Install on the "STM32 Based MCU Boards"
  4. Wait for the instalation process to complete

Install Driver

6.png
10.png
12.png
14.png
driver_instalation.png

We will install STM32CubeProg to solve driver problems.

  1. First, go to this link
  2. 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.
  3. Extract the file and install STM32CubeProg by following the steps until the instalation is complete

Try Blink

28.png
29.png
blink.gif
  1. Write the code below
  2. Click Tools -> Boards -> STM32 Based MCU Boards -> Generic STM32F4 Boards
  3. Make sure the downloader cable is plugged in
  4. 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);
 } 
}

Try Serial Communication (Useful for Debugging)

30.jpg
31.jpg
32.png
33.png
34.png
  1. 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
  2. Click Tools -> Boards -> STM32 Based MCU Boards -> Generic STM32F4 Boards
  3. Write the code below
  4. Make sure the downloader cable is plugged in
  5. Click Upload or press CTRL+U on keyboard
  6. Click Serial Monitor in the top right corner or press CTRL+M on keyboard
  7. 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);
   
}