Since I just got the 28X1 parts I thought I would try to interface an SD card to the 28X1 via the new SPI commands. I don't have anything working yet, but I thought I would post my thoughts and look for suggestions. I put the card in a socket and powered it. I hooked up the clk, spin and spo lines (Via voltage dividers to drop these to 3.3 V). I used another pin to control the CS line. (Again dropped to 3.3V)
I tried the sample code from the SPI tutorial:
symbol cs = 7
init:
hspisetup spimode11e, spimedium ‘ spi mode 1,1
low cs ‘ enable chip select
hspiout (6) ‘ send write enable
high cs ‘ disable chip select
low cs ‘ enable chip select
hspiout (1,0) ‘ remove block protection
high cs ‘ disable chip select
pause 5 ‘ wait write time
main:
low cs ‘ enable chip select
hspiout (6) ‘ send write enable
high cs ‘ disable chip select
low cs ‘ enable chip select
hspiout (2,0,5,25) ‘ write 25 to address 5
high cs ‘ disable chip select
pause 5 ‘ wait write time of 5ms
low cs ‘ enable chip select
hspiout (6) ‘ send write enable
high cs ‘ disable chip select
low cs ‘ enable chip select
hspiout (3,0,5) ‘ send read command, address 5
hspiin (b1) ‘ shift in the data
high cs ‘ disable chip select
low cs ‘ enable chip select
hspiout (4) ‘ send write disable
high cs ‘ disable chip select
sertxd (#b1)
pause 1000
goto main
I either got 255 off b1 or 0 depending on how things were powered.
** Note the code as presented is missing the definition of cs.
Then I started in on the datasheet:
http://web.archive.org/web/20041029000445/http://www.sandisk.com/pdf/oem/ProdManualSDCardv1.9.pdf
I am hoping someone else has done this already and will save me a lot of grief!
(Or maybe I will just stick with the 24LC EEPROMS which work great!)
have fun,
mmason
I tried the sample code from the SPI tutorial:
symbol cs = 7
init:
hspisetup spimode11e, spimedium ‘ spi mode 1,1
low cs ‘ enable chip select
hspiout (6) ‘ send write enable
high cs ‘ disable chip select
low cs ‘ enable chip select
hspiout (1,0) ‘ remove block protection
high cs ‘ disable chip select
pause 5 ‘ wait write time
main:
low cs ‘ enable chip select
hspiout (6) ‘ send write enable
high cs ‘ disable chip select
low cs ‘ enable chip select
hspiout (2,0,5,25) ‘ write 25 to address 5
high cs ‘ disable chip select
pause 5 ‘ wait write time of 5ms
low cs ‘ enable chip select
hspiout (6) ‘ send write enable
high cs ‘ disable chip select
low cs ‘ enable chip select
hspiout (3,0,5) ‘ send read command, address 5
hspiin (b1) ‘ shift in the data
high cs ‘ disable chip select
low cs ‘ enable chip select
hspiout (4) ‘ send write disable
high cs ‘ disable chip select
sertxd (#b1)
pause 1000
goto main
I either got 255 off b1 or 0 depending on how things were powered.
** Note the code as presented is missing the definition of cs.
Then I started in on the datasheet:
http://web.archive.org/web/20041029000445/http://www.sandisk.com/pdf/oem/ProdManualSDCardv1.9.pdf
I am hoping someone else has done this already and will save me a lot of grief!
(Or maybe I will just stick with the 24LC EEPROMS which work great!)
have fun,
mmason