杨洋阳 发表于 2017-12-6 09:02:37

STM8L152CC6的PD6口上拉为什么会失败?

RT,想用来做按键,设置输入上拉,但量出来是0.6V,一直为低,硬件不影响。查手册也说有弱上拉,非IIC口。
配置如下
#define Key0_PORT GPIOD
#define Key1_PORT GPIOB
#define Key2_PORT GPIOB
#define Key3_PORT GPIOB
#define Key4_PORT GPIOB
#define Key5_PORT GPIOB

#define Key0_PINS GPIO_Pin_6
#define Key1_PINS GPIO_Pin_1
#define Key2_PINS GPIO_Pin_2
#define Key3_PINS GPIO_Pin_3
#define Key4_PINS GPIO_Pin_4
#define Key5_PINS GPIO_Pin_5

//函数声明---------------------------------------------------------------------------
unsigned char KeyScan (void);
unsigned char GetKeyValue (void);
//-------------------------------------------------------------------------------------


void KeyIoInit()
{
GPIO_Init(Key0_PORT, Key0_PINS, GPIO_Mode_In_PU_No_IT);//带上拉,输入
GPIO_Init(Key1_PORT, Key1_PINS, GPIO_Mode_In_PU_No_IT);//带上拉,输入
GPIO_Init(Key2_PORT, Key2_PINS, GPIO_Mode_In_PU_No_IT);//带上拉,输入
GPIO_Init(Key3_PORT, Key3_PINS, GPIO_Mode_In_PU_No_IT);//带上拉,输入
GPIO_Init(Key4_PORT, Key4_PINS, GPIO_Mode_In_PU_No_IT);//带上拉,输入
GPIO_Init(Key5_PORT, Key5_PINS, GPIO_Mode_In_PU_No_IT);//带上拉,输入


PB1-PB5量是正常的VDD电压,PD6就只有0.6V,为什么呢

toofree 发表于 2018-3-23 00:33:38

这个情况不应该呀。
PD6上电复位默认是IO功能,如果你程序没有做其它与PD6管脚上功能相关的操作的话,应该是可以上拉的。
还有就是,电路有没有问题呢,比如说有没有下拉电阻。MCU本身的上拉能力比较弱,如果外部下拉电阻较小的话,一分压,电压就降下来了。

robter 发表于 2018-4-26 12:33:18

好像PB4PB5使用比较麻烦,这个应该没问题
页: [1]
查看完整版本: STM8L152CC6的PD6口上拉为什么会失败?