/*MCU=C8051F310
程序测试:下面程序的运行后FLAG0,FLAG1,FLAG2,data0,data1,data2的结果你能简单地确定吗?
在循环程序中,第一个循环运行的结果和第二个循环运行的结果相同吗?
P1 = B0; indata = P1; 运行后indata = B0吗?为什么?
*/
#include "C8051F310.h"
#define B0 0x71
#define B1 0xe2
#define B2 0xd3
sbit P10 = P1^0;
sbit P11 = P1^1;
sbit P12 = P1^2;
unsigned char FLAG0,FLAG1,FLAG2;
unsigned char data0,data1,data2;
unsigned char indata;
void main (void)
{
P1MDOUT = 0xFF;
P0SKIP = 0x01;
XBR0 = 0x01;
XBR1 = 0xC0;
P10 = 0;
while(1)
{
P1 = B0;
indata = P1;
if(P1 != B0)
{
FLAG0 = 1;
}
else
{
FLAG0 = 2;
}
data0 = P1;
P1 = B1;
if(P1 != B1)
{
FLAG1 = 1;
}
else
{
FLAG1 = 2;
}
data1 = P1;
P1 = B2;
if(P1 != B2)
{
FLAG2 = 1;
}
else
{
FLAG2 = 2;
}
data2 = P1;
}
}
文章评论(0条评论)
登录后参与讨论