阅读:7690回复:39
100分请教u盘flash闪存读写问题!
正在做u盘,对三星flash读写操作遇到困惑,不知谁做过u盘的,能否给处读写子程序?(100分)
|
|
最新喜欢:chinak... |
沙发#
发布于:2003-07-30 01:00
我说的片选是指A15、A14合成后作为rd、wr片选的合成,因为平时mcu的wr和rd有很多的信号,这样flash能收到正确的读写信号吗!
这个电路我以前用过的,肯定不会有错的! |
|
板凳#
发布于:2003-07-29 19:18
我的cpu是没法改了,想知道为什么要用RD、WR与片选信号相或之后再与flash的RE、WE相连呢?这样是总线方式吗?另外我想知道是怎么解决5v和3.3v之间的逻辑电平转换问题。听说用74LVC245还是哪个芯片,谁能说说看
|
|
地板#
发布于:2003-07-29 02:48
你的电路的确有错!你应该用一个io pin控制/CS,将/wr、/rd与A15、A14合成后的/ce相或再分别去控制flash的/wr、/rd!
P?.? -> flash /CE P?.? -> flash ALE P?.? -> flash CLE P?.? -> flash R/B MCU /RD -> \"+\" | -> FLASH /RE MCU /WR -> \"+\" | -> FLASH /WE MCU ADDR A15/A14 + 另外现在大家都用3.3V的mcu,所以没有这方面的问题! |
|
地下室#
发布于:2003-07-28 19:44
我的MCU用的是89c55,所以好不容易找到一个电压为5v的flash,如果用容量大一点的电压都是3.3v的,电平匹配(5v <---> 3.3v)是个难题,不知诸位是怎么解决的?
|
|
5楼#
发布于:2003-07-28 19:40
现在已经可以实现RAM中的u盘了!
可惜闪存读写还是不行,郁闷呢!关键是flash地址不知道是怎么确定的(总线方式),如果用I/O口方式的话,延时是怎么控制的?还有就是对P0口赋值是总是无效,P0口总为低电平。 |
|
6楼#
发布于:2003-07-20 12:43
你用的是老的型号,其新的是K9F3208W0A,有改进。但似乎也快停产了。还是用容量大点的吧,K9F6408U0C,价钱还要便宜。只是要注意08是3-5V的,其他的是低电压的3.3V或更低。
|
|
7楼#
发布于:2003-07-20 02:12
0x???? -> read/write
P?.? -> flash /CE P?.? -> flash ALE P?.? -> flash CLE P?.? -> flash R/B MCU /RD -> \"+\" | -> FLASH /RE MCU /WR -> \"+\" | -> FLASH /WE MCU ADDR A15/A14 + :) |
|
8楼#
发布于:2003-07-19 12:06
s_7710:
能给出你的flash-mcu连接电路图吗?我实在是没办法了!唉! |
|
9楼#
发布于:2003-07-19 10:59
s_7710: 因为我用的是 8Mbyte 的 Flash,所以可以从P2.7加个非门接到Flash 的 /CE。其实你的电路图只要加一个二输入与门就可以啦, 输入端: I/O(P3.5) 口和 Flash 的片选线 输出端: Flash的/CE 在读写Flash时 P3.5 为低,其它操作时必须为高! |
|
10楼#
发布于:2003-07-18 23:36
我现在已经把CE直接接到P3.5上,读写操作时是一直选通的。可是写的数据,读出来有些是对的,有些是错误的。写的时候,是写528个字节,还是512个字节呢?后面16个字节有什么特殊功能?我现在还搞不清楚。 你搜索一下我以前回的帖子,里面有讲过这16字节的含义和用法! |
|
11楼#
发布于:2003-07-18 22:50
已经给s_7710 和 NewTech 各加50分,希望以后多多帮忙!
|
|
12楼#
发布于:2003-07-18 22:46
s_7710:
你的ce怎么没有选通呢,是不是接地了? 还有你的地址[0x8000]是怎么确定的? |
|
13楼#
发布于:2003-07-17 20:04
可能是你的程序有问题,看看下面的程序,希望能对你有所帮助!
若你要对Block进行写之前,必须要擦除该Block! ############################ //===============================SMC_READ_LSA_LEN===========================================// void SMC_Read_LSA_Len(U16 PSA,U16 startoffset,U16 len) { U16 count; Command_Latch_Enabled; //CLE=1 if(startoffset<256) { IOregister_Write(0x8000,0x00); //read \"A\" area command } else if(startoffset<512) { IOregister_Write(0x8000,0x01); //read \"B\" area command startoffset=startoffset-256; } else if(startoffset<528) { IOregister_Write(0x8000,0x50); //read \"C\" area command startoffset=startoffset-512; } Command_Latch_Disabled; //CLE=0 Address_Latch_Enabled; //ALE=1 //send address IOregister_Write(0x8000,(BYTE)(startoffset&0xff)); IOregister_Write(0x8000,(BYTE)(PSA&0xff)); IOregister_Write(0x8000,(BYTE)((PSA>>8)&0xff)); Address_Latch_Disabled; //ALE=0 while (); //wait flash memory ready //read data from flash memory for(count=0;count<len;count++) {dataBuf[count]=XBYTE[0x8000];} //end read flash data } //=========================SMC_Write_LSA_Len==================================// void SMC_Write_LSA_Len(U16 PSA,U16 startoffset,U16 len) { U16 count; U8 state; Command_Latch_Enabled; //CLE=1 if(startoffset<256) { IOregister_Write(0x8000,0x50); // program \"A\" area IOregister_Write(0x8000,0x00); } else if(startoffset<512) { IOregister_Write(0x8000,0x00); // program \"B\" area IOregister_Write(0x8000,0x01); startoffset=startoffset-256; } else if(startoffset<528) { IOregister_Write(0x8000,0x00); // program \"C\" area IOregister_Write(0x8000,0x50); startoffset=startoffset-512; } IOregister_Write(0x8000,0x80); Command_Latch_Disabled; //CLE=0 //address Address_Latch_Enabled; //ALE=1 IOregister_Write(0x8000,(BYTE)startoffset); IOregister_Write(0x8000,(BYTE)(PSA&0xff)); IOregister_Write(0x8000,(BYTE)((PSA>>8)&0xff)); Address_Latch_Disabled; //ALE=0 //write data for(count=0;count<len;count++) {IOregister_Write(0x8000,dataBuf[count]);} //here must add \"{}\" because IOregister_Write is defined Command_Latch_Enabled; //CLE=1 IOregister_Write(0x8000,0x10); //write page program command 0x10 while (Ready==0); //wait SMC not busy IOregister_Write(0x8000,0x70); //write read status command 0x70 Command_Latch_Disabled; //CLE=0 state= XBYTE[0x8000]; //read status //end write data } //=========================SMC_Erase_One_Block_PSA(PSA)=============================// bit SMC_Erase_One_Block(U16 PSA) {U8 state; Command_Latch_Enabled; //CLE=1 IOregister_Write(0x8000,0x60); //erase command=0x60 Command_Latch_Disabled; //CLE=0 //address Address_Latch_Enabled; //ALE=1 IOregister_Write(0x8000,(BYTE)(PSA&0xff)); IOregister_Write(0x8000,(BYTE)((PSA>>8)&0xff)); Address_Latch_Disabled; //ALE=0 Command_Latch_Enabled; //CLE=1 IOregister_Write(0x8000,0xd0); //erase command Command_Latch_Disabled; //CLE=0 while(Ready==0); Command_Latch_Enabled; //CLE=1 IOregister_Write(0x8000,0x70); //read state Command_Latch_Disabled; //CLE=0 state=XBYTE[0x8000]; //status output if(state&0x01) { return (state & 0x01); } } |
|
14楼#
发布于:2003-07-17 17:38
我现在已经把CE直接接到P3.5上,读写操作时是一直选通的。可是写的数据,读出来有些是对的,有些是错误的。写的时候,是写528个字节,还是512个字节呢?后面16个字节有什么特殊功能?我现在还搞不清楚。
|
|
15楼#
发布于:2003-07-15 08:24
SM_CMD=1;
KM29WDATA=0xd0;在读、写时 CS 为低电平 SM_CMD=0; while(SM_RDY==0);读Ready信号时,CS是高电平。 SM_CMD=1; KM29WDATA=0x70;在读、写时 CS 为低电平 SM_CMD=0; 因为你是用地址译码的方式来读写Nand Flash,所以只有在你对该地址进行操作时 CS 才会是低电平,其它情况都会为高!把 CS 用 IO口来选,应该就会 OK !还要注意,在初始化 MCU 时必须把Nand Flash的 ALE、CLE pin清零才能保证正确! |
|
16楼#
发布于:2003-07-14 23:46
其实就是小于8M时,不论读写都要求cs始终为低电平,但是其他的就可以在需要的时候为低就行了!
|
|
17楼#
发布于:2003-07-14 20:33
s_7710:
能详细说一下两者的区别吗? |
|
18楼#
发布于:2003-07-14 20:32
不是很明白,cs不是一直都是低电平吗?
|
|
19楼#
发布于:2003-07-14 19:28
KM29W32000AT 在读、写、擦除时,要求 R/B 为低时 CS 信号必须为低,否则就会出错。但 Nand Flash 的容量大于或等于 8Mbyte 时就不存在这个问题,具体你可以把它们的时序仔细对比一下就知道啦!这是我刚刚做完的,用w77e32一次写7片Nand Flash!
|
|
上一页
下一页