//20200530_tm1651_pfc161测试02
#include "extern.h"
tm1651_clk bit pb.0; //tm1651时钟输入
tm1651_dio bit pb.7; //tm1651数据输入输出
void tm1651_yanshi(); //tm1651延时
byte tm1651_a1;
/**************************************************/
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/4 // SYSCLK=IHRC/4
/**************************************************/ //start起始
$ tm1651_clk out; $ tm1651_dio out;
tm1651_clk =1;
tm1651_dio =1;
tm1651_yanshi();
tm1651_dio =0;
tm1651_yanshi();
/**************************************************/ //data数据
tm1651_a1 =0b1000_1011;
tm1651_clk =0; tm1651_yanshi();
if(tm1651_a1.0) {tm1651_dio =1;} else{tm1651_dio =0;} //bit0(先发低)
tm1651_clk =1; tm1651_yanshi();
tm1651_clk =0; tm1651_yanshi();
if(tm1651_a1.1) {tm1651_dio =1;} else{tm1651_dio =0;}
tm1651_clk =1; tm1651_yanshi();
tm1651_clk =0; tm1651_yanshi();
if(tm1651_a1.2) {tm1651_dio =1;} else{tm1651_dio =0;}
tm1651_clk =1; tm1651_yanshi();
tm1651_clk =0; tm1651_yanshi();
if(tm1651_a1.3) {tm1651_dio =1;} else{tm1651_dio =0;}
tm1651_clk =1; tm1651_yanshi();
tm1651_clk =0; tm1651_yanshi();
if(tm1651_a1.4) {tm1651_dio =1;} else{tm1651_dio =0;}
tm1651_clk =1; tm1651_yanshi();
tm1651_clk =0; tm1651_yanshi();
if(tm1651_a1.5) {tm1651_dio =1;} else{tm1651_dio =0;}
tm1651_clk =1; tm1651_yanshi();
tm1651_clk =0; tm1651_yanshi();
if(tm1651_a1.6) {tm1651_dio =1;} else{tm1651_dio =0;}
tm1651_clk =1; tm1651_yanshi();
tm1651_clk =0; tm1651_yanshi();
if(tm1651_a1.7) {tm1651_dio =1;} else{tm1651_dio =0;}
tm1651_clk =1; tm1651_yanshi();
/**************************************************/ //ack应答
$ tm1651_clk out; $ tm1651_dio in,pull;
tm1651_clk =0; tm1651_yanshi(); //第八个时钟的下降沿
tm1651_clk =1; tm1651_yanshi();
while(tm1651_dio==0){nop;} //ack
/**************************************************/
while (1)
{
}
}
/**************************************************/
void tm1651_yanshi() //tm1651延时
{
.delay 5000;
}
/**************************************************/
|