stm32配置调试引脚-CubeMx模板

JTAG和SWD或者不用此引脚的配置
控制文档: stm32f1xx_hal_msp.c
控制函数:void HAL_MspInit(void)
控制语句:
/** DISABLE: JTAG-DP Disabled and SW-DP Disabled /
__HAL_AFIO_REMAP_SWJ_DISABLE();
/
* ENABLE: Full SWJ (JTAG-DP + SW-DP): Reset State */
__HAL_AFIO_REMAP_SWJ_ENABLE();
寄存器层:
#define __HAL_AFIO_REMAP_SWJ_ENABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_RESET)
#define AFIO_MAPR_SWJ_CFG_RESET 0x00000000U

#define __HAL_AFIO_REMAP_SWJ_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_DISABLE)
#define AFIO_MAPR_SWJ_CFG_DISABLE AFIO_MAPR_SWJ_CFG_DISABLE_Msk

#define AFIO_MAPR_SWJ_CFG_DISABLE_Pos (26U)
#define AFIO_MAPR_SWJ_CFG_DISABLE_Msk (0x1U << AFIO_MAPR_SWJ_CFG_DISABLE_Pos) /*!< 0x04000000 */

#define AFIO_DBGAFR_CONFIG(DBGAFR_SWJCFG) do{ uint32_t tmpreg = AFIO->MAPR;
tmpreg &= ~AFIO_MAPR_SWJ_CFG_Msk; \ 清零24,25,26:000: Full SWJ (JTAG-DP + SW-DP): Reset State
tmpreg |= DBGAFR_SWJCFG; \使能,此处或0:不改变默认值 禁能:此处为100:100: JTAG-DP Disabled and SW-DP Disabled
AFIO->MAPR = tmpreg;
}while(0U)
#define AFIO_MAPR_SWJ_CFG_Pos (24U)
#define AFIO_MAPR_SWJ_CFG_Msk (0x7U << AFIO_MAPR_SWJ_CFG_Pos) /*!< 0x07000000 */

结论:
两个参数都是配置24-27位,使能或禁能jtag及swd功能

你可能感兴趣的:(#,2.2.4,单片机平台)