24c01a的读写程序 - 免费下载

单片机编程资源 文件大小:30 K

📋 资源详细信息

文件格式
未知
所属分类
上传用户
上传时间
文件大小
30 K
所需积分
2 积分
推荐指数
⭐⭐⭐⭐⭐ (5/5)

💡 温馨提示:本资源由用户 zhou28 上传分享,仅供学习交流使用。如有侵权,请联系我们删除。

资源简介

#include <at24c01a.h>
/*******************************************
******
向24C01A写入一个字节
输入:E2ROM地址,字节数据
************************************************
******/
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();
}
/**********************************
发送开始
*****************************************/
void start(void)
{
a_scl=1;
a_sda=1;
a_sda=0;
a_scl=0;
a_scl=1;
}
/********************************************
发送停止
*******************************************/
void stop(void)
{
a_scl=0;
a_sda=0;
a_scl=1;
a_sda=1;
}
/*********************************************
发送反馈
************************************************
/
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)
}
/*************************************
*
发送无反馈
********************************************/
bit noack(void)
{
int a_ack;
a_scl=1;
a_scl=1;
a_scl=0;
}
/******************************************
*
发送
****************************************************
/
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读一个字节;
输入:EEROM地址;
输出:EEROM数据;
********************************************/
void read24c01a(uchar  counter)
{
receivebyte=0xa1;
start();
send(receivebyte);
if (!ack())
continue;
send(counter);
if (!ack())
continue;
receive()
noack();
stop();
}

立即下载此资源

提示:下载后请用压缩软件解压,推荐使用 WinRAR 或 7-Zip

资源说明

📥 下载说明

  • 下载需消耗 2积分
  • 24小时内重复下载不扣分
  • 支持断点续传
  • 资源永久有效

📦 使用说明

  • 下载后用解压软件解压
  • 推荐 WinRAR 或 7-Zip
  • 如有密码请查看说明
  • 解压后即可使用

🎁 积分获取

  • 上传资源获得积分
  • 每日签到免费领取
  • 邀请好友注册奖励
  • 查看详情 →

相关标签

点击标签查看更多相关资源:

相关资源推荐