电路设计,软件开发,专业项目团队承接电子产品开发!


ISPRO下载型编程器
火爆销售中

RS232/TTL转换器
全IC串口窃电

RS232/TTL转换线
全IC串口窃电

ByteBlasterMV Cable
CPLD/FPGA并口下载线

ByteBlaster II Cable ISPRO下载型编程器
支持S51/AVR/PIC
超级51开发板套件
前卫实用超值

PC/MCU/CPLD
三合一学习套件

全新万年历方案
AVR单片机开发板
 

Min51单片机仿真机
迷你型

ARM7开发板
仅售260元!
 

RS-232/RS-485双向接口电平转换器  

51单片机升级STM32
火爆销售中
MPLAB-ICD2
火爆销售中
LED51开发板
玩具又名图文显示棒

面板模块/开发板
经济危机明智决择

       

GSM MODEM GSM猫

SMS短信模块 工业级/全自动
火爆销售中

大功率数传电台

高速数传电台

您当前位置:电子技术资料 -> 外围驱动 -> EEPROM ->

祝您阅读愉快!

ISPRO下载型编程器

RS232 TO TTL转换器
↑↑本文相关产品介绍↑↑

24C64、24c128、24C256、24C512 EEPROM测试程序


类别:技术文章
来源:未知
作者:未知
关键字:at24C256
加入日期:2010-8-3

// 24C64、24c128、24C256、24C512 EEPROM测试程序
/*中国电子网*/
/*www.ec66.com*/

#include <reg52.h>

sbit 24CXX_SCL = P1^0;
sbit 24CXX_SDA = P1^1;

sbit ACC_0 = ACC^0;
sbit ACC_1 = ACC^1;
sbit ACC_2 = ACC^2;
sbit ACC_3 = ACC^3;
sbit ACC_4 = ACC^4;
sbit ACC_5 = ACC^5;
sbit ACC_6 = ACC^6;
sbit ACC_7 = ACC^7;

// buff = 数据缓冲区
// address = EEPROM 地址
// size = 数量
char READ_24CXX(unsigned char * buff,unsigned int address,unsigned char size)
{
unsigned char a;

24CXX_SCL = 1;
24CXX_SDA = 1;
24CXX_SDA = 0;
24CXX_SCL = 0;

ACC = 0xa0;
24CXX_SDA = ACC_7;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_6;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_5;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_4;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_3;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_2;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_1;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_0;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = 1;
24CXX_SCL = 1;
if(24CXX_SDA)
return -1;
24CXX_SCL = 0;

a = address>>8;
ACC = a;
24CXX_SDA = ACC_7;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_6;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_5;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_4;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_3;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_2;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_1;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_0;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = 1;
24CXX_SCL = 1;
if(24CXX_SDA)
return -1;
24CXX_SCL = 0;

a = address;
ACC = a;

24CXX_SDA = ACC_7;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_6;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_5;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_4;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_3;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_2;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_1;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_0;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = 1;
24CXX_SCL = 1;
if(24CXX_SDA)
return -1;
24CXX_SCL = 0;

24CXX_SCL = 1;
24CXX_SDA = 1;
24CXX_SDA = 0;
24CXX_SCL = 0;

ACC = 0xa1;

24CXX_SDA = ACC_7;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_6;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_5;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_4;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_3;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_2;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_1;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_0;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = 1;
24CXX_SCL = 1;
if(24CXX_SDA)
return -1;
24CXX_SCL = 0;

for(a=0;a<size;a++)
{
24CXX_SCL = 0;
ACC_7 = 24CXX_SDA;

24CXX_SCL = 1;
24CXX_SCL = 0;
ACC_6 = 24CXX_SDA;

24CXX_SCL = 1;
24CXX_SCL = 0;
ACC_5 = 24CXX_SDA;

24CXX_SCL = 1;
24CXX_SCL = 0;
ACC_4 = 24CXX_SDA;

24CXX_SCL = 1;
24CXX_SCL = 0;
ACC_3 = 24CXX_SDA;

24CXX_SCL = 1;
24CXX_SCL = 0;
ACC_2 = 24CXX_SDA;

24CXX_SCL = 1;
24CXX_SCL = 0;
ACC_1 = 24CXX_SDA;

24CXX_SCL = 1;
24CXX_SCL = 0;
ACC_0 = 24CXX_SDA

*buff = ACC;
buff++;
24CXX_SCL = 1;
}
24CXX_SCL = 0;
24CXX_SDA = 0;
24CXX_SCL = 1;
24CXX_SDA = 1;
return 0;
}

// buff = 数据缓冲区
// address = EEPROM 地址
// size = 数量
char WRITE_24CXX(unsigned char *buff,unsigned int address,unsigned char size)
{
unsigned char a;

24CXX_SCL = 1;
24CXX_SDA = 1;
24CXX_SDA = 0;
24CXX_SCL = 0;

ACC = 0xa0;
24CXX_SDA = ACC_7;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_6;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_5;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_4;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_3;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_2;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_1;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_0;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = 1;
24CXX_SCL = 1;
if(24CXX_SDA)
return -1;
24CXX_SCL = 0;

a = address>>8;
ACC = a;
24CXX_SDA = ACC_7;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_6;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_5;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_4;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_3;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_2;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_1;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_0;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = 1;
24CXX_SCL = 1;
if(24CXX_SDA)
return -1;
24CXX_SCL = 0;

a = address;
ACC = a;

24CXX_SDA = ACC_7;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_6;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_5;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_4;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_3;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_2;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_1;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_0;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = 1;
24CXX_SCL = 1;
if(24CXX_SDA)
return -1;
24CXX_SCL = 0;

for(a=0;a<size;a++)
{
ACC = *buff;

24CXX_SDA = ACC_7;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_6;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_5;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_4;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_3;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_2;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_1;
24CXX_SCL = 1;
24CXX_SCL = 0;

24CXX_SDA = ACC_0;
24CXX_SCL = 1;
24CXX_SCL = 0;

X24CXX_SDA = 1;
X24CXX_SCL = 1;
if(24CXX_SDA)
return -1;
24CXX_SCL = 0;
buff++;
}
24CXX_SCL = 0;
24CXX_SDA = 0;
24CXX_SCL = 1;
24CXX_SDA = 1;
return 0;
}


您可能还会关注的相关技术资料:
暂无

中国电子网
www.EC66.com
QQ:34740080 EMAIL:iloveaoe@163.com
最佳浏览:1024*768
Copyright (C) 2001-2010 EC66.COM All Rights Reserved
Aoe/帝国 制作维护
粤ICP备18061901号