Erase memory -- new API command

1 view
Skip to first unread message

casainho

unread,
Sep 29, 2008, 5:42:17 PM9/29/08
to Bicycle LED POV
Hello :-)

Today I was reading and trying to make drivers for DataFlash memory. I
saw that DataFlash memory can't be written without first be erased. We
can write/read byte by byte, but every byte to be written should be
erased (with value 0xff).

DataFlash have one command to be all erased and commands to erase
blocks of 4kB, 32kB and 64kB.

So my suggestion is to add a command to erase all DataFlash memory,
and software would first erase all memory, after write all data
sequentially and in the end, read it to verify.

Fernando Silva

unread,
Sep 29, 2008, 5:46:36 PM9/29/08
to bicycl...@googlegroups.com
Well... I did not understand what you are talking about!

Jorge Pinto aka Casainho

unread,
Sep 29, 2008, 5:46:35 PM9/29/08
to bicycl...@googlegroups.com

> So my suggestion is to add a command to erase all DataFlash memory,
> and software would first erase all memory, after write all data
> sequentially and in the end, read it to verify.

And the command to erase and write on memory, should have an answer from
hardware saying that action was performed -- because erase the whole
memory and write data takes take, memory will be busy, so, I think that
software should not continue while don't receive an confirmation of
action successeful performed.

Jorge Pinto aka Casainho

unread,
Sep 29, 2008, 5:54:35 PM9/29/08
to bicycl...@googlegroups.com
Fernando,

Actual API have the command: "Command 13: Write memory byte" -- I can't
implement that because to write the byte on DataFlash memory address xx,
I must before erase address xx!

DataFlash memory can't erase one byte only, just blocks of 4kB, 32kB,
64kB or the whole memory.

Could be a better way than erase all memory before write?

You can read the datasheet: http://www.farnell.com/datasheets/103577.pdf

Fernando Silva

unread,
Sep 29, 2008, 6:06:40 PM9/29/08
to bicycl...@googlegroups.com
Can you confirm that this only happens with this kind of memory, or
happens with all kinds?

Jorge Pinto aka Casainho

unread,
Sep 29, 2008, 6:11:09 PM9/29/08
to bicycl...@googlegroups.com
Well, with other kind like EEPROM don't happen. I am new to DataFlash
memory, I didn't know about this. I just used EEPROM untill now.

Fernando Silva

unread,
Sep 29, 2008, 6:27:01 PM9/29/08
to bicycl...@googlegroups.com
This is a case where we need a function to be implemented, but it has
no logic with other kinds of memory.

Anyway, it makes sense to have a clearMemory API function, to erase
all the memory. But a problem arises, with different memories the API
will have no effect, because it will need to implement different
commands.

Is it possible to send all writes to the memory through the microchip?
And do all reads through it too?

Jorge Pinto aka Casainho

unread,
Sep 30, 2008, 2:53:36 AM9/30/08
to bicycl...@googlegroups.com

> Anyway, it makes sense to have a clearMemory API function, to erase
> all the memory. But a problem arises, with different memories the API
> will have no effect, because it will need to implement different
> commands.

Well, If we use EEPROM, firmware can also implement the erase all memory
command.


> Is it possible to send all writes to the memory through the microchip?
> And do all reads through it too?

I am not sure I understand your question, but the read, write and erase
commands API are performed by MCU (microchip), to the memory.

I don't see any big problem, just the memory must be all erased before
writing on it.

Fernando Silva

unread,
Sep 30, 2008, 4:11:14 AM9/30/08
to bicycl...@googlegroups.com
Ok then, if is the MCU that does the job, we can implement two things:
1. eraseMemory - that will clear all memory, so we can startover
2. the write command being implemented by the firmware, will have the
work of erasing the necessary blocks prior to the writing itself (in
the DataFlash case)

Casainho

unread,
Sep 30, 2008, 4:15:37 AM9/30/08
to bicycl...@googlegroups.com
> Ok then, if is the MCU that does the job, we can implement two things:
> 1. eraseMemory - that will clear all memory, so we can startover

Okok.

> 2. the write command being implemented by the firmware, will have the
> work of erasing the necessary blocks prior to the writing itself (in
> the DataFlash case)

EI!! I didn't suggest this ;-) eheh - I don't know I could a do
that... I was thinking about and I couldn't find a solution, thats why
I suggest erase all memory.

Do you have an idea how MCU could do that? -- because if I just want
to write a byte, I need to erase the at least 4kB...

Fernando Silva

unread,
Sep 30, 2008, 4:22:35 AM9/30/08
to bicycl...@googlegroups.com
write command, erases and writes, returning the number of bytes written/erased

ok, I explain my problem: I can't write 1 byte right? If I write some
images into the memory, all be fine. But next time, I want to change
some images I will always have to read them all, erase all memory and
write all again.

If for you this is not a problem, we can implement this behaviour for
all MCU within the function "write" that before writing can erase all
memory, allowing writenext to work as expected

Casainho

unread,
Sep 30, 2008, 5:50:01 AM9/30/08
to bicycl...@googlegroups.com
On Tue, Sep 30, 2008 at 9:22 AM, Fernando Silva <fsil...@gmail.com> wrote:
>
> write command, erases and writes, returning the number of bytes written/erased
>
> ok, I explain my problem: I can't write 1 byte right?

Yes, is not possible with this DataFlash memory and with this MCU. If
I had more than 4kB RAM, I could try read 4kB and after erase and
write one new byte and other bytes.


> If for you this is not a problem, we can implement this behaviour for
> all MCU within the function "write" that before writing can erase all
> memory, allowing writenext to work as expected

I don't like the idea that a write command erases all memory. Write
command should work as expected, in this specific case of DataFlash
memory, memory must be erased before any write command.

My suggestion is the initial, a new command on API to erase all memory.

casainho

unread,
Sep 30, 2008, 10:25:01 AM9/30/08
to Bicycle LED POV
Another question:

While reading the DataFlash datasheet, I saw that there is only one
read and write command. For example, read command needs the address at
first time and on next sequential read commands there is no need to
send address... would be good idea to make the same on our API? - I
can implement it easily...

Fernando Silva

unread,
Sep 30, 2008, 10:27:40 AM9/30/08
to bicycl...@googlegroups.com
Yes! You had already a write/writenext, read/readnext and I agreed with you!

Casainho

unread,
Sep 30, 2008, 10:32:27 AM9/30/08
to bicycl...@googlegroups.com
> Yes! You had already a write/writenext, read/readnext and I agreed with you!

So writenext and readnext will disapear from API :-)

Fernando Silva

unread,
Sep 30, 2008, 10:33:40 AM9/30/08
to bicycl...@googlegroups.com
Why? I'm confused...

Casainho

unread,
Sep 30, 2008, 10:37:25 AM9/30/08
to bicycl...@googlegroups.com
> Why? I'm confused...

readnext functionality can pass to read, also the same to write. So
API can be shortened to less 2 commands.

Fernando Silva

unread,
Sep 30, 2008, 10:38:56 AM9/30/08
to bicycl...@googlegroups.com
And other memory types?

Casainho

unread,
Sep 30, 2008, 10:47:26 AM9/30/08
to bicycl...@googlegroups.com
> And other memory types?

Well, If software sends the 1st read command and the address to
hardware, MCU will start a counter to store and increment the address.
Next read command will not have the address -- DataFlash memory works
like this, so, I think we can do like that on our API, just to save
that xxnext commands.

So, this is something that depends on firmware and not memory :-)

Fernando Silva

unread,
Sep 30, 2008, 10:56:14 AM9/30/08
to bicycl...@googlegroups.com
Ok!

casainho

unread,
Sep 30, 2008, 7:23:13 PM9/30/08
to Bicycle LED POV
I were working on driver code for DataFlash, I wrote 3 functions to
implement the API:

void DataFlash_EraseAll (void);

unsigned char DataFlash_ReadByte (unsigned long int uliAddress);

void DataFlash_WriteByte (unsigned long int uliAddress, unsigned char
ucData);

They are not tested yet....

http://code.google.com/p/bicycleledpov/source/browse/trunk/hardware/firmware/Drivers/DataFlash/AT26DF081A.c?r=327
Reply all
Reply to author
Forward
0 new messages