Ap plication Note Re pla cing Atm el 4 5DB1 6 1D Seria l Fla sh with Ma cronix M X25 L16 0 5A Seria l Fla sh April 27, 2006 Introd uct ion Macronix offers a family of serial flash (SPI) products from 512Kb to 64Mb densities. This application note explains how the Atmel 45DB161D, 16Mb DataFlash can be replaced with a similar Macronix MX25L1605A,16Mb flash product. There are several compelling reasons to replace the Atmel device with a Macronix part. Speed (performance) and costs are typical factors. For a successful design in, system designers need to know the product feature differences, as well as similarities, of the two devices. This is summarized in the comparison table below. Comparison between Macronix and Atmel Flash product Macronix 16Mb and Atmel 16Mb Flash Memory Comparison Specification Macronix MX25L1605A Atmel* 45DB161D Vcc voltage Bus Width Erase unit 2.7V – 3.6V 1x I/O, SPI compliance Equal 4KB/ Equal 64KB SPI clock rate 33MHz normal read/ 85MHz fast read 256B -4KB- 60ms(typ) 64KB- 1s(typ) Chip (16Mb)- 14s(typ) 256B- 1.4ms(typ) 2.7V – 3.6V or 2.5V- 3.6V 1x I/O, SPI compliance Equal 256B/ Equal 4KB/ Equal 128KB 33MHz normal read / 66MHz fast read @ 2.7V 512B or 528B 256B- 15ms(typ) 4KB- 45ms(typ) 128KB- 1.6s(typ) -512B- 3ms(typ) 100k 100k Page Program Buffer Erase Performance Program Performance Write/Erase cycles (Endurance) Sector lock down register NA Additional sector lock down register (16 bytes) Sector (block) Protection 1. Area: 1/32, 1/16, 1/8, 1/4, 1. Area: sector o and the rest 1/2, all 2. Register: Additional sector 2. Register: Status register protection register (16 bytes) bit2-4 and bit 7 * The terms used to identify companies and products may be trademarks of their respective owners. AN 015 1 Application Note Replacing Atmel 45DB161D Serial Flash with Macronix MX25L1605A Serial Flash Protection Register (OTP Sector) Read Current Erase/Program Current Standby current Package NA 128 byte 4mA(max.) @ 33MHz 4mA(typ.)/8mA(max.) @ 33MHz 12 mA (typ.)/17mA(max) 25uA(typ)/ 50uA(max) 8-pin 209mil SOP/ 28-TSOP/ 8-MLF(6x5mm) 15 mA (max.) 20uA(max.) 8-pin 209mil SOP/ 16-pin 300mil SOP/ 8-SON(8x6mm) Hardw are C ons iderat ion s From a hardware perspective, replacing the Atmel 45DB161D DataFlash with Macronix MX25L1605A is a relatively straightforward task for two reasons: Firstly, the major pin functions are compatible to each other and secondly, it might be feasible to accommodate both footprints in one board area. The major pin functions (SI, SO, SCLK, CS#) from both suppliers are compatible Macronix and Atmel pinout compatibility (by pin and function): Macronix pin(s) and Atmel pin(s) and Comments function function Pin 1: CS# Pin 4: CS# Same pin definition and function Pin 2: SO Pin 8: SO Same pin definition and function Pin 3: WP# Pin 5: WP# Similar function Pin 4: GND Pin 7: GND Ground pin Pin 5: SI Pin 1: SI Same pin definition and function Pin 6: SCLK Pin 2: SCK Same function, but different name Pin 7: HOLD# Pin 3: RESET# Different function, but both active low Pin 8: VCC Pin 6: VCC Power supply pin * *Other names and brands are the property of the respective companies. 2 www.macronix.com AN 015 Application Note Replacing Atmel 45DB161D Serial Flash with Macronix MX25L1605A Serial Flash AT45DB161D MX25L1605A One possibility of a dual footprint layout is by rotating the Atme l part by 90º and overlaying the footprint on top of a normally positioned Macronix device as shown below. This way, the same PCB board area is maintained. Dual footprint example – Atmel and Macronix part in the same area Software Considerations From a software point of view, both Macronix and Atmel command sets follow the industry standard but each has its own unique command set. The manufacturer and device ID are different between Macronix and Atmel parts and one could make use of the Read ID command (which is common in both parts) to select the appropria te command sets for use with the device. This is shown in the flowchart on page 6. 3 www.macronix.com AN 015 Application Note Replacing Atmel 45DB161D Serial Flash with Macronix MX25L1605A Serial Flash The main software differences shown below are: (i) Manufacturer ID/Device ID (ii) Command Instruction Manufacturer ID and Device ID Macronix MX25L1605A Command Cycle ID (Address/Data) 9F Atmel 45DB161D Command Cycle Mfr. ID: C2h 2-byte Device ID: 20h and 15h 9F ID Mfr. ID: 1Fh Device ID: 26h and 00h and 00h Command Instruction Command Set and Software Compatibility Part Number Macronix Atmel MX25L1605A AT45DB161D WREN (write Enable) WRDI (write disable) RDID (read identification) RDSR (read status register) WRSR (write status register) 06 Hex 04 Hex 9F Hex 05 Hex 01 Hex AD (read data) 03 Hex 03 Hex Fast READ (fast read data) 0B Hex 0B Hex Page Erase SE (4KBSector Erase) -20 Hex 81 hex 4KB block erase: 50 Hex SE (32KB Sector Erase) Block (64KB) Erase CE (Chip Erase) PP(Page Program) 9F Hex D7 hex -52 or D8 Hex 60 or C7 Hex 128KB block erase: 7C Hex 02 Hex DP (Deep Power Down) Release from Deep Power-down (RDP) and Device ID B9 Hex AB Hex RES(Read Electronic Id) AB Hex REMS(Read Manufacturer Electronic Id) 90 Hex B9 Hex AB Hex 4 www.macronix.com AN 015 Application Note Replacing Atmel 45DB161D Serial Flash with Macronix MX25L1605A Serial Flash Atmel unique command set: For read: Command main memory page read D2 hex continuous array read buffer 1 read(low freq.) buffer 2 read(low freq.) buffer 1 read buffer 2 read For write E8 hex D1 hex D3 hex D4 hex D6 hex Command buffer 1 write 84 hex buffer 2 write 87 hex buffer 1 to main memory program w. erase buffer 2 to main memory program w. erase 83 hex 86 hex buffer 1 to main memory program w/o. erase 88 hex buffer 2 to main memory program w/o. erase 89 hex main memory pgm thru buffer 1 82 hex main memory pgm thru buffer 2 For Protection/Security 85 hex Command Enable Sector Protection Disable Sector Protection 3DH+2AH+7F+A9H 3DH+2AH+7F+9AH Erase Sector Protection Register Program Sector Protection Register Read Sector Protection Register Sector Lockdown Read Sector Lockdown Register Program Security Register 3DH+2AH+7F+CFH 3DH+2AH+7F+FCH 32H 3DH+2AH+7F+30H 35H 9BH+00H+00H+00H Read Security Register 77H Additional Commands Command Main Memory page to buffer 1 transfer 53H Main Memory page to buffer 2 transfer 50H Main Memory page to buffer 1 compare 60H Main Memory page to buffer 2 compare Auto page rewrite through buffer 1 61H 58H Auto page rewrite through buffer 2 59H 5 www.macronix.com AN 015 Application Note Replacing Atmel 45DB161D Serial Flash with Macronix MX25L1605A Serial Flash START Read ID code command Write Command 9Fh Read ID code 1st read is Manufacturer ID 2nd read is Device ID Manufacturers ID = C2h ? Store ID Yes Device is Macronix flash. Use Macronix command set No Yes Manufacturers ID = 1Fh ? Device is ATMEL flash. Use ATMEL command set No Non-Macronix or Atmel device. Multi-Source algorithm flowchart 6 www.macronix.com AN 015 Application Note Replacing Atmel 45DB161D Serial Flash with Macronix MX25L1605A Serial Flash Conclu sio n For hardware considerations, in order to minimize board area, it might be feasible that the pads for both Atmel and Macronix parts overlay on top of each other rotated by 90º. In the case of software, the appropriate command set can be selected by screening for the manufacturer and device IDs. For both cases, a multi-source strategy is provided for the system designer with the aim that this will ease procurement effort during a tight market condition. In the following appendix, numerous examples of sample code for various device operations are provided to the designer. For the 16Mb serial Flash, although Macronix does not offer the same pinout that Atmel uses, Macronix does provide industry compatible parts. Replacing Atmel serial Flash with Macronix serial Flash is not a trivial matter and does require some effort on the part of the user. However, give n the definite speed advantage of the Macronix product offering, applications that require higher speeds will experience noticeable difference in performance. For additional technical support, please contact the Macronix sales office in your local area. 7 www.macronix.com AN 015 Application Note Replacing Atmel 45DB161D Serial Flash with Macronix MX25L1605A Serial Flash App end ix: Sa mp le co de Read_ID_Op() { CS# low; Write Read ID command = 0x9F; MfrID= read flash at 1st; // read manufacturer ID DevID1= read flash at 2nd; // read memory type ID DevID2= read flash at 3rd; // read memory density ID CS # high; } Sector_Erase_Op() { eraseOkFlag = TRUE; CS# low; Write WREN command = 0x06; CS# high; /* clear the erase ok flag to be TRUE */ // Setting Write Enable Latch bit CS# low; Write Block Erase command = 0x26; // 4KB Sector-Erase command Write Block address = AD1; // AD1 = A23 – A 16; Write Block address = AD2; // AD2 = A15 – A8; Write Block address = AD3; // AD3 = A7 – A0 CS# high; CS# low; Write Read Status command = 0x05; While(1) // set a loop to check the flash's Status Register till ready or time out { statusReg = read status of flash; // read status from flash if( (statusReg & 0x01) == 0x00) // if the Q0(write in progress bit) == ‘0’ is ready or ‘1’ busy break; else if( time-out) { set eraseOkFlag = FALSE; break; } } CS# high; return (eraseOkFlag); /* report the final result to main program */ } /* end of Sector_erase_Op */ 8 www.macronix.com AN 015 Application Note Replacing Atmel 45DB161D Serial Flash with Macronix MX25L1605A Serial Flash Block_Erase_Op() { eraseOkFlag = TRUE; CS# low; Write WREN command = 0x06; CS# high; /* clear the erase ok flag to be TRUE */ // Setting Write Enable Latch bit CS# low; Write Block Erase command = 0xD8 or 0x52; // 64KB Block-Erase (both command 0x52/0xd8 are accepted) Write Block address = AD1; // AD1 = A23 – A 16; Write Block address = AD2; // AD2 = A15 – A8; Write Block address = AD3; // AD3 = A7 – A0 CS# high; CS# low; Write Read Status command = 0x05; While(1) // set a loop to check the flash's Status Register till ready or time out { statusReg = read status of flash; // read status from flash if( (statusReg & 0x01) == 0x00) // if the Q0(write in progress bit) == ‘0’ is ready or ‘1’ busy break; else if( time-out) { set eraseOkFlag = FALSE; break; } } CS# high; return (eraseOkFlag); /* report the final result to main program */ } /* end of Block_erase_Op */ 9 www.macronix.com AN 015 Application Note Replacing Atmel 45DB161D Serial Flash with Macronix MX25L1605A Serial Flash Page_Program_Op() { int i; ProgramOkFlag = TRUE; CS# low; Write WREN command = 0x06; CS# high; // clear the program ok flag to be TRUE // Setting Write Enable Latch bit CS# low; Write Page Program command = 0x02; Write Block address = AD1; // AD1 = A23 – A16; Write Block address = AD2; // AD2 = A15 – A8; Write Block address = AD3; // AD3 = A7 – A0 For (i=0; i<256 ; i++) // set a loop to down load whole page data into flash’s buffer { // the page number is 256 bytes write data = WDi; // WDi stands for write data 0 ~ 255 bytes } CS# high; CS# low; Write Read Status command = 0x05; While(1) // set a loop to check the flash's Status Register till ready or time out { statusReg = read status of flash; // read status from flash if( (statusReg & 0x01) == 0x00) // If the Q0(write in progress bit) == ‘0’ is ready or ‘1’ busy break; else if( time-out ) { set ProgramOkFlag = FALSE; break; } } CS# high; return (ProgramOkFlag); } /* report the final result to main program */ /* end of Program_Op */ 10 www.macronix.com AN 015 Application Note Replacing Atmel 45DB161D Serial Flash with Macronix MX25L1605A Serial Flash Chip_Erase_ Op() { eraseOkFlag = TRUE; CS# low; Write WREN command = 0x06; CS# high; /* clear the erase ok flag to be TRUE */ // Setting Write Enable Latch bit CS# low; Write Chip Erase command = 0x60 or 0xC7; CS# high; CS# low; Write Read Status command = 0x05; While(1) { statusReg = read status of flash; if( (statusReg & 0x01) == 0x00) break; else if( time-out ) { set eraseOkFlag = FALSE; break; } } CS# high; return (eraseOkFlag); } // set a loop to c heck the flash's Status Register till ready or time out // read status from flash // If the Q 0(write in progress bit) == ‘0’is ready or ‘1’ busy /* report the final result to main program */ /* end of Chip_erase_Op */ 11 www.macronix.com AN 015 Application Note Replacing Atmel 45DB161D Serial Flash with Macronix MX25L1605A Serial Flash Read_Op( ) { CS# low; Write Read Array comma nd = 0x03; Write Sector address = AD1; /* AD1 = A23 – A16 */ Write Sector address = AD2; /* AD2 = A15 – A8; */ Write Sector address = AD3; /* AD3 = A 7 – A0; */ For (i=0; i<n ; i++) { array_data = read flash; } CS# high; // set a loop to read data into flash’s buffer // n bytes read out until /CS goes high } Fast_Read_Op( ) { CS# low; Write Read Array command = 0x0B; Write Sector address = AD1; /* AD1 = A23 – A16 */ Write Sector address = AD2; /* AD2 = A15 – A8; */ Write Sector address = AD3; /* AD3 = A 7 – A0; */ Write dummy address = data; For (i=0; i<n ; i++) { array_data = read flash; } CS# high; // set a loop to read data into flash’s buffer // n bytes read out until /CS goes high } 12 www.macronix.com AN 015