亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

蟲蟲首頁| 資源下載| 資源專輯| 精品軟件
登錄| 注冊

您現(xiàn)在的位置是:蟲蟲下載站 > 資源下載 > 單片機編程 > 24c01a的讀寫程序

24c01a的讀寫程序

  • 資源大小:30 K
  • 上傳時間: 2013-12-23
  • 上傳用戶:zhou28
  • 資源積分:2 下載積分
  • 標(biāo)      簽: 24c01a 讀寫程序

資 源 簡 介

#include <at24c01a.h>
/*******************************************
******
向24C01A寫入一個字節(jié)
輸入:E2ROM地址,字節(jié)數(shù)據(jù)
************************************************
******/
void write24c01a(uchar uadd_1,uchar udata_1)
{
sendbyte=0xa0;
start();
send(sendbyte);
if (!ack())
continue;
send(uadd_1);
if (!ack())
continue;
send(udata_1)
if (!ack())
continue;
stop();
}
/**********************************
發(fā)送開始
*****************************************/
void start(void)
{
a_scl=1;
a_sda=1;
a_sda=0;
a_scl=0;
a_scl=1;
}
/********************************************
發(fā)送停止
*******************************************/
void stop(void)
{
a_scl=0;
a_sda=0;
a_scl=1;
a_sda=1;
}
/*********************************************
發(fā)送反饋
************************************************
/
bit ack(void)
{
int a_ack
a_scl=0;
a_scl=0;
a_scl=0;
a_scl=1;
a_ack=a_sda;
a_scl=0;
return(a_ack)
}
/*************************************
*
發(fā)送無反饋
********************************************/
bit noack(void)
{
int a_ack;
a_scl=1;
a_scl=1;
a_scl=0;
}
/******************************************
*
發(fā)送
****************************************************
/
void send(uchar  undata)
{
uchar i;
sendbyte=undata
for(i=8;i>0;i--)
{
a_sda=sendbyte7;
a_scl=0;
a_scl=1;
sendbyte=sendbyte<<1
}
}
/********************************************
接受
****************************************************
/
void   receive(void)
{
int i;
uchar data;
for(i=8;i>0;i--)
{ a_scl=1;
receivebyte7=a_sda;
a_scl=0;
receivebyte=receivebyte>>1
}
receivedata=receivebyte;
}
/*******************************************
*
向 24c01a讀一個字節(jié);
輸入:EEROM地址;
輸出:EEROM數(shù)據(jù);
********************************************/
void read24c01a(uchar  counter)
{
receivebyte=0xa1;
start();
send(receivebyte);
if (!ack())
continue;
send(counter);
if (!ack())
continue;
receive()
noack();
stop();
}

相 關(guān) 資 源

主站蜘蛛池模板: 贺州市| 肥城市| 通海县| 宁强县| 宿松县| 永宁县| 寿宁县| 离岛区| 波密县| 乐昌市| 徐汇区| 鸡泽县| 鲁甸县| 临高县| 嫩江县| 德兴市| 英山县| 安平县| 通江县| 澄城县| 汾西县| 湛江市| 绍兴县| 双流县| 塔城市| 仪征市| 大宁县| 扎赉特旗| 金湖县| 平顶山市| 信宜市| 沅江市| 来凤县| 开江县| 宜阳县| 修文县| 洛浦县| 广汉市| 大渡口区| 华池县| 临漳县|