{

SDA =1; //sda=1

}

else

{

SDA =0; //sda=0

}

temp /=2;

iic_delay();

SCL =1;

iic_delay();

SCL =0;

iic_delay();

}

}

void iic_start(void)

{

SDA =1;

SCL =1;

WP =0;

iic_delay();

SDA =0;

iic_delay();

SCL =0;

}

void iic_stop(void)

{

SDA =0;

SCL =1;

iic_delay();

SDA =1;

//WP =1;

}

void iic_ack(void)

{

ack_flag =0x00; //ack_flag等于0x00时有应答

SDA =1;

iic_delay();

SCL =1;

iic_delay();

if(SDA)

{

ack_flag =0x01;

}

SCL =0;

}

void iic_delay(void)

{

_nop_();

_nop_();

_nop_();

_nop_();

}

void iic_delay10ms(void)

{

#pragma ASM

mov r6,#200

mov r7,#10

delay:

nop

nop

nop

djnz r6,delay

mov r6,#200

djnz r7,delay

#pragma ENDASM

}

void initial(void)

{

TMOD =0x21;

TH1 =0xfd;

TL1 =0xfd;

TH0 =0xfd;

TL0 =0xfd;

SCON =0x50;

TR1 =1;

EA =1;

ES =1;

ET0 =1;

PT0 =1;

}

void ok(void)

{

ACC =0x55;

SBUF =ACC;

while(!TI);

TI =0;

ACC =0xaa;

SBUF =ACC;

while(!TI);

TI =0;

}

void error(void)

{

ACC =0xaa;

SBUF =ACC;

while(!TI);

TI =0;

ACC =0x55;

SBUF =ACC;

while(!TI);

TI =0;

rw =0x55;

}

void es_int(void)interrupt 4

{

uchar i;

RI =0;

type =SBUF; //型号

while(!RI);

RI =0;

device_addr =SBUF; //器件地址

for(i=0;i《3;i++)

{

while(!RI);

RI =0;

addr[2-i] =SBUF; //地址高、中、低位字节

  • UC3846控制芯片工作原理控制图 逆变焊机原理与用途
  • 数字万用表电阻档测试二极管正反向没有阻值(使用万用表测量二极管的正向电阻,为什么各档)
  • 学单片机需要学数电模电吗(学单片机要先学数电模电吗)
  • 电工怎么选择适合自己用的万用表(电工初学者买什么样的万用表好)
  • 单片机需要同时运行多个任务怎么办(单片机怎么同时执行多个任务)
  • 电机保护的方案取决于负载的机械特性
  • 绝缘电阻表正负搭接不复零位是怎么回事
  • 短路怎么用万用表查