u8 DHT11_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //使能PB端口时钟 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_1 | GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStructure); //初始化IO口 GPIO_SetBits(GPIOB,GPIO_Pin_3 | GPIO_Pin_1 | GPIO_Pin_7); // 输出高 DHT11_Rst(); //复位DHT11 return DHT11_Check();//等待DHT11的回应 }
代码上的PB1、7口都可以用,后来就是用PB7口控制DHT11读取数据的。
这是帖子地址//www.icxbk.com/community/thread-96082-1-1.html
PB3是JTAG的接口之一,你看一下禁用了JTAG功能没有