Perhaps any people from earth knows that the atmel dataflash is short. I do NOT know why. Somebody said atmel isnot so good company that she is planing to rise the chip price by this way. The others said that many people in this market are crasy to buy and store so mang chips for grasping unnomal money... We don't know whose opion is right...
; (
Drive the flash from other company. The OLD Chinese Aphorism said: "After Butcher Zhang die, we have to eat the pork with full hair?"("死了张屠户, 我们就得吃带毛的猪?")
Searching some weeks, we found the spi flash from winbond seemed to satify us. The 4M bit flash W25Q16xx is enough in current market.
We uploaded our simple driver source code here. I wish it will help some engineer or company to replant new winbond flash for their case. Anyway, the price of winbond spi-flash from my provider is good. ; ) Of course, if you touch me then I will tell u... But it is not appropriate to paste the price in the public topic. Right? ;&
The important different issue from the other spi memory chip is: ADD BUSY DELAY FUNCITON! If not, we will found some fails at our reading event.
The source are written with C, running NXP arm7 chip.
// flash size
#define W25Q16_TOTAL_SIZE 0x200000 // 256*8192 bytes = 2048k = 2M = 0x200000
#define REAL_PAGE_SIZE 256 // 256 bytes/page
// command opcode
#define RSR1_INST 0x05 // Read Status Register-1
#define DEID_INST 0xab // Read Device ID
#define MDID_INST 0x90 // Read Manufacturer/Device ID
#define JEID_INST 0x9f // Read Manufacturer/Memory Type/Capacity
#define FTRD_INST 0x0b // Fast Read
#define WREN_INST 0x06 // Write Enable
#define STER_INST 0x20 // Sector Erase
#define PGWR_INST 0x02 // Page Program
// init
void w25q16_init(void)
{
IO0DIR |= SPI0CS;
IO0SET = SPI0CS;
delay_ms(10);
}
// read status register, default return we read is 0x00, that means none of the array protected
U8 w25q16_rdsr_cmd(void)
{
U8 data;
IO0CLR = SPI0CS;
spi0_send_U8(RSR1_INST);
data = spi0_read_U8();
IO0SET = SPI0CS;
return data;
}
/*
* Status Register Format:
* Bit7 | Bit6 | Bit5 | Bit4 | Bit3 | Bit2 | Bit1 | Bit0
* | SEC | TB | BP2 | BP1 | BP0 | WEL | BUSY
*/
void w25q16_busy_delay(void)
{
U8 status;
do {
status = w25q16_rdsr_cmd();
} while ((status & 0x01) == 0x01);
}
// read device id, return must be 0x14 for W25Q16BV
U8 w25q16_deid_cmd(void)
{
U8 data;
w25q16_busy_delay();
IO0CLR = SPI0CS;
spi0_send_U8(DEID_INST);
spi0_send_U8(0x00); // dummy
spi0_send_U8(0x00); // dummy
spi0_send_U8(0x00); // dummy
data = spi0_read_U8();
IO0SET = SPI0CS;
return data;
}
W25Q16BV driver sample(I)
W25Q16BV driver sample(II)
用户1277994 2010-8-17 15:24
allen_zhan_752827529 2010-8-17 13:14
用户1277994 2010-8-16 13:55