STM32F103释放Jtag接口用做普通io

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wuxinke_blog/article/details/48825591

stm32上有两个调试接口,一个是比较通用的Jtag,一个是SWD。SWD占用的IO口更少,因此,我们可以用SWD来调试MCU,这样,除去swd的两条线,Jtag接口的另外三个口则可以用来作普通IO口使用,配置很简单,分享给各位:

GPIO_InitTypeDef GPIO_InitStructure;

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); 
// GPIO_AFIODeInit();

GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed   = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_15 ;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed   = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_3 ;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
 
GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed   = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_4 ;
  GPIO_Init(GPIOB, &GPIO_InitStructure);

猜你喜欢

转载自blog.csdn.net/wuxinke_blog/article/details/48825591