|
爱科技、爱创意、爱折腾、爱极致,我们都是技术控
您需要 登录 才可以下载或查看,没有账号?立即注册
x
受硬件或走线限制,有些IO不连续,操作不便。因此做个程序
注意,通过debug,实际上仍是位操作,比真正的P1 = 0x0f慢得多,不是万不得已,不要用
#include<reg51.h>
sbit port0= P0^0;
sbit port1= P0^1;
sbit port2= P1^0;
sbit port3= P1^1;
sbit port4= P2^0;
sbit port5= P2^1;
sbit port6= P3^0;
sbit port7= P3^1;
void newIo(unsigned char da)
{
port0 = (bit)(da&0x01);
port1 = (bit)(da&0x02);
port2 = (bit)(da&0x04);
port3 = (bit)(da&0x08);
port4 = (bit)(da&0x10);
port5 = (bit)(da&0x20);
port6 = (bit)(da&0x40);
port7 = (bit)(da&0x80);
}
void main ()
{
newIo(0x02) ;
}
|
|