No.59150 作者:longxiuwei 邮件:longxiuwei@126.com ID:19646 登陆:46次 文章数:33篇 最后登陆IP:221.179.17.0 最后登陆:2008/9/10 16:29:44 注册:2004/3/28 13:57:45 财富:253 发帖时间:2004/7/27 15:44:34 发贴者IP:61.150.120.202 标题:longxiuwei:我要跳楼了!!!25045的问题!急死我了!!!!! 摘要:No.59150我要跳楼了!!!25045的问题!急死我了!!!!! 我在写25045的问题!!用C语言写的!现在可以写进去了!可读出来就不一样啊!写入“0X00”时读出来是对的!可写其他的数据读出来是“0XCC”!不知道什么原因!我也延时了!可读出来不对!那位大虾看看!程序在下面!!谢谢了! #include <reg52.h> #include <intrins.h> #define Nop() _nop_() #define WREN 0x06 #define WRDI 0x04 #define RDRS 0x05 #define WRSR 0x01 #define READ0 0x03 #define READ1 0x0B #define WRITE0 0x02 #define WRITE1 0x0a sbit cs=P1^0; sbit so=P1^1; sbit sck=P1^2; sbit si=P1^3; sbit com=P1^7; unsigned char dd; void delay(unsigned int x) { while(x--) { } } /************读8位数据*************/ unsigned char Read8() { unsigned char cloop; unsigned char cData=0; for(cloop=0;cloop <8;cloop++) { sck=1; Nop(); Nop(); Nop(); Nop(); Nop(); sck=0; Nop(); Nop(); Nop(); Nop(); Nop(); cData < <=1; if(so==1) { cData=cData+1; } } sck=0; return cData; } /***********写8位数据*****************/ void Write8(unsigned char cData) { unsigned char cloop; for(cloop=0;cloop <8;cloop++) { if((cData&0x80)==0) { si=0; } else { si=1; } sck=0; sck=1; cData < <=1; } sck=0; } /***************读寄存器状态**************/ unsigned char ReadSR() { unsigned char cData; cs=0; Write8(RDRS); cData=Read8(); sck=0; cs=1; return cData; } /************写寄存器状态*************/ void Write ......
>>返回讨论的主题
|