|
15W4K32S4单片机P44口初始化为低电平,但是实际测量管脚仍然是高电平,想不明白,请教各位大佬。下面贴上程序:
#include <INTRINS.H>
#include <STC15.H>
//IO定义
sbit Buzzer =P5^4; //蜂鸣器,低电平驱动
sbit wifi_reset =P2^7; //wifi复位,高电平驱动
sbit power_touch =P4^7; //电源触摸按键
sbit power_sw =P1^2; //电源软关机,高电平关机
sbit p_en =P1^5; //电源稳压使能,高电平驱动
sbit p_save =P1^4; //电源稳压节能模式,高电平驱动
sbit red =P4^4; //红色LED,低电平驱动
sbit blu =P4^3; //蓝色LED,低电平驱动
sbit sw =P5^3; //升压电路开关,低电平驱动
sbit SCL =P0^6; //I2C时钟线
sbit SDA =P0^7; //I2C数据线
sbit SCLK =P2^1; //SPI时钟线
sbit MISO =P2^2; //SPI主机接收线
sbit MOSI =P2^3; //SPI主机发送线
sbit ESP8266 =P4^4; //WIFI电源开关,低电平驱动
sbit NRF24L01 =P2^6; //NRF24L01电源开关,低电平驱动
sbit KEY_E =P3^7; //五向按键东
sbit KEY_N =P3^2; //五向按键北
sbit KEY_W =P3^4; //五向按键西
sbit KEY_S =P3^6; //五向按键南
sbit KEY_ENTER =P3^3; //五向按键中
unsigned int i;
//定时器0设置
void Timer0Init(void) //1毫秒@22.1184MHz
{
AUXR |= 0x80; //定时器时钟1T模式
TMOD &= 0xF0; //设置定时器模式
TL0 = 0x9A; //设置定时初值
TH0 = 0xA9; //设置定时初值
TF0 = 0; //清除TF0标志
TR0 = 1; //定时器0开始计时
}
//定时器0中断函数
void Timer0(void) interrupt 1
{
if(i>=1000)
{blu=~blu;
//red=~red;
i=0;
}
else
{i++;}
}
/*****主函数*********/
void main(void)
{
P0M1 = 0; P0M0 = 0; //设置P0为弱上拉
P1M1 = 0; P1M0 = 0; //设置P1为弱上拉
P2M1 = 0; P2M0 = 0; //设置P2为弱上拉
P3M1 = 0; P3M0 = 0; //设置P3为弱上拉
P4M1 = 0; P4M0 = 0; //设置P4为弱上拉
P5M1 = 0; P5M0 = 0; //设置P5为弱上拉
wifi_reset =0; //wifi复位,高电平驱动
power_touch =1; //电源触摸按键
power_sw =0; //电源软关机,高电平关机
p_en =1; //电源稳压使能,高电平驱动
p_save =1; //电源稳压节能模式,高电平驱动
red =0; //红色LED,低电平驱动
blu =0; //蓝色LED,低电平驱动
sw =0; //升压电路开关,低电平驱动
SCL =1; //I2C时钟线
SDA =1; //I2C数据线
SCLK =1; //SPI时钟线
MISO =1; //SPI主机接收线
MOSI =1; //SPI主机发送线
ESP8266 =1; //WIFI电源开关,低电平驱动
NRF24L01 =1; //NRF24L01电源开关,低电平驱动
KEY_E =1; //五向按键东
KEY_N =1; //五向按键北
KEY_W =1; //五向按键西
KEY_S =1; //五向按键南
KEY_ENTER =1; //五向按键中
Timer0Init();
ET0 =1;
EA =1;
while(1)
{
}
}
|
|