这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » am29lv160dt,flash am29lv160dt flash 擦除

共2条 1/1 1 跳转至

am29lv160dt,flash am29lv160dt flash 擦除

院士
2006-09-17 18:14:16     打赏
am29lv160dt,flash am29lv160dt flash 擦除



关键词: am29lv160dt     flash     擦除    

院士
2006-12-22 22:43:00     打赏
2楼
am29lv160dt flash 擦除某一sector时怎么全片都擦除了
这是下面的代码,请高手看看有没有写错。

void flash_erase(P_U16 base_addr){
    
    
    P_U16 Temp;
    U32 i=35000000;
    
         /*  Issue the Sector Erase command to am29lv160dt  */

         Temp  = (P_U16)((0x0000555<<1)+FLASH_ADDRESS);                 *Temp = 0xAA;                 
         Temp  = (P_U16)((0x00002AA<<1)+FLASH_ADDRESS);                 *Temp = 0x55;                
         Temp  = (P_U16)((0x0000555<<1)+FLASH_ADDRESS);         
          *Temp = 0x80;                 
         Temp  = (P_U16)((0x0000555<<1)+FLASH_ADDRESS);
          *Temp = 0xAA;                
         Temp  = (P_U16)((0x00002AA<<1)+FLASH_ADDRESS);
          *Temp = 0x55;                
         Temp  = base_addr;                     
         *Temp = 0x30;                 
         while(i--);//Delay
} 1: 有没有人用过个flash呢有没有人用过个flash 2: re:woaini看看我的擦除操作:
#define WRITE_FLASH(uiAddr,usData)    *((volatile INT16U *)(uiAddr << 1))= usData

void  bSST39VF160SectorErase(INT32U uiAddr)
{
    WRITE_FLASH(0x5555, 0xAA);
    WRITE_FLASH(0x2AAA, 0x55);
    WRITE_FLASH(0x5555, 0x80);
    WRITE_FLASH(0x5555, 0xAA);
    WRITE_FLASH(0x2AAA, 0x55);
    WRITE_FLASH(uiAddr, 0x30);
    bWaitForEndOfPrg();//判断是否写入完成函数
}
3: SST39VF160 的我的程序也可以用在SST39VF160的是可以的.
#define WRITE_FLASH(uiAddr,usData)    *((volatile INT16U *)(uiAddr << 1))= usData

void  bSST39VF160SectorErase(INT32U uiAddr)
{
    WRITE_FLASH(0x5555, 0xAA);
    WRITE_FLASH(0x2AAA, 0x55);
    WRITE_FLASH(0x5555, 0x80);
    WRITE_FLASH(0x5555, 0xAA);
    WRITE_FLASH(0x2AAA, 0x55);
    WRITE_FLASH(uiAddr, 0x30);
    bWaitForEndOfPrg();//判断是否写入完成函数
}
但在am29lv160dt就不行,代码如下:
#define WRITE_FLASH(uiAddr,usData)    *((volatile INT16U *)(uiAddr << 1))= usData

void  bAM29VF160SectorErase(INT32U uiAddr)
{
    WRITE_FLASH(0x555, 0xAA);
    WRITE_FLASH(0x2AA, 0x55);
    WRITE_FLASH(0x555, 0x80);
    WRITE_FLASH(0x555, 0xAA);
    WRITE_FLASH(0x2AA, 0x55);
    WRITE_FLASH(uiAddr, 0x30);
    bWaitForEndOfPrg();//判断是否写入完成函数
} 4: 我用过没问题啊//--------------------------------
//Erase all data on chip
//--------------------------------
void chip_erase( void )
{
    SFRPAGE = 0x0F ;
    CE_H() ;
    WE_H() ;
    OE_H() ;
    out_byte( 0xAAA, 0xAA );
    
    out_byte( 0x555, 0x55 );
    
    out_byte( 0xAAA, 0x80 );
    
    out_byte( 0xAAA, 0xAA );
    
    out_byte( 0x555, 0x55 );
    
    out_byte( 0xAAA, 0x10 );

    wait_ready1();
    
}


//--------------------------
//Erase a sector
//--------------------------
void sec_erase( ulong  addre )
{

        
    SFRPAGE = 0x0F ;

    CE_H() ;
    WE_H() ;
    OE_H() ;
    out_byte( 0xAAA, 0xAA );
    
    out_byte( 0x555, 0x55 );
    
    out_byte( 0xAAA, 0x80 );
    
    out_byte( 0xAAA, 0xAA );
    
    out_byte( 0x555, 0x55 );
    
    out_byte( addre, 0x30 );


   
    wait_ready2();

    
}

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]