91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 46KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-14
  • 語言: 其他
  • 標簽: MPL3115A2??I2C??

資源簡介

C51和STC15用I2C操作MPL3115A2串口顯示,測量高度和溫度.ct1668顯示.
#include
#include
#include "ct1668.h"
#define uchar unsigned char
sbit SCL=P1^0;
sbit SDA=P1^1;

資源截圖

代碼片段和文件信息

#include?
#include?
#include?“ct1668.h“
#define?uchar?unsigned?char?
sbit?SCL=P1^0;? ?????
sbit?SDA=P1^1;?

void?Delay5us()
{
????unsigned?char?i;???//若使用12T芯片,直接寫一個空函數,實現5us延時

????_nop_();
????i?=?15;
????while?(--i);
}
void?Start()?
{
????SDA=1;
????Delay5us();
????SCL=1;
????Delay5us();
????SDA=0;
????Delay5us();
}
void?Stop()??
{
????SDA=0;
????Delay5us();
????SCL=1;
????Delay5us();
????SDA=1;
????Delay5us();
}
void?Respons()??//應答
{
????uchar?i;
????SCL=1;
????Delay5us();
????while((SDA==1)&&(i<250))i++;
????SCL=0;
????Delay5us();
}
void?Init_mpl3115()?
{
????SDA=1;
????Delay5us();
????SCL=1;
????Delay5us();
}
void?Write_Byte(uchar?date)
{
????uchar?itemp;
????temp=date;
????for(i=0;i<8;i++)
????{
????????temp=temp<<1;
????????SCL=0;
????????Delay5us();
????????SDA=CY;
????????Delay5us();
????????SCL=1;
????????Delay5us();
????}
????SCL=0;
????Delay5us();
????SDA=1;
????Delay5us();
}
uchar?Read_Byte()
{
????uchar?ik;
????SCL=0;
????Delay5us();
????SDA=1;????????
????Delay5us();
????for(i=0;i<8;i++)
????{
????????SCL=1;
????????Delay5us();
????????k=(k<<1)|SDA;
????????SCL=0;
????????Delay5us();
????}
return?k;
}
void?Write_mpl3115(uchar?addressuchar?shuju)?
{
????Start();
????Write_Byte(0xC0);????//最低位為0寫,1讀
????Respons();
????Write_Byte(address);
????Respons();
????Write_Byte(shuju);
????Respons();
????Stop();
}
uchar?Read_mpl3115(uchar?address)?
{
????uchar?date;
????Start();
????Write_Byte(0xC0);
????Respons();
????Write_Byte(address);
????Respons();

????Start();
????Write_Byte(0xC1);
????Respons();
????date=Read_Byte();
????Stop();
????return?date;
}
void?Delay1000ms() //@11.0592MHz
{
unsigned?char?i?j?k;

_nop_();
_nop_();
i?=?43;
j?=?6;
k?=?203;
do
{
do
{
while?(--k);
}?while?(--j);
}?while?(--i);
}
void?SendData(unsigned?char?dat)
{????SBUF?=?dat;????????????????????
????while?(!TI);
????TI?=?0;???????????????????

}
/*void?SendString(char?*s)
{
????while?(*s)??????????????????
????{
????????SendData(*s++);?????????
????}
}*/
void?UartInit(void) //9600bps@11.0592MHz
{
SCON?=?0x50; //8位數據可變波特率
AUXR?|=?0x01; //串口1選擇定時器2為波特率發生器
AUXR?|=?0x04; //定時器2時鐘為Fosc即1T
T2L?=?0xE0; //設定定時初值
T2H?=?0xFE; //設定定時初值
AUXR?|=?0x10; //啟動定時器2
}

void?main(void)?
{?uchar?high1high2high3temp1temp2;
UartInit();
????P1M0?=?0x00;???????
????P1M1?=?0x00;
????Init_mpl3115();??????????
Write_mpl3115(0x260xb8);
Write_mpl3115(0x130x07);
Write_mpl3115(0x260xB9);

while(1)?
????{
high1=Read_mpl3115(0x01);
high2=Read_mpl3115(0x02);
high3=Read_mpl3115(0x03);
temp1=Read_mpl3115(0x04);
temp2=Read_mpl3115(0x05);
SendData(high2);
SendData(temp1);
display(high2temp1);
Delay1000ms();

}
????}



?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2020-03-08?21:19??mpl3115a2\
?????文件????????6376??2012-06-15?10:41??mpl3115a2\STARTUP.A51
?????文件???????14049??2020-03-08?16:38??mpl3115a2\STARTUP.LST
?????文件?????????749??2020-03-08?16:38??mpl3115a2\STARTUP.OBJ
?????文件????????2276??2020-03-08?21:17??mpl3115a2\ct1668.h
?????文件???????15974??2020-03-08?21:17??mpl3115a2\mpl
?????文件???????18893??2020-03-08?21:17??mpl3115a2\mpl.M51
?????文件????????2013??2020-03-08?21:17??mpl3115a2\mpl.hex
?????文件??????????58??2020-03-08?21:17??mpl3115a2\mpl.lnp
?????文件????????2011??2020-03-08?21:19??mpl3115a2\mpl.plg
?????文件???????68529??2020-03-08?21:19??mpl3115a2\mpl.uvgui.Administrator
?????文件???????68526??2020-03-08?21:11??mpl3115a2\mpl.uvgui_Administrator.bak
?????文件????????5318??2020-03-08?21:19??mpl3115a2\mpl.uvopt
?????文件???????13529??2020-03-08?21:11??mpl3115a2\mpl.uvproj
?????文件????????6668??2020-03-08?21:17??mpl3115a2\mpl3115.LST
?????文件???????17273??2020-03-08?21:17??mpl3115a2\mpl3115.OBJ
?????文件??????????46??2020-03-08?21:17??mpl3115a2\mpl3115.__i
?????文件????????2977??2020-03-08?21:17??mpl3115a2\mpl3115.c
?????文件????????5319??2020-03-08?21:11??mpl3115a2\mpl_uvopt.bak
?????文件???????13361??2020-03-08?18:26??mpl3115a2\mpl_uvproj.bak

評論

共有 條評論