|
|
可以打開關(guān)閉內(nèi)部上拉,奇怪的是我設(shè)置開漏模式,我拿萬用表測 io口還有2V電壓,不知道什么原因,而然我上一次配置開漏模式,我拿萬用表測 io口還有0.6V電壓,為什么內(nèi)部上拉斷開不應(yīng)該是0V嗎?
#include "reg51.h"
#include "intrins.h"
sfr P3M0 = 0xb2;
sfr P3M1 = 0xb1;
sfr P5M0 = 0xca;
sfr P5M1 = 0xc9;
#define P5PU (*(unsigned char volatile xdata *)0xfe15) //P5口上拉電阻控制寄存器
#define P3PU (*(unsigned char volatile xdata *)0xfe13) //P3口上拉電阻控制寄存器
sfr P_SW2 = 0xba;
sfr P5 = 0xC8;
void main()
{
P3M0 = 0xff; //設(shè)置P3.0~P3.7為開漏模式
P3M1 = 0xff;
P5M0 = 0xff; //設(shè)置P3.0~P3.7為開漏模式
P5M1 = 0xff;
P_SW2 =0x80;
// P3PU = 0xfc;
// P5PU = 0x30;
P_SW2 =0x00;
while (1);
}
|
|