当前位置:首页 >> 信息与通信 >>

93c46读写程序


“93c46 读写程序” #include <reg52.h> sbit CS=P2^7; sbit SK=P2^6; sbit DI=P2^5; sbit DO=P2^4; /* extern unsigned char ReadChar(unsigned char address); extern void WriteChar(unsigned char address,unsigned char InData); extern void ReadString(unsigned char data *RamAddress,unsigned char RomAddress, unsigned char Number); extern void WriteString(unsigned char data *RamAddress,unsigned char RomAddress, unsigned char Number); */ // Write enable must precede all programming modes. void Ewen(void) { unsigned char temp,InData; CS=0; SK=0; CS=1; InData=0x98; // 10011XXXX for(temp=9;temp!=0;temp--) { // 9 DI=InData&0x80; SK=1; SK=0; InData<<=1; } CS=0; } // Disables all programming instructions. void Ewds(void) { unsigned char temp,InData; CS=0; SK=0; CS=1; InData=0x80; // 10000XXXX for(temp=9;temp!=0;temp--) { // 9 DI=InData&0x80; SK=1; SK=0; InData<<=1; } CS=0; } // Reads data stored in memory, at specified address. unsigned int Read(unsigned char address) { unsigned char temp; unsigned int result; Ewen(); SK=0; DI=1; // 110 A5-A0 CS=0; CS=1; SK=1; SK=0; // 1 address=address&0x3f|0x80; for(temp=8;temp!=0;temp--) { // 8 DI=address&0x80; SK=1; SK=0; address<<=1;

} DO=1; for(temp=16;temp!=0;temp--) { // 16 SK=1; result=(result<<1)|DO; SK=0; } CS=0; Ewds(); return(result); } // Writes memory location An - A0. void Write(unsigned char address,unsigned int InData) { unsigned char temp; Ewen(); SK=0; DI=1; // 101 A5-A0 CS=0; CS=1; SK=1; SK=0; // 1 address=address&0x3f|0x40; for(temp=8;temp!=0;temp--) { // 8 DI=address&0x80; SK=1; SK=0; address<<=1; } for(temp=16;temp!=0;temp--) { // 16 DI=InData&0x8000; SK=1; SK=0; InData<<=1; } CS=0; DO=1; CS=1; SK=1; while(DO==0) { // busy test SK=0; SK=1; } SK=0; CS=0; Ewds(); } /* // Erase memory location An - A0. void Erase(unsigned char address) { unsigned char temp; Ewen(); SK=0; DI=1; // 111 A5-A0 CS=0; CS=1; SK=1; SK=0; address|=0xc0; for(temp=8;temp!=0;temp--) { // 8 DI=address&0x80; SK=1; SK=0; address<<=1; } CS=0; DO=1; CS=1; SK=1; while(DO==0) { SK=0; SK=1; } SK=0; CS=0;

// 1

Ewds(); } // Erases all memory locations. Valid only at VCC = 4.5V to 5.5V. void Eral(void) { unsigned char temp,InData; Ewen(); CS=0; SK=0; CS=1; InData=0x90; // 10010XXXX for(temp=9;temp!=0;temp--) { // 9 DI=InData&0x80; SK=1; SK=0; InData<<=1; } CS=0; DO=1; CS=1; SK=1; while(DO==0) { SK=0; SK=1; } SK=0; CS=0; Ewds(); } // Writes all memory locations. Valid only at VCC = 4.5V to 5.5V. void Wral(unsigned int InData) { unsigned char temp,address; Ewen(); CS=0; SK=0; CS=1; address=0x88; // 10001XXXX for(temp=9;temp!=0;temp--) { // 9 DI=address&0x80; SK=1; SK=0; address<<=1; } for(temp=16;temp!=0;temp--) { // 16 DI=InData&0x8000; SK=1; SK=0; InData<<=1; } CS=0; DO=1; CS=1; SK=1; while(DO==0) { SK=0; SK=1; } SK=0; CS=0; Ewds(); } */ unsigned char ReadChar(unsigned char address) { unsigned char temp=address>>1; if(address&0x01) return((unsigned char)(Read(temp)>>8)); else return((unsigned char)(Read(temp))); }

void WriteChar(unsigned char address,unsigned char InData) { unsigned char temp=address>>1; if(address&0x01) Write(temp,(unsigned int)(Read(temp)&0x00ff|(InData<<8))); else Write(temp,(unsigned int)(Read(temp)&0xff00|InData)); } void ReadString(unsigned char data *RamAddress,unsigned char RomAddress, unsigned char Number) { while(Number!=0) { *RamAddress=ReadChar(RomAddress); RamAddress++; RomAddress++; Number--; } } void WriteString(unsigned char data *RamAddress,unsigned char RomAddress, unsigned char Number) { unsigned int temp; if(Number==0) return; if(RomAddress&0x01) { WriteChar(RomAddress,*RamAddress); RamAddress++; RomAddress++; Number--; } if(Number==0) return; while(Number>>1) { temp=*RamAddress; RamAddress++; temp=temp|(*RamAddress)<<8; RamAddress++; Write(RomAddress>>1,temp); RomAddress++; RomAddress++; Number--; Number--; } if(Number) WriteChar(RomAddress,*RamAddress);


相关文章:
关于调试93C46的读写出现的问题
关于调试93C46读写出现的问题_电子/电路_工程科技_专业资料。93C46 为容量 ...终于在 93C46 的规格书中发现这么一个参数 对应时序图红色方框的部分 于是报着...
93c46读写原C程序
93c46读写原C程序_信息与通信_工程科技_专业资料。93c46读写原C程序 /*93c46 读写程序*/ #include <reg52.h> //定义 I/O sbit CS=P1^0; sbit SK...
AT93C46的汇编读写软件程序
AT93C46的汇编读写软件程序_信息与通信_工程科技_专业资料。AT93C46的汇编读写软件程序AT93C46/56/57/66 EEPROM 芯片示例模块程序 [日期:2010-09-08 ] [来源...
93C46演示程序(SPI总线接口)
93C46 为串行三线 SPI 操作芯 片,在时钟时序的同步下接收数据口的指令。指令码为 9 位十进制码,具有 7 个指令,读、 擦写使能、擦除、写、全擦、全写及擦...
基于SPI总线的EEPROM读写实验
基于SPI 总线的 EEPROM 读写实验 一、实验目的 1 熟悉 AT93C46 的芯片功能。 2 掌握采用单片机和 AT93C46 的硬件接口技术。 3 掌握 AT93C46读写程序的...
程序
程序功能:对 EEPROM 进行读写测试 ---说 明:AT24C02 是 256Byte...AT93C46 串行 EEPROM 读写例程 MSP430 与 AT93C46 串行 EEPROM 读写例程 DC,2006-09-...
[QL200]软件模拟93LC46B读写程序[PIC16F877A+汇编]
[QL200]软件模拟93LC46B读写程序[PIC16F877A+汇编]_计算机软件及应用_IT/计算机...;4.本电路所使用 93C46 为 ATMEL 或 MICROCHIP 的,或不是该厂的,则烧写...
单片机C语言小程序
单片机C语言小程序_信息与通信_工程科技_专业资料。单片机C语言小程序单片机...93c46 读取的识别码 READ=0*/ /*93c46 写入的识别码 WRITE=2*/ /*93C46...
93c66与spi驱动程序
{ unsigned char idata n=8; // 从 MISO 线上读取一上数据字节,共八位 ...(tdata); 93C46/93c06/93c56/93c66/93c86 的驱动程序(C51) 时间:2007-04...
接触式IC卡读写器使用手册
AT93C46/93C46A 函数库 f. SLE4404 函数库 g. SLE4406 函数库 h. SLE...系列读写器驱动程序 C.DOS 静态函数库 FOXPRO FOR DOS 接口函数库 WINDOWS32 ...
更多相关标签: