Writing to Winbond W29C020  - Page 1
Forum section: electronics / projects

author: gmc
author_rank: Regular Contributor
timestamp: May 22, 2020, 12:54:46 pm
content: I'm using these Winbond 256K × 8 CMOS FLASH MEMORY chips in a project and first need to build a Arduino based programmer.Not finding much on the internet or on the forums for this chip so doesn't look like its widely used for some reason.http://pdf.datasheetcatalog.com/datasheets2/27/274053_1.pdfLooking at the datasheet I've got a few queries on the method of programming. I'm a bit confused as to how to write data.The chip needs to be programmed in page write mode.QuoteBut then it goes on to says software data protection is enabled by default so I need to perform the three-byte command cycle at the beginning of a page load cycleLooking at the timing waveforms is not making anything clearerWhy are there 3 ways to write to the chip, CE controlled, WE controlled, and page writeTaking a wild guess here but to program 256Kb would the sequence be:- Write 3 byte sequence- set address and data lines- CE low, OE, high, WE high- Increment address, set data lines- CE low, OE, high, WE high- Repeat until 256Kb writtenIf its any clearer to someone who has used these I would appreciate a flow on how to program these.

author: chriva
author_rank: Regular Contributor
timestamp: May 22, 2020, 02:28:04 pm
content: Let me start with: I _HATE_ these! (and Atmel's version).Had to write a target resident driver for them on a CPU32 target a couple of years ago. Proper PIA.Have you looked at 39sf020?Writing data or a command should not behave differently in terms of pin and address behaviour so start by writing functions for read and write.keep chip enable at all times (just tie it to ground)Also: You can take quite many liberties. Just make sure hold and data direction times are metVery ugly "psuedo code":Code:initialize(){Set data pins as inputset address pins as output, address doesn't really matter right nowset OE and WE high, data direction output}writeByte(address, byte){Set address pinsMake sure (Toes) is metSet data pins to output and set data byteSet WE lowMake sure (Twp) is metSet WE highMake sure (Twph) is met_Set data pins to input_(!!!)}readByte(address){Set address pinsSet OE lowWait (Trc). (Toe) is likely enough but let's be paranoidRead data byte_Set OE high_(!!!)Return data byte}writePage(address, *data){writeByte(5555,aa)writeByte(2aaa,55)writeByte(5555,a0)for number of pagebytes:writeByte(address++, data[pagebyte++])Make sure (Twc) is met (this is where the chip actually writes the data after you've filled the page buffer}You can optimize this quite significantly but it's better to take it safe and slow.

author: gmc
author_rank: Regular Contributor
timestamp: May 22, 2020, 03:39:28 pm
content: Thanks very much, that gives me something to work on.I think I've been reading the datasheet for too long and getting more and more confused. Spent hours scouring the net for examples.Beginning to see why you hate them

author: chriva
author_rank: Regular Contributor
timestamp: May 22, 2020, 03:53:16 pm
content: Just reading and writing a whole image is not too bad (it's pretty much standard procedure).They become annoying once you want to write to other than page offsets since a read-modify-write must be performed

author: gmc
author_rank: Regular Contributor
timestamp: May 22, 2020, 04:22:09 pm
content: Ok, doesn't sound too bad. I'm only interesting in reading/writing a full image.