sd card troubles
Pasha
Posts: 56
I am using the PropRPM it is working well for me. I am trying to attatch an sd card reader, but have been so far unsuccessful. I have worked a total of about 4 hours on this problem, and just need some good advice. I am using a floppy edge connector as my reader. I know that all the pins on my card are touching the pins on the reader. I have connected sd card pin 1 to prop pin 3, pin 2 to prop pin 2, pin 3 to gnd, pin 4 to +3.3V, pin 5 to prop pin 1, pin 6 to gnd, pin 7 to prop pin 0. other than this I have pulled up all pins (except power and ground pins) via 10K resistors to +3.3v. I keep getting the error message -41 even when there is no card in the reader. Please any suggestions would be welcome. when I tried it without any pullup resistors, I always got -20 even though I know my card was correctly formated, connected, and all wires were conducting correctly.
Comments
This info is at the bottom of this page:
http://www.rayslogic.com/propeller/Programming/SD_Card/SD_Card.htm
Also, make sure it's not·the newer type "SDHC" card.
I disconnected the pullup resistors, because that was when i started to get the -41 error. I only got one of my cards to work. [noparse]:([/noparse] will try formatting again tell me any luck you have.
10k or 20k or 100k does not matter. (I normally connect only one at the CS pin).
I've used something like a "floppy edge connecter" at the beginning and had always contact problems, because the contacts of my SD cards are a little bit sunked in the plastic enclosure.
Since I use a real SD card socket it works well.
Andy
The series resistors "slow the signal down" (really, there's an RC time constant coming into play here).
If you don't have the series resistors, and it still only works with sdspi and not with the faster ones,
it's time to look at your signal path and see what might be causing problems. These are not terribly
fast signals (around 20MHz) but it still doesn't take a whole lot of capacitance or inductance to slow
them down.
In general, I would always try to use a real SD socket, and not some kludge. Spend a few bucks
and wait for it to come in the mail and save yourself a ton of aggravation. To me this fits squarely
in the "use the right tools" category, similar to the way you never want to use a pair of cheap
slip-joint pliers on nuts, or common rubber mallets on the side of your new plasma HDTV because
the picture isn't coming in well.
is many yards. I think it's about a nanosecond a foot. The data is latched on a clock
edge, but the signal changes on the other clock edge, so there's quite a lot of setup and
hold time.
Ps. I tried adding one pullup resistor between 3.3v and cs, and nothing changed. still -20 error. I know my sd card is correctly formated, because it always works with sdspi
It should work with no resistors at all. Try cranking the prop clock down from 80MHz to say 10MHz and see if that works
(of course your TV won't work there, so you'll have to use perhaps a serial connection or something to verify it).
There is no easy way that I know of to measure capacitances so low, but frankly, I'm not sure that's your problem.
It *might* be power issues; do you have a capacitor close to the card between +3.3V and ground? Maybe the
power lines are too long.
It may be time to slap a scope on the pins. Do you have a scope, or a friend who has one?
Frankly, though, this stuff works under such adverse conditions that I'm still tempted to blame some sort of
programming error or the like.
I will try the speed thing. Maybe just have it run an led if there are no problems. Thanks Rockocki. The real reason I am using an sd card is because I am building a robot, and i am pretty sure I will need to reprogram it a lot of times. I am not building it on the board I have to program the Eeprom, so I would like to put the program on the sd card and transfer it from there at run time. I should be able to do this albeit slowly even with sdspi.
will post results
this is a european source which also ships to Ukraine (they have an ukraine translation of the site too).
www.tme.eu/ua/
Andy
·
The loader object from FemtoBasic is designed to be used on its own (separate from the rest of FemtoBasic) to do EEPROM or low level SD card I/O.
Note that your SD card should be formatted with 32K clusters. If the file to be loaded spans more than one cluster and they're not sequential, the file won't load properly. Formatting with 32K clusters eliminates this issue.
With small clusters (like 2K) you have to be careful about how you create your files so that they're at least 32K in length and contiguous. If you never delete files and never expand them in size, you'll be ok since new files will always be allocated at the end of the existing files.
You should still be able to format a 16MB card using 32K clusters using Linux or an old version of Windows (like Windows 98). As I recall, both allowed you to specify the cluster size explicitly.
Is there a way I can mod the fsrwfemto file to use sdspi instead of some special assembly one. My card interface isn't working at that speed.
2) The low level SPI routines in sdspiFemto are called "spiSendByte" and "spiRecvByte". With an 80MHz system clock, the SD card clock speed is about 3MHz with a 100ns wide transmit clock pulse and a 50ns wide receive clock pulse. These can be slowed down by adding NOP instructions to these low level routines. The easiest way to test this out would be to change the Propeller's system clock speed by changing the _clkmode constant definition and using pll8x instead of pll16x. This will give you a 40MHz system clock and slow down everything including the SD card speed by a factor of two. Other I/O like a keyboard and display or serial I/O will adjust appropriately.
ps. Will the tv work?
If the total number of clusters is then < 4096, you'll get fat12. If it's less than 65,536, you'll get fat16.
Otherwise you'll get fat32. (This is rough; the numbers above are not exact.)
If your card is so small that 32Kbyte clusters give you fat12, that means your card is only about 128MB or
less; I was not aware such cards even existed anymore.
In any case, I recommend people use 65Kbyte clusters; there's no good reason not to unless you have
*very* small cards.