欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

资源详细信息

文件格式
压缩包
文件大小
30 K
资源分类
上传者
发布时间
下载统计
103
所需积分
2 积分

24c01a的读写程序 - 资源详细说明

#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();
}

立即下载 24c01a的读写程序

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

下载说明与使用指南

下载说明

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

使用说明

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

积分获取方式

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

相关技术标签

点击标签浏览更多相关单片机编程资源:

相关单片机编程资源推荐