微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > 此贴终结,勿回

此贴终结,勿回

时间:10-02 整理:3721RD 点击:

想让GPIOB_Pin_5置高电平的,结果测出来是0v代码如下
主函数:

  1. #include "stm32f10x.h"
  2. #include"testIO.h"

  3. int main(void)
  4. {
  5.         LCD_Com_GPIO_Config();
  6. GPIOB->BRR  = 0x00000020 ;
  7. <font color="#ff0000">//GPIO_SetBits(GPIOB, GPIO_Pin_5); // 把这句注释去掉就能测得输出高电平了</font>
  8. }

复制代码

testIO.c

  1. #include"testIO.h"

  2. void LCD_Com_GPIO_Config(void)
  3. {
  4.         GPIO_InitTypeDef GPIO_InitStructure;  
  5.         RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);
  6.         
  7.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 ;
  8.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  9.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  10.         
  11.         GPIO_Init(GPIOB, &GPIO_InitStructure);
  12. }

复制代码


testIO.h

  1. #ifndef _testIO_h_
  2. #define _testIO_h_
  3. /***********************************************************************************/
  4. #include "stm32f10x.h"
  5. #define PIN_5_H                       GPIOB->BRR  = 0x00000020
  6. #define PIN_5_L                       GPIOB->BSRR  = 0x00000020
  7. void LCD_Com_GPIO_Config(void);
  8. /**********************************************************************************/
  9. #endif

复制代码



//GPIO_SetBits(GPIOB, GPIO_Pin_5); // 把这句注释去掉就能测得输出高电平了

也就是寄存器操作无效了

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top