You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

未安全拔出USB后ST-Link Debugger提示“No target connected”问题求助

Nucleo STM32F446RE ST-Link连接故障求助

设备与开发环境

  • 开发板:Nucleo STM32F446RE
  • 开发环境:Keil MDK,C语言

硬件配置要求

作业要求通过面包板连接外部LED与按键,接口配置如下:

  • Button1接PA1,配置为内部上拉模式
  • Button2接PA6,配置为外部下拉模式
  • LED1接PA4
  • LED2接PA7
  • PA2、PA3配置为USART2/UART2

编写的代码

#include <stdint.h>
#include "stm32f4xx.h"

#define Button1 (1)
#define Button2 (6)
#define LED1 (4)
#define LED2 (7)

unsigned char button1_down = 0;
unsigned char button2_down = 0;

int main(void) {
   RCC->AHB1ENR |=  1;                /* enable GPIOA clock */

// Button1
   GPIOA->MODER &= ~(0x0000000C << (Button1*2));        /* clear pin mode */
   GPIOA->PUPDR &= ~(0x0000000C << (Button1*2));        /* clear */
   GPIOA->PUPDR |=  (0x00000004 << (Button1*2));        /* set pin to pull up mode */

// Button2
   GPIOA->MODER &= ~(0x00003000 << (Button2*2));        /* clear pin mode */
   GPIOA->PUPDR &= ~(0x00003000 << (Button2*2));        /* clear */
   GPIOA->PUPDR |=  (0x00002000 << (Button2*2));        /* set pin to pull down mode */

// LED1
   GPIOA->MODER &= ~(0x00000300 << (LED1*2));
   GPIOA->MODER |= (0x00000100 << (LED1*2));
   GPIOA->OTYPER &= ~(1 << LED1);

//LED2
   GPIOA->MODER &= ~(0x0000C000 << (LED2*2));
   GPIOA->MODER |= (0x00004000 << (LED2*2));
   GPIOA->OTYPER &= ~(1 << LED2);

while(1) {
   uint32_t idr_val = ~GPIOA->IDR;
   if (idr_val & (1 << Button1)) {
       if (!button1_down) {
           GPIOA->ODR ^= (1<<LED1);
       }
       button1_down = 1;
   }
       else {
           button1_down = 0;
       }
   if (idr_val & (1 << Button2)) {
       if (!button2_down) {
           GPIOA->ODR ^= (1 << LED2);
       }
       button2_down = 1;
   }
       else {
           button2_down = 0;
       }
   }
}

问题描述

此前在Keil Debug选项卡选择ST-Link Debugger可正常连接开发板。完成硬件接线并编写代码后,发现功能未符合作业要求,未安全拔出USB线再次连接后,Debug界面持续提示No target connected,但板载LD1、LD2正常亮起。

已尝试的解决操作

  • 多次插拔开发板
  • 在多台曾正常连接的电脑上测试,均提示无法连接目标,但设备管理器均识别到“STM32 STLink”
  • 在笔记本设备管理器中卸载端口设备
  • 发现所有电脑的 eject 选项中新增“Eject NOD_F446RE”选项

怀疑原因

  • 开发板被识别为USB存储设备
  • 硬件接线问题导致板卡损坏

寻求该问题的解决方案。


内容的提问来源于stack exchange,提问作者Zianne

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 06:30:32