Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] SPI interface to AT45DB161

2008-09-09 by Moataz Hussein

Thanks Tim for your advice,

Actualy I was not able at all to find helpful material concering that, but
at last I found and application note AVR335 which has some hints.
Will continue testing ,

Moataz


On Tue, Sep 9, 2008 at 9:58 AM, Tim Mitchell <tim@sabretechnology.co.uk>wrote:

>     Moataz Hussein wrote:
> > Hello,
> > I am building a data logging system to record temperaure readings and
> > store them on a flash.
> > I am using ATmega 16 and AT45DB161D memory.
> > I have some points which are not clear though I studied the ATDB161
> > datasheet.
> >
> >
> > Please correct me.
> > How can I write for example 10 bytes of data to the memory? then
> > store another 10 bytes after the first 10 bytes?
> > I will give command to write page through buffer and send the first
> > 10 bytes, which will be stored in page 1 for example. How to do the
> > next step?
> >
> >
> > How can I read the 20 bytes which are prevoiusly stored?
> > I will send a command to read the page the contain the stored data,
> > checking the SPIF when set read the first byte and so on..
> >
> >
> > I Have to check SPIF after each byte to be sure that it is sent or
> > recieved?
>
> The AT45DB... dataflash chips have a RAM buffer to temporarily store
> data before you write it to the flash (or when reading it from the
> flash). But the flash can only be written in a whole page of 524 (? I
> think) bytes.
>
> So you have 2 options, you can either fill the ram buffer before you
> write the flash page all in one go, or you need to read back the flash
> page into the buffer, modify your 10 bytes and write it back to the
> flash again.
>
> The first way is best if you can be sure you are not going to lose
> power. The second way will mean you don't lose data if the power is
> turned off but will mean more "wear" of the flash.
>
> The commands for read block to buffer, write block to buffer etc are all
> listed in the data sheet.
>
> If you are writing or reading a sequence of bytes to or from the RAM
> buffer, you don't have to check SPIF each time - just once before you
> start to make sure the chip is not busy with a flash write or erase
> operation.
>
> --
> Tim Mitchell
>
> 
>


[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.