atmel AT45D0xx serial flash
Archiver
Posts: 46,084
Ryan -
Here is a copy of what I kept, from the original Stamp List.
Have phun !
Regards,
Bruce
>Date: Mon, 8 Mar 1999 14:23:55 -0500
>From: Tracy Allen <emesys@c...>
>Subject: [noparse][[/noparse]STAMPS] atmel AT45D0xx serial flash
>To: "INTERNET:stamps@p..." <stamps@p...>
>Sender: owner-stamps@p...
>Reply-To: stamps@p...
>X-MIME-Autoconverted: from quoted-printable to 8bit by mh005.infi.net id
PAA25011
>
>Gregory Whitmore <gwhitmore@m...> wrote:
>> I have a few serial-flash-eeproms from ATMEL. They are
>> the AT45D041, 512k (I think). I was wondering if it
>> is possible to interface these with the stamp2. Maybe
>> to just hold data to send to a LCD. Can anyone help
>> with the coding? ....
>
>Bruce Bates <bvbates@i...> replied
>> ...big snip...
>> This is a rather sophisticated device you're working
>> with - to say the least.
>
>
>Gregory,
>
>I agree with Bruce. To take full advantage of this memory chip's
>capabilities you should be looking at a BS2SX with a whole bank dedicated
>to memory management.
>
>That said, I think you can do some useful stuff with it on a BS2. It could
>hold lots of messages for your LCD. With read-only messages, it won't
>require too much code.
>
>Here is a working (mileage may vary) demo, to get you started. There is a
>subroutine called "sndcmd" ("send command") that is called at the beginning
>of each cycle of instructions. It parses the page and address bits and
>sends the extra don't care bits if required. I hope this helps.
>
> -- Tracy Allen
> mailto:emesys@c...
> http://go.ourworld.nu/emesys/
>
>
>' demo program for ATMEL AT45D0xx flash/ram
>' (c) 1999, Tracy Allen, eme systems
>' demos commands for writing and reading
>' the RAM and the flash array.
>'
>' The hardware connections are:
>'
>' BS2 or BS2SX AT45D0xx
>' p8 atcs ----> cs\ chip select
>' p9 sck ----> sck serial clock
>' pA sdo ----> si serial data in
>' pB sdi <---- so serial data out
>' wp\ and reset\ tied high.
>'
>pmax con 1024 ' AT45D021 number of pages
> ' at 264 bytes per page
> ' 256kbytes+ FLASH
> ' +528 bytes RAM
>cmd var byte ' AT45D0xx command
>page var word ' which page?
>adrs var byte ' which byte?
> ' bytes 0-255 used for data
> ' bytes 256-263 not used in demo
>ix var byte ' general purpose index
>x var byte ' data byte to/from device
>
>msg data "why do we do it?" ' demo data
>
>atcs con 8 ' AT45Dxx chip select pin
>sck con 9 ' serial clock pin
>sdo con 10 ' serial data out pin
>sdi con 11 ' serial data in pin
>sdin var in11 ' serial input pin status, alias
>
>outs=%0000000111100001 ' p8 chip select is high
> 'fedcba9876543210
>dirs=%1111011111111111 ' pB is serial data input
> ' other pins as needed
>
>main:
>'
write demo data to buffer 1
> cmd=$84 ' write to buffer 1
> adrs=0 ' from the top
> gosub sndcmd ' send command
> for ix=0 to 15 ' send 16 bytes
> read msg+ix,x ' demo data bytes
> shiftout sdo,sck,msbfirst,[noparse][[/noparse]x\8] ' to buffer 1
> debug x ' show them
> next
> high atcs ' end of command
> debug cr
>'
>'
read back 16 bytes from buffer 1
> cmd=$54 ' read from buffer 1
> adrs=0 ' from the top
> gosub sndcmd ' send command
> for ix=0 to 15 ' read 16 bytes
> shiftin sdi,sck,msbpost,[noparse][[/noparse]x] ' from AT45D0xx
> debug x ' show them
> next
> high atcs ' end of command
> debug cr
>'
>'
erase & prog. a flash page from buffer 1
> cmd=$83 ' erase flash & write buffer 1
> random page ' pick a page at random
> page=page//pmax ' limit to valid pages
> debug hex4 page,cr ' show page#
> gosub sndcmd ' send command
> high atcs ' initiate the business
> gosub waitrdy ' wait for not_busy flag
>' pause 20 ' OR, just wait maximum
> ' OR, poll hardware busy\ flag
>'
>'
read back 16 bytes direct from flash
> cmd=$52 ' read flash page direct
> ' same flash page
> adrs=0 ' from the top
> gosub sndcmd ' send command
> for ix=0 to 15 ' read 16 bytes
> shiftin sdi,sck,msbpost,[noparse][[/noparse]x\8] ' from flash
> debug x ' show them
> next
> high atcs ' finished
> debug cr,cr
>'
> pause 2000
>goto main ' do it again
>end
>
>'
subroutine sends command to AT45Dxxx
>' send command, page (shifted left one), 8 bit address
>' send extra required clocking for commands $52 to $56
>' leave chip selected on return for completion of command
>sndcmd:
> low atcs ' chip select
> shiftout sdo,sck,msbfirst,[noparse][[/noparse]cmd\8,page<<1\16,adrs\8]
> if cmd>$56 then sndend
> shiftout sdo,sck,msbfirst,[noparse][[/noparse]0\8]
> if cmd>$52 then sndend
> shiftout sdo,sck,msbfirst,[noparse][[/noparse]0\16,0\8]
>sndend:
> return
>
>'
subroutine tests AT45Dxxx busy flag
>' needs up to 20 mS to complete erase+page write.
>' sends command and gets first data bit
>' polls busy flag until it equals 1,
>' or until watchdog times out=>error.
>' alternative--use 20 mS blind delay.
>' alternative--poll the hardware busy flag
>waitrdy:
> low atcs
> shiftout sdo,sck,msbfirst,[noparse][[/noparse]$ae\9]
> ' 8 bits of command $57 + one extra clock cycle
> ix=255
>wr1:
> ix=ix-1 ' watchdog
> of sdin-1*ix then wr1
> high atcs
> if ix=0 then ATerror
>return
>
>'
flash write failed
>ATerror:
> debug "flash busy",cr
>return
>
>
>
>- To subscribe -or- unsubscribe send e-mail to majordomo@p... and
>- put SUBSCRIBE stamps -or- UNSUBSCRIBE stamps in the body of the message
>
>
Here is a copy of what I kept, from the original Stamp List.
Have phun !
Regards,
Bruce
>Date: Mon, 8 Mar 1999 14:23:55 -0500
>From: Tracy Allen <emesys@c...>
>Subject: [noparse][[/noparse]STAMPS] atmel AT45D0xx serial flash
>To: "INTERNET:stamps@p..." <stamps@p...>
>Sender: owner-stamps@p...
>Reply-To: stamps@p...
>X-MIME-Autoconverted: from quoted-printable to 8bit by mh005.infi.net id
PAA25011
>
>Gregory Whitmore <gwhitmore@m...> wrote:
>> I have a few serial-flash-eeproms from ATMEL. They are
>> the AT45D041, 512k (I think). I was wondering if it
>> is possible to interface these with the stamp2. Maybe
>> to just hold data to send to a LCD. Can anyone help
>> with the coding? ....
>
>Bruce Bates <bvbates@i...> replied
>> ...big snip...
>> This is a rather sophisticated device you're working
>> with - to say the least.
>
>
>Gregory,
>
>I agree with Bruce. To take full advantage of this memory chip's
>capabilities you should be looking at a BS2SX with a whole bank dedicated
>to memory management.
>
>That said, I think you can do some useful stuff with it on a BS2. It could
>hold lots of messages for your LCD. With read-only messages, it won't
>require too much code.
>
>Here is a working (mileage may vary) demo, to get you started. There is a
>subroutine called "sndcmd" ("send command") that is called at the beginning
>of each cycle of instructions. It parses the page and address bits and
>sends the extra don't care bits if required. I hope this helps.
>
> -- Tracy Allen
> mailto:emesys@c...
> http://go.ourworld.nu/emesys/
>
>
>' demo program for ATMEL AT45D0xx flash/ram
>' (c) 1999, Tracy Allen, eme systems
>' demos commands for writing and reading
>' the RAM and the flash array.
>'
>' The hardware connections are:
>'
>' BS2 or BS2SX AT45D0xx
>' p8 atcs ----> cs\ chip select
>' p9 sck ----> sck serial clock
>' pA sdo ----> si serial data in
>' pB sdi <---- so serial data out
>' wp\ and reset\ tied high.
>'
>pmax con 1024 ' AT45D021 number of pages
> ' at 264 bytes per page
> ' 256kbytes+ FLASH
> ' +528 bytes RAM
>cmd var byte ' AT45D0xx command
>page var word ' which page?
>adrs var byte ' which byte?
> ' bytes 0-255 used for data
> ' bytes 256-263 not used in demo
>ix var byte ' general purpose index
>x var byte ' data byte to/from device
>
>msg data "why do we do it?" ' demo data
>
>atcs con 8 ' AT45Dxx chip select pin
>sck con 9 ' serial clock pin
>sdo con 10 ' serial data out pin
>sdi con 11 ' serial data in pin
>sdin var in11 ' serial input pin status, alias
>
>outs=%0000000111100001 ' p8 chip select is high
> 'fedcba9876543210
>dirs=%1111011111111111 ' pB is serial data input
> ' other pins as needed
>
>main:
>'
write demo data to buffer 1
> cmd=$84 ' write to buffer 1
> adrs=0 ' from the top
> gosub sndcmd ' send command
> for ix=0 to 15 ' send 16 bytes
> read msg+ix,x ' demo data bytes
> shiftout sdo,sck,msbfirst,[noparse][[/noparse]x\8] ' to buffer 1
> debug x ' show them
> next
> high atcs ' end of command
> debug cr
>'
>'
read back 16 bytes from buffer 1
> cmd=$54 ' read from buffer 1
> adrs=0 ' from the top
> gosub sndcmd ' send command
> for ix=0 to 15 ' read 16 bytes
> shiftin sdi,sck,msbpost,[noparse][[/noparse]x] ' from AT45D0xx
> debug x ' show them
> next
> high atcs ' end of command
> debug cr
>'
>'
erase & prog. a flash page from buffer 1
> cmd=$83 ' erase flash & write buffer 1
> random page ' pick a page at random
> page=page//pmax ' limit to valid pages
> debug hex4 page,cr ' show page#
> gosub sndcmd ' send command
> high atcs ' initiate the business
> gosub waitrdy ' wait for not_busy flag
>' pause 20 ' OR, just wait maximum
> ' OR, poll hardware busy\ flag
>'
>'
read back 16 bytes direct from flash
> cmd=$52 ' read flash page direct
> ' same flash page
> adrs=0 ' from the top
> gosub sndcmd ' send command
> for ix=0 to 15 ' read 16 bytes
> shiftin sdi,sck,msbpost,[noparse][[/noparse]x\8] ' from flash
> debug x ' show them
> next
> high atcs ' finished
> debug cr,cr
>'
> pause 2000
>goto main ' do it again
>end
>
>'
subroutine sends command to AT45Dxxx
>' send command, page (shifted left one), 8 bit address
>' send extra required clocking for commands $52 to $56
>' leave chip selected on return for completion of command
>sndcmd:
> low atcs ' chip select
> shiftout sdo,sck,msbfirst,[noparse][[/noparse]cmd\8,page<<1\16,adrs\8]
> if cmd>$56 then sndend
> shiftout sdo,sck,msbfirst,[noparse][[/noparse]0\8]
> if cmd>$52 then sndend
> shiftout sdo,sck,msbfirst,[noparse][[/noparse]0\16,0\8]
>sndend:
> return
>
>'
subroutine tests AT45Dxxx busy flag
>' needs up to 20 mS to complete erase+page write.
>' sends command and gets first data bit
>' polls busy flag until it equals 1,
>' or until watchdog times out=>error.
>' alternative--use 20 mS blind delay.
>' alternative--poll the hardware busy flag
>waitrdy:
> low atcs
> shiftout sdo,sck,msbfirst,[noparse][[/noparse]$ae\9]
> ' 8 bits of command $57 + one extra clock cycle
> ix=255
>wr1:
> ix=ix-1 ' watchdog
> of sdin-1*ix then wr1
> high atcs
> if ix=0 then ATerror
>return
>
>'
flash write failed
>ATerror:
> debug "flash busy",cr
>return
>
>
>
>- To subscribe -or- unsubscribe send e-mail to majordomo@p... and
>- put SUBSCRIBE stamps -or- UNSUBSCRIBE stamps in the body of the message
>
>
Comments
AWSOME!
thanks a zillion
ryan
Original Message
From: Bruce Bates <bvbates@i...>
To: <basicstamps@egroups.com>
Sent: Wednesday, April 19, 2000 4:57 PM
Subject: [noparse][[/noparse]basicstamps] [noparse][[/noparse]STAMPS] atmel AT45D0xx serial flash
> Ryan -
>
> Here is a copy of what I kept, from the original Stamp List.
>
> Have phun !
>
> Regards,
>
> Bruce
>
>
> >Date: Mon, 8 Mar 1999 14:23:55 -0500
> >From: Tracy Allen <emesys@c...>
> >Subject: [noparse][[/noparse]STAMPS] atmel AT45D0xx serial flash
> >To: "INTERNET:stamps@p..." <stamps@p...>
> >Sender: owner-stamps@p...
> >Reply-To: stamps@p...
> >X-MIME-Autoconverted: from quoted-printable to 8bit by mh005.infi.net id
> PAA25011
> >
> >Gregory Whitmore <gwhitmore@m...> wrote:
> >> I have a few serial-flash-eeproms from ATMEL. They are
> >> the AT45D041, 512k (I think). I was wondering if it
> >> is possible to interface these with the stamp2. Maybe
> >> to just hold data to send to a LCD. Can anyone help
> >> with the coding? ....
> >
> >Bruce Bates <bvbates@i...> replied
> >> ...big snip...
> >> This is a rather sophisticated device you're working
> >> with - to say the least.
> >
> >
> >Gregory,
> >
> >I agree with Bruce. To take full advantage of this memory chip's
> >capabilities you should be looking at a BS2SX with a whole bank dedicated
> >to memory management.
> >
> >That said, I think you can do some useful stuff with it on a BS2. It
could
> >hold lots of messages for your LCD. With read-only messages, it won't
> >require too much code.
> >
> >Here is a working (mileage may vary) demo, to get you started. There is a
> >subroutine called "sndcmd" ("send command") that is called at the
beginning
> >of each cycle of instructions. It parses the page and address bits and
> >sends the extra don't care bits if required. I hope this helps.
> >
> > -- Tracy Allen
> > mailto:emesys@c...
> > http://go.ourworld.nu/emesys/
> >
> >
> >' demo program for ATMEL AT45D0xx flash/ram
> >' (c) 1999, Tracy Allen, eme systems
> >' demos commands for writing and reading
> >' the RAM and the flash array.
> >'
> >' The hardware connections are:
> >'
> >' BS2 or BS2SX AT45D0xx
> >' p8 atcs ----> cs\ chip select
> >' p9 sck ----> sck serial clock
> >' pA sdo ----> si serial data in
> >' pB sdi <---- so serial data out
> >' wp\ and reset\ tied high.
> >'
> >pmax con 1024 ' AT45D021 number of pages
> > ' at 264 bytes per page
> > ' 256kbytes+ FLASH
> > ' +528 bytes RAM
> >cmd var byte ' AT45D0xx command
> >page var word ' which page?
> >adrs var byte ' which byte?
> > ' bytes 0-255 used for data
> > ' bytes 256-263 not used in demo
> >ix var byte ' general purpose index
> >x var byte ' data byte to/from device
> >
> >msg data "why do we do it?" ' demo data
> >
> >atcs con 8 ' AT45Dxx chip select pin
> >sck con 9 ' serial clock pin
> >sdo con 10 ' serial data out pin
> >sdi con 11 ' serial data in pin
> >sdin var in11 ' serial input pin status, alias
> >
> >outs=%0000000111100001 ' p8 chip select is high
> > 'fedcba9876543210
> >dirs=%1111011111111111 ' pB is serial data input
> > ' other pins as needed
> >
> >main:
> >'
write demo data to buffer 1
> > cmd=$84 ' write to buffer 1
> > adrs=0 ' from the top
> > gosub sndcmd ' send command
> > for ix=0 to 15 ' send 16 bytes
> > read msg+ix,x ' demo data bytes
> > shiftout sdo,sck,msbfirst,[noparse][[/noparse]x\8] ' to buffer 1
> > debug x ' show them
> > next
> > high atcs ' end of command
> > debug cr
> >'
> >'
read back 16 bytes from buffer 1
> > cmd=$54 ' read from buffer 1
> > adrs=0 ' from the top
> > gosub sndcmd ' send command
> > for ix=0 to 15 ' read 16 bytes
> > shiftin sdi,sck,msbpost,[noparse][[/noparse]x] ' from AT45D0xx
> > debug x ' show them
> > next
> > high atcs ' end of command
> > debug cr
> >'
> >'
erase & prog. a flash page from buffer 1
> > cmd=$83 ' erase flash & write buffer 1
> > random page ' pick a page at random
> > page=page//pmax ' limit to valid pages
> > debug hex4 page,cr ' show page#
> > gosub sndcmd ' send command
> > high atcs ' initiate the business
> > gosub waitrdy ' wait for not_busy flag
> >' pause 20 ' OR, just wait maximum
> > ' OR, poll hardware busy\ flag
> >'
> >'
read back 16 bytes direct from flash
> > cmd=$52 ' read flash page direct
> > ' same flash page
> > adrs=0 ' from the top
> > gosub sndcmd ' send command
> > for ix=0 to 15 ' read 16 bytes
> > shiftin sdi,sck,msbpost,[noparse][[/noparse]x\8] ' from flash
> > debug x ' show them
> > next
> > high atcs ' finished
> > debug cr,cr
> >'
> > pause 2000
> >goto main ' do it again
> >end
> >
> >'
subroutine sends command to AT45Dxxx
> >' send command, page (shifted left one), 8 bit address
> >' send extra required clocking for commands $52 to $56
> >' leave chip selected on return for completion of command
> >sndcmd:
> > low atcs ' chip select
> > shiftout sdo,sck,msbfirst,[noparse][[/noparse]cmd\8,page<<1\16,adrs\8]
> > if cmd>$56 then sndend
> > shiftout sdo,sck,msbfirst,[noparse][[/noparse]0\8]
> > if cmd>$52 then sndend
> > shiftout sdo,sck,msbfirst,[noparse][[/noparse]0\16,0\8]
> >sndend:
> > return
> >
> >'
subroutine tests AT45Dxxx busy flag
> >' needs up to 20 mS to complete erase+page write.
> >' sends command and gets first data bit
> >' polls busy flag until it equals 1,
> >' or until watchdog times out=>error.
> >' alternative--use 20 mS blind delay.
> >' alternative--poll the hardware busy flag
> >waitrdy:
> > low atcs
> > shiftout sdo,sck,msbfirst,[noparse][[/noparse]$ae\9]
> > ' 8 bits of command $57 + one extra clock cycle
> > ix=255
> >wr1:
> > ix=ix-1 ' watchdog
> > of sdin-1*ix then wr1
> > high atcs
> > if ix=0 then ATerror
> >return
> >
> >'
flash write failed
> >ATerror:
> > debug "flash busy",cr
> >return
> >
> >
> >
> >- To subscribe -or- unsubscribe send e-mail to majordomo@p...
and
> >- put SUBSCRIBE stamps -or- UNSUBSCRIBE stamps in the body of the message
> >
> >
>
>
>