打印

各位大哥sst29sf040当数据存储器的时候有限制吗?

[复制链接]
1694|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ccjchen|  楼主 | 2007-9-14 09:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我在使用flash  sst29sf040作为数据存储器时,好像得要首先声明unsigned char data型的数组,然后才能一个一个写到sst29sf040内部,也就是AT89C52要消耗掉同样多的数据空间,才能将数据写进sst29sf040,难道必须这样吗?这样不还是会消耗AT89C52的程序空间,等于没有外扩ram吗?下面是我的程序
#define _SST_C_
#include "reg51.h"
#include "sst.h"
#include <intrins.h>
#include <absacc.h>

#define FALSE             0
#define TRUE              1

#define SECTOR_SIZE          128       /*Must be 128 bytes for 29EE020*/

#define SST_ID            0xBF
#define SST_29SF040       0X13
#define uchar             unsigned char 
#define uint              unsigned int     
uchar data buff[5]={0x4e,0xae,0x89 ,0x39,0x43};

void  wait(uchar p,uchar q);
void  ByteProgram(uchar SrcByte,uint Dst);
int   Erase_One_Sector(uint Dst);
uchar ByteRead(uint addr);
void main()
{
    uchar i;
    Erase_One_Sector(0);
        
         for (i=0;i<128;i++)
    {  
        if(i<5)
        {
            ByteProgram(buff,0x0000+i);
        }
         else
             ByteProgram(i,0x0000+i);
    }
    Erase_One_Sector(128);    
    for (i=0;i<128;i++)
    {  
        if(i<5)
        {
            ByteProgram(buff,0x0080+i);
        }
         else
             ByteProgram(0x80+i,0x0080+i);
    }
    
}

void  ByteProgram(uchar data SrcByte,uint Dst)
{
    XBYTE[0x0555] = 0xAA;
    XBYTE[0x02AA] = 0x55;
    XBYTE[0x0555] = 0xA0;
    XBYTE[Dst]   = SrcByte;
    //Check_Toggle_Ready(Dst);
    wait(1,9);//等待25us
}
int Erase_One_Sector(uint Dst)
{

        /*  Issue the Sector Erase command to 39SF040   */

        XBYTE[0x0555] = 0xAA; /* set up address to be 555h    */
                             /* write data 0xAA to the address     */
        XBYTE[0x02AA] = 0x55; /* set up address to be 2AAh    */
                             /* write data 0x55 to the address     */
        XBYTE[0x0555] = 0x80; /* set up address to be 555h    */
                             /* write data 0x80 to the address     */
        XBYTE[0x0555] = 0xAA; /* set up address to be 555h    */
                             /* write data 0xAA to the address     */
        XBYTE[0x02AA] = 0x55; /* set up address to be 2AAh    */
                             /* write data 0x55 to the address     */
        XBYTE[Dst]   = 0x20; /* set up starting address to be erased */
                             /* write data 0x30 to the address     */
        wait(85,134);        /* check DATABOOK for the most  */
                             /* accurate value -- Tse        */
}

uchar ByteRead(uint addr)
{
    uchar GetData;
    GetData = XBYTE[addr];
    return(GetData);
}
void  wait(uchar p,uchar q)
{
   uchar  i,j;                //(2*j+3)*i+4
 for (i=p;i>0;i--)

         for (j=q;j>0;j--);
}

相关帖子

沙发
xwj| | 2007-9-14 10:07 | 只看该作者

FLASH都只能按扇区写,

要改一个字节必须先读1扇区,修改缓存,再回写扇区


任何程序都要消耗程序空间和RAM的

你的逻辑很混乱,不知道你到底指什么

使用特权

评论回复
板凳
qjy_dali| | 2007-9-14 10:52 | 只看该作者

你外扩的存贮器还是要映射到89C52的空间的,自然要占

只是没占89C52内部的FLASH和SRAM而已

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

175

主题

446

帖子

1

粉丝