2026-05-27 10:59 AM
I have created the below circuit and build a PCBA. I'm using the J-Link Base Compact and Tag-Connect TC2030.
Using the Arduino IDE I created a simple sketch to drive the 4 LEDs shown on the schematic below and blink every second.
The code compiles ok and Arduino IDE reports that it has successfully upload to the SMT32 chip, but the LEDs won't blink. I tried enableling outputs to other pins as well, but the problem persists. Any ideas what might be causing this? I'm using the Generic STM32L4 series "board" from Arduino library.
Solved! Go to Solution.
2026-05-28 7:58 AM - edited 2026-05-28 8:05 AM
So your J-Link should connect to 3V3 - not BATT_IN.
It's for the J-Link to sense what voltage the MCU is actually running at.
PS:
Not the latest manual, but:
2026-05-27 11:43 AM
If BOOT0 is floating it may be booting into the bootloader instead of user code. Either ground BOOT0 or adjust option bytes using STM32CubeProgrammer to boot into the flash regardless of BOOT0 pin state.
2026-05-27 5:13 PM - edited 2026-05-27 6:47 PM
Thanks for the tip, but I've connected boot0 to ground and I still have the same issue. The application is not running. I moved over to STM32CubeIDE and instill trying to use Segger J-Link and I'm having the same issue.
The code compiled without issues and I programmed the device with STM32CubeProgrammer and received the output succesfull below.
19:56:49 : Start operation achieved successfully
19:58:40 : Opening and parsing file: BlinkTest.elf
19:58:40 : Memory Programming ...
19:58:40 : File : BlinkTest.elf
19:58:40 : Size : 4.11 KB
19:58:40 : Address : 0x08000000
19:58:40 : Erasing memory corresponding to segment 0:
19:58:40 : Erasing internal memory sectors [0 2]
19:58:40 : Download in Progress:
19:58:40 : File download complete
19:58:40 : Time elapsed during download operation: 00:00:00.249
19:58:40 : Verifying...
19:58:40 : File size < 32KB legacy verify will be used
19:58:40 : Read progress:
19:58:40 : Time elapsed during verifying operation: 00:00:00.018
19:58:40 : Download verified successfully
19:58:40 : Memory [0x08000000 : 0x08020000] - Checksum : 0x01BD8D08
19:58:40 : RUNNING Program ...
19:58:40 : Address: : 0x08000000
19:58:40 : Application is running, Please Hold on...
19:58:40 : Start operation achieved successfully
20:02:48 : Disconnected from device.In my main.c I'm running a simple script to toggle some pins to verify board functionality.
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_SET);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_RESET);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_SET);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_RESET);
HAL_Delay(500);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}The pin configuration was also setup with MX
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5
|GPIO_PIN_6|GPIO_PIN_7, GPIO_PIN_RESET);
/*Configure GPIO pins : PA1 PA4 PA5 PA6 */
GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pin : PA7 */
GPIO_InitStruct.Pin = GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PB0 PB1 PB6 PB7 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pins : PB4 PB5 */
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}
2026-05-28 5:26 AM
Debug the program. Hit pause, see where execution is at. If BOOT0 is grounded, most likely other things are invalid clock settings in SystemClock_Config, or option bytes are set up not to boot to user flash.
2026-05-28 5:40 AM - edited 2026-05-28 5:46 AM
Where is VDDA supplied from ?
What is BATT_IN? Are you using the J-Link to supply power to the board?
Have you tested your code on a known-good board; eg, a Nucleo board?
PS:
See also AN4555, Getting started with STM32L4 Series and STM32L4+ Series hardware development
2026-05-28 6:47 AM
VDDA is tied to 3V3 and BATT_IN is voltage before the regulator, which is about 3.6V.
And yes, the code was tested on the nucleo without issues. This is the rest of the circuit. U3 is not installed and VDDA is tied to 3V3.
2026-05-28 7:22 AM
So you are using the J-Link to supply power ?
I think you should check with Segger whether this is a valid configuration: I think it's intended to supply power direct to the target MCU - not via a regulator?
https://www.segger.com/support/technical-support/
https://forum.segger.com/board/4-j-link-flasher-related/
2026-05-28 7:53 AM
No, BATT_IN is connected to an external power supply.
2026-05-28 7:58 AM - edited 2026-05-28 8:05 AM
So your J-Link should connect to 3V3 - not BATT_IN.
It's for the J-Link to sense what voltage the MCU is actually running at.
PS:
Not the latest manual, but:
2026-05-28 9:30 AM
Tied Vref to 3V3 and I can now toggle a pin. Not sure if that did it since the VTref is only to detect power presence? Isn't it only looking for a voltage?
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.