你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

STM32F030的SWD口如何做普通IO

[复制链接]
q80351951 提问时间:2017-3-19 20:10 /
STM32F030的SWD口如何做普通IO,不够用差一个,不知如何设置,发现和F1系列不同。一直没找到方法。
收藏 1 评论12 发布时间:2017-3-19 20:10

举报

12个回答
那片清茶 回答时间:2017-3-19 21:01:51
只要把SWD功能禁用就可以了
酱哒哒 回答时间:2017-3-19 21:25:17
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENABLE);
酱哒哒 回答时间:2017-3-19 21:25:54
RCC中开启AFIO时钟
q80351951 回答时间:2017-3-19 22:07:45
酱哒哒 发表于 2017-3-19 21:25
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENABLE);

F0不是103
q80351951 回答时间:2017-3-19 22:11:30

/**
  * @brief  Writes data to the specified GPIO data port.
  * @param  GPIOx: where x can be (A or B) to select the GPIO peripheral.
  * @param  GPIO_PinSource: specifies the pin for the Alternate function.
  *          This parameter can be GPIO_PinSourcex where x can be (0..15).
  * @param  GPIO_AF: selects the pin to used as Alternate function.
  *          This parameter can be one of the following value:
  *            @arg GPIO_AF_0: WKUP, EVENTOUT, TIM15, SPI1, TIM17,MCO, SWDAT, SWCLK, TIM14,
  *                            USART1, CEC, IR_OUT, SPI2
  *            @arg GPIO_AF_1: USART2, CEC, Tim3, USART1, IR_OUT,EVENTOUT, I2C1, I2C2, TIM15
  *            @arg GPIO_AF_2: TIM2, TIM1, EVENTOUT, TIM16, TIM17
  *            @arg GPIO_AF_3: TS, I2C1, TIM15, EVENTOUT
  *            @arg GPIO_AF_4: TIM14, I2C1 (only for STM32F0XX_LD and STM32F030X6 devices)
  *            @arg GPIO_AF_5: TIM16, TIM17
  *            @arg GPIO_AF_6: EVENTOUT
  *            @arg GPIO_AF_7: COMP1 OUT, COMP2 OUT
  * @note   The pin should already been configured in Alternate Function mode(AF)
  *         using GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
  * @note   Refer to the Alternate function mapping table in the device datasheet
  *         for the detailed mapping of the system and peripherals'alternate
  *         function I/O pins.
  * @retval None
  */
void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
{
  uint32_t temp = 0x00;
  uint32_t temp_2 = 0x00;

  /* Check the parameters */
  assert_param(IS_GPIO_LIST_PERIPH(GPIOx));
  assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
  assert_param(IS_GPIO_AF(GPIO_AF));

  temp = ((uint32_t)(GPIO_AF) << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
  GPIOx->AFR[GPIO_PinSource >> 0x03] &= ~((uint32_t)0xF << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
  temp_2 = GPIOx->AFR[GPIO_PinSource >> 0x03] | temp;
  GPIOx->AFR[GPIO_PinSource >> 0x03] = temp_2;
}


默认是 GPIO_AF_0,是swd,那做普通io呢?
q80351951 回答时间:2017-3-19 22:12:20
那片清茶 发表于 2017-3-19 21:01
只要把SWD功能禁用就可以了

f030
那片清茶 回答时间:2017-3-20 07:13:28

这个还真没有试过,各种配置方式都试试,把引脚配置成复用模式,试试。
xueshawu1 回答时间:2017-3-20 14:22:29
Once the SW I/O is released by the user software, the GPIO controller takes control of these
pins. The reset states of the GPIO control registers put the I/Os in the equivalent states:
• SWDIO: input pull-up
• SWCLK: input pull-down
Having embedded pull-up and pull-down resistors removes the need to add external
resistors.

F0参考手册,如2楼所说,你需要释放掉SWD功能
xmshao 回答时间:2017-3-20 17:27:28
SWD脚复位后默认是调试脚,

把它做普通IO配置就好了。具体就是将GPIOX_MODER寄存器相关位做配置就好,比STM32F1配置更为简洁。
12下一页

所属标签

相似问题

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号二维码 微信公众号
手机版二维码 手机版