0
\$\begingroup\$

This is for a school project where I have to create a custom PCB using a STM32 microcontroller chip. I realize that in the CUBEIDE you can set clock speeds, pin functions, interrupts, etc., via the SWD pins. However, I have seen some individuals use a Serial to USB IC and program via a USB cable on the Arduino IDE and my teammates are emphasizing wanting to use Arduino libraries. My question is what is the fundamental difference between the two as far as programming peripherals and executing a program?

Should I establish a serial connection to program peripheral functions on the STM32 chip before trying flash programs via Arduino? Or can I immediately use the serial to USB chip to start programming my STM32 chip right away? Sorry if this is a confusing question but I have searched for a long time for a definitive answer and have found nothing. Any help clearing up the fundamental difference between the two or just giving the positives/negatives for using one over the other would be of great help!

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

They are not related. And there seems to be some misunderstanding about the term "programming", as it can either refer to "writing the code in an IDE" or "uploading the executable into flash memory". I answer based on the umderstanding it means uploading the firmware.

What you describe done with CubeIDE is setting up a new project and configure what kind of settings you want to compile and run your binary with. That is not done through SWD, and thus has nothing to do with how to upload the binary to the MCU. The compiled binary can be however programmed via SWD.

What you describe done with Arduino IDE is uploading the binary to MCU. It has nothing to do with how to compile the binary. Most STM32s have a factory bootloader which can be used to program via serial connection.

\$\endgroup\$
0
\$\begingroup\$

In order to program the flash on a custom board via SWD you need a programming device such as an ST-Link/V2. And your custom board should include a Cortex-M debug connector (10-pin), which is where the programmer device will connect.

If you don't have a programming device, then it's possible to program the flash via the serial port using the ROM boot loader built-in to the chip.

The huge benefit of using SWD with the programming device is that this method also allows you to single-step debug your custom program.

ST Micro's Discovery and Nucleo evaluation boards have the ST-Link programmer built-in to the board so that you don't need a separate programmer device.

When you use the CubeIDE to "set clock speeds, pin functions, interrupts, etc.", you're configuring the IDE to generate code that will configure the peripherals when the code runs on the microcontroller. Those peripherals are not configured via SWD. Rather, you use SWD to program the executable code onto the flash, then peripherals get configured when that code runs.

\$\endgroup\$
2
  • \$\begingroup\$ Let me see if I understand this correctly. I need the ST-Link in order to install the firmware(pin/clock configuration). After this is completed, can I then program executables into the flash memory using either the STM32CubeIDE or the ArduinoIDE via the SWD pins? \$\endgroup\$
    – JymmyBob
    Feb 7, 2023 at 14:51
  • \$\begingroup\$ @JymmyBob No, that's not how I would say it. You need a programming device, such as ST-Link/V2, to connect to the chip via the SWD interface. You can program the flash via the SWD interface. The firmware that you program onto the flash should configure the clocks/pins/peripherals appropriately for your application. \$\endgroup\$
    – kkrambo
    Feb 7, 2023 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.