音影先锋亚洲天堂网|电影世界尽头的爱完整版播放|国产 熟女 91|高清无码免费观看欧美日韩|韩国一区二区三区黄色录像|美女亚洲加勒比在线|亚洲综合网 开心五月|7x成人在线入口|成人网站免费日韩毛片区|国产黄片?一级?二级?三级

登錄 免費(fèi)注冊 首頁 | 行業(yè)黑名單 | 幫助
維庫電子市場網(wǎng)
技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng)
驅(qū)動編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計 | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe

請指點(diǎn)一下,關(guān)于at45db041b的讀寫

作者:delay 欄目:單片機(jī)
請指點(diǎn)一下,關(guān)于AT45DB041B的讀寫
關(guān)于main MEMORY page program through buffer
void FLASHAutoProgViaBuffer1(uchar *buffer,uint len,uint page,uint start_addr) //將指定數(shù)據(jù)通過緩存1寫入FLASH指定位置(先擦除)
{
           uint  i;
        uchar idata get;
         SPI45D041_SK=0;  
         SPI45D041_CS=0;
                          //緩沖區(qū)1為84H  緩沖區(qū)2為87H
       WriteByte(0x82,8);
       WriteByte(0x00,3);// fill 3 sk,don\'t care.
       WriteByte( (uchar)(page>>8) , 4 );//send 12 bit address to 45D081
       WriteByte( (uchar)(page) , 8 );
       WriteByte((start_addr>>8) , 1 );
       WriteByte(start_addr,8 );//fill 8 bits blank
           for (i=0;i<len;i++)
         {         
             WriteByte(buffer[i],8);
          }
       SPI45D041_CS=1;
         get=GetFLASHStatus();// check if FLASH is busy//
       while(!(get&0x80)) ;
      
}



請幫忙看一下,這個函數(shù)對嗎?為什么再程序中不走呢?謝謝!
  





2樓: >>參與討論
cywiner
這是我的一個代碼
希望能對你有用,這個代碼在keil中編譯,在硬件中測試通過,但沒有在市場上使用。

//memory.c
//編寫一個對at45d系列操作的庫,大模式編譯
//說明每個指令時間為1us時調(diào)試通過
//
//為了在投幣式加油機(jī)項(xiàng)目的需要,編寫該庫函數(shù)。
//20040610完成該庫的編寫
//cywiner

#include <intrins.h>
#include <REG51F.H>
#include <string.h>

#define CLOCK_FRIQUENCY    12000000L
#define OPT_CYC            1                //單指令時間為 1 us
#define MEM_PAGESIZE    264
#define MEM_BLOCKPAGE    8
#define MEM_BLOCKNUM    256        //AT45D041
//#define MEM_BLOCKNUM    128        //AT45D021
//總大小 MEM_PAGESIZE * MEM_BLOCKPAGE * MEM_BLOCKNUM
//接口


sbit FMCK    = P3^6;
sbit FMDO    = P3^4;
sbit FMDI    = P3^5;
sbit FMCS    = P2^6;

sbit CTR_E    = P2^3;

#define STATR_MEM_OPT    CTR_E = 1;
#define END_MEM_OPT        CTR_E = 0;

#define INTERRUPT_DISABLE    EA = 0
#define INTERRUPT_ENABLE    EA = 1

#define CKUP    FMCK = 1;
#define CKDOW    FMCK = 0;
#define CSON    FMCS = 0;
#define CSOFF    FMCS = 1;


void WriteFMByte(unsigned CHAR ucByte)
{//92指令
    unsigned CHAR m;
    INTERRUPT_DISABLE;
    STATR_MEM_OPT;
    m = 0;
    for(;m<8;m++)
    {
        CKDOW;//開始時CKUP
        FMDI = ucByte&0x80;    
        ucByte = ACC;
        CKUP;
    }
    END_MEM_OPT;
    INTERRUPT_ENABLE;
}
unsigned CHAR ReadFMByte()
{//100指令
    unsigned CHAR ucByte,m;
    INTERRUPT_DISABLE;
    STATR_MEM_OPT;
    for(m = 0;m<8;m++)
    {
        CKDOW;        
        CKUP;
        ucByte <<= 1;
        if(FMDO)ucByte++;
    }
    END_MEM_OPT;
    INTERRUPT_ENABLE;
    return ucByte;
}

unsigned CHAR ReadStatus()
{//200指令
    unsigned CHAR ucByte;
    CSON;
    //tcss 250 ns
    //optcode = 57:0101 0111
    WriteFMByte(0x57);
    ucByte = ReadFMByte();
    CSOFF;
    return ucByte;
/*    ucByte = 0x57;
    for(n = 0;n<8;n++)
    {
        CKDOW;
        FMDI = ucByte & 0x80;
        ucByte = ACC;
        CKUP;
    }
    for(n = 0;n<8;n++)
    {
        CKDOW;        
        CKUP;
        CY = FMDO;
        ACC >>= 1;
    //    ucByte <<= 1;
    //    if(FMDO)ucByte++;
    }
    CSOFF;
    return ACC;
*/}
//return 0
unsigned CHAR BufferRead(unsigned CHAR ucIndex,unsigned int uiAdd,unsigned CHAR* pucBuffer,unsigned int uiLen)
{
    unsigned int uiCount;
    CKUP;
    CSON;
    if(ucIndex == 1)WriteFMByte( 0x54);        //buffer1Read
    else WriteFMByte( 0x56);                //buffer2Read
    WriteFMByte(0);
    WriteFMByte(uiAdd/256);
    WriteFMByte(uiAdd%256);

    for(uiCount = 0;uiCount<(40-8*3-8);uiCount++)
    {
        CKDOW;
        CKUP;
    }
    for(uiCount = 0;uiCount<uiLen;uiCount++)
    {
        pucBuffer[uiCount] = ReadFMByte();
    }
    CSOFF;
    return 0;
}
void BufferWrite(unsigned ucIndex,unsigned int uiAdd,unsigned CHAR* pucBuffer,unsigned int uiLen)
{//
    unsigned int uiCount;
    CKUP;
    CSON;
    if(ucIndex == 1)    WriteFMByte(0x84);
    else                WriteFMByte(0x87);
    WriteFMByte(0);
    WriteFMByte(uiAdd/256);
    WriteFMByte(uiAdd%256);

    for(uiCount = 0;uiCount<= (uiLen-1);uiCount++)
    {
        WriteFMByte(pucBuffer[uiCount]);
    }
    CSOFF;
    //檢查是否成功
    uiCount=0;
    while(0 == (0x80 & ReadStatus()))uiCount++;//0
}
//ucFlag = 0 ,帶擦除,其他不帶插除
unsigned CHAR BufferToMain(unsigned CHAR ucIndex,unsigned int uiPage,unsigned CHAR ucFlag)
{//帶擦除 = 0x34 * 206 +482 = 11190 us
//不擦除  = 0x18 * 206 +482 = 5426us
    unsigned CHAR ucData,ucTemp;
    ucData = uiPage / 128;
    ucTemp = uiPage<<1;// % 128)*2;
    
    CKUP;
    CSON;
if(ucFlag)
{
    if(ucIndex == 1)WriteFMByte( 0x88);        //buffer1to main 不擦除
    else WriteFMByte( 0x89);                //buffer2to main
}
else
{
    if(ucIndex == 1)WriteFMByte( 0x83);        //buffer1to main
    else WriteFMByte( 0x86);                //buffer2to main
}
    Wri
參與討論
昵稱:
討論內(nèi)容:
 
 
相關(guān)帖子
請教
有沒有帶模數(shù)轉(zhuǎn)換的51單片機(jī)??
單片機(jī)啟動后,數(shù)據(jù)寄存器,如30H等,它的內(nèi)容為0嗎?
關(guān)于Keil+偉福仿真器,請進(jìn)
摩托羅拉系列單片有沒有-在線調(diào)試的工具
免費(fèi)注冊為維庫電子開發(fā)網(wǎng)會員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入


Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號