本帖最后由 wang2012216 于 2023-6-18 18:21 编辑
!!!已解决
业余爱好,stc8h8k64u 32脚的,P2口配置为准双向,另外IIC用了P24、P25,
P26、P27分别接了个五向开关的2个脚,上电设置为1,用万用表检测这两个io口一直为低电平,请问该怎么配置?
P0口相同配置,P00、P01、P02也是接五向开关,P0口就正常,单机双击长按检测均正常,就P26、P27一直是低电平,外接上拉也不行。
1:IIC和GPIO初始化。
- void GPIO_config(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure; //结构定义
- GPIO_InitStructure.Pin = GPIO_Pin_All; //指定要初始化的IO, GPIO_Pin_0 ~ GPIO_Pin_7, 或操作
- GPIO_InitStructure.Mode = GPIO_PullUp; //指定IO的输入或输出方式,GPIO_PullUp,GPIO_HighZ,GPIO_OUT_OD,GPIO_OUT_PP
- GPIO_Inilize(GPIO_P0,&GPIO_InitStructure); //初始化
- GPIO_InitStructure.Pin = GPIO_Pin_All; //指定要初始化的IO, GPIO_Pin_0 ~ GPIO_Pin_7, 或操作
- GPIO_InitStructure.Mode = GPIO_PullUp;
复制代码