⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 93lc66a-b.c

📁 93LC66A-B于AT89s52的读写程序。93LC66A,93LC66B是4K的EEROM.
💻 C
字号:
#include "REG52.H"
#include "INTRINS.H"
#include "ABSACC.H"
#include "MATH.H"

sbit cs=P2^7;//cs
sbit clkee=P2^6;//clk
sbit di=P2^5;//di
sbit doo=P2^4;//do
bdata unsigned char ee_sbuf;
bdata unsigned char exchange;
bdata unsigned char low8,high4;
sbit ee_sbuf_7=ee_sbuf^7;
sbit ee_sbuf_0=ee_sbuf^0;

unsigned char BB;
unsigned char ee_unit_high8;
unsigned char ee_unit_low8;
unsigned char ee_low8,ee_high8;//hight 8 and low8;

void write_ee(unsigned char adrress);
void en_write_ee(void);
void dis_write_ee(void);
main()
{








}
/*EE中某一地址中数据读出子程序*/
void read_ee(unsigned char ee_address)
{
	unsigned char i;

	cs=0;   /*P1_0->CS*/
	clkee=0;   /*P1_1->clkee*/
	di=0;   /*P1_2->DI*/
	doo=1;   /*P1_3->DO*/
	cs=1;	  /*select chip*/
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	_nop_();
	di=1;		/*送中止码,高电平*/
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	di=0;		/*送起始码,低电平*/
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	_nop_();
	_nop_();
	ee_sbuf=ee_address;
	for(i=0;i<8;i++)   /*先送EE地址(8位)*/
	{
		di=(bit)(ee_sbuf&0x80);
		_nop_();
		_nop_();
		clkee=1;
		_nop_();
		_nop_();
		clkee=0;
		ee_sbuf<<=1;
		_nop_();
	}
	_nop_();
	_nop_();
	di=0;
	_nop_();
	ee_sbuf=0;
	for(i=0;i<8;i++)	/*从EE中读出第一个字节,即高八位数据*/
	{
		ee_sbuf=ee_sbuf<<1;
		_nop_();
		clkee=1;
		_nop_();
		_nop_();
		ee_sbuf_0=doo;
		_nop_();
		clkee=0;
		_nop_();
	}
	ee_high8=ee_sbuf;
	ee_sbuf=0;
	_nop_();
	for(i=1;i<=8;i++)    /*从EE中读出第二个字节,即低八位数据*/
	{
		ee_sbuf=ee_sbuf<<1;
		_nop_();
		_nop_();
		clkee=1;
		_nop_();
		_nop_();
		ee_sbuf_0=doo;
		clkee=0;
	}
	ee_low8=ee_sbuf;
	cs=0;
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
}
void en_write_ee(void)
{
	unsigned char temp_i;

	/*
bdata   uchar ee_sbuf;
sbit    ee_sbuf_7=ee_sbuf^7; */
	cs=0;//cs
	clkee=0;//clk
	di=0;//di
	_nop_();
	_nop_();
	cs=1;
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	di=1;
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	_nop_();
	_nop_();
	di=0;
	_nop_();
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	BB=0xc0;
	di=0;
	_nop_();
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	for(temp_i=1;temp_i<=8;temp_i++)
	{
		di=(bit)(BB&0x80);
		_nop_();
		_nop_();
		_nop_();
		clkee=1;
		_nop_();
		_nop_();
		clkee=0;
		BB<<=1;

	}
	_nop_();
	_nop_();
	di=0;
	cs=0;
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
}
void write_ee(unsigned char address)
{
	unsigned char temp_i;


	/*   P1=0x0f;*/
	cs=1;
	di=1;
	clkee=1;
	cs=0;
	_nop_();
	cs=1;
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	di=1;
	_nop_();
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	di=0;
	_nop_();
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	_nop_();
	_nop_();
	_nop_();
	di=1;
	_nop_();
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	for(temp_i=1;temp_i<=8;temp_i++)
	{
		di=(bit)(address&0x80);
		_nop_();
		_nop_();
		_nop_();
		clkee=1;
		_nop_();
		_nop_();
		clkee=0;
		address<<=1;
	}
	BB=ee_unit_high8;
	for(temp_i=1;temp_i<=8;temp_i++)
	{
		di=(bit)(BB&0x80);
		_nop_();
		_nop_();
		_nop_();
		clkee=1;
		_nop_();
		_nop_();
		clkee=0;
		BB=BB<<1;
	}
	BB=ee_unit_low8;
	for(temp_i=1;temp_i<=8;temp_i++)
	{
		di=(bit)(BB&0x80);
		_nop_();
		_nop_();
		_nop_();
		clkee=1;
		_nop_();
		_nop_();
		clkee=0;
		BB=BB<<1;
	}
	_nop_();
	di=0;
	_nop_();
	cs=0;
	_nop_();
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	_nop_();
	cs=1;
	temp_i=0;
	do
	{
		clkee=1;
		_nop_();
		_nop_();
		_nop_();
		clkee=0;
		_nop_();
		_nop_();
		temp_i++;
	}
	while(temp_i<70);
	_nop_();
	_nop_();
	cs=0;
	_nop_();
	_nop_();
}
void dis_write_ee(void)
{
	unsigned char temp_c0;
	cs=0;
	clkee=0;
	di=0;
	_nop_();
	cs=1;
	_nop_();
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	_nop_();
	_nop_();
	_nop_();
	di=1;
	_nop_();
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	_nop_();
	_nop_();
	di=0;
	_nop_();
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	for(temp_c0=1;temp_c0<=9;temp_c0++)
	{
		di=0;
		_nop_();
		_nop_();
		_nop_();
		clkee=1;
		_nop_();
		_nop_();
		clkee=0;
		_nop_();
	}
	_nop_();
	di=0;
	cs=0;
	_nop_();
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
	_nop_();
	_nop_();
	_nop_();
	clkee=1;
	_nop_();
	_nop_();
	clkee=0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -