zoukankan      html  css  js  c++  java
  • STM32库中关于GPIO_PinRemapConfig函数的使用

    对于初学习者来说为什么用到PB3和PB4时无法控制输出呢?

    下面就这一问题进行分析讲解。

    首先,STM32F10x系列的MCU复位后,PA13/14/15 & PB3/4默认配置为JTAG功能。有时我们为了充分利用MCU I/O口的资源,会把这些
    端口设置为普通I/O口。具体方法如下:
    在GPIO_Configuration(); // 配置使用的 GPIO 口:

    GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);   // 改变指定管脚的映射 GPIO_Remap_SWJ_Disable,SWJ 完全禁用(JTAG+SW-DP),而且管脚映射函数,需要在GPIO配置函数GPIO_Configuration()中
                                    
    GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE);  // 改变指定管脚的映射 GPIO_Remap_SWJ_JTAGDisable ,JTAG-DP 禁用 + SW-DP 使能,而且管脚映射函数,需要在GPIO配置函数GPIO_Configuration()中  

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

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13;
      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
      GPIO_Init(GPIOA, &GPIO_InitStructure); 

    注意:不要忘记在RCC_Configuration()中开启AFIO时钟,
      //AFIO时钟
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

  • 相关阅读:
    Spring 09 : AOP实例
    Spring08 AOP概念
    Spring 07 : 动态代理
    Spring06 Spring+Junit
    Spring05 : 基于注解的IOC
    Spring03 : 依赖注入
    jupyter修改python核(使用不同的python虚拟环境)
    线性代数的本质——引入几何视角
    图像的去雾与加雾
    从MATLAB看一个IDE应该具有的素质
  • 原文地址:https://www.cnblogs.com/watson8544/p/5552492.html
Copyright © 2011-2022 走看看