PDA

View Full Version : SD Card reader problem



Philldapill
01-10-2008, 09:18 AM
I've been having trouble trying to get a simple SD Card to work with the prop. It's a 512MB, SanDisk SD Card. I'm going to attach a schematic of how I have it set up. I have tried formatting the card through a card reader. I used the windows formatting utility to do this and the only two options, as far as FAT formatting goes, were "FAT" and "FAT32". As I understand it, FAT is FAT16, which I need. When I do not have anything connected to the pins(8..11), I get error -20. When I have the card connected, or the pull up resistors, I get the "InitSDCard mount" error string. I have no idea what's going on but I can answer any troubleshooting questions if you guys can help.

Philldapill
01-10-2008, 12:11 PM
Adding to the list: Now I've tried pull-down resistors in place of the pull-up and both combinations on every pin. Still no luck. HELP

Oldbitcollector (Jeff)
01-10-2008, 12:28 PM
Dump your pull-down resistors and take a look at the Cookbook link below for an example of SD hookup.
(Hope it helps)

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?

Getting started with the Protoboard? - Propeller Cookbook (http://ucontroller.com/Propeller%20Protoboard%20Designs%20for%20the%20Beg inner.pdf)
Got an SD card? - PropDOS (http://www.orrtech.net/propdos/)
A Living Propeller FAQ - The Propeller Wiki (http://propeller.wikispaces.com/)
(Got the Knowledge? Got a Moment? Add something today!)

Philldapill
01-10-2008, 12:40 PM
The cookbook was what I was originally going by. I've seen other sources say to use pullup/down resistors at various locations, yet the cookbook doesn't use any and it keeps pins 1 and 9 floating. This method should work? Is the FAT filesystem the correct one for SD?

Philldapill
01-10-2008, 12:59 PM
Ok, I don't want to jynx myself, but I think I got it working... I just switched the pins from the default, 8-11, to pins 0-3 and to my suprise I saw that it passed the first mountSDvol function. It later opened the file "autoexec.bas" after I plugged the card into my PC and created it. I think I'm good to go *crosses fingers*.

Philldapill
01-10-2008, 01:21 PM
Looks like I spoke too soon. However, the card is being recognized. Now, how do you actually WRITE to the darn thing? I've tried mass.dec and mass.str with no luck. When I call mass.openfile with "w" as the read/write parameter, I get error -26. It passes when it is "r"

Mike Green
01-10-2008, 01:32 PM
-26 is "Bad cluster number"
mode = "w" deletes the file, then opens an empty new file
mode = "a" positions the file at the end and opens it for writing
mode = "r" opens the file for reading (writing not allowed)
mode = "d" deletes the file

I don't know why you're getting the error. The openFile routine in DongleBasic just calls Rokicki's popen routine
if the filename doesn't start with a colon (":"). A leading colon opens the file using a 32K EEPROM page instead
of the SD card.

mass.dec and mass.str should work once the file is opened for writing.

Philldapill
01-10-2008, 01:40 PM


 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ ‘’“”•–—˜™š›œžŸ* ; r[ŠV$ |‹F=}F)}Œ‰N‰N–} f‹FfFf‹f^JJŠF

...Never looked so good!
NOW openfile with a w works. added the following code after the call:
repeat i from 0 to 255
mass.out(i)

And that's what it wrote! Thanks Mike and OldBitCollector!

Philldapill
01-10-2008, 01:54 PM
Btw, Mike, I am unfamiliar with "BB_FullDuplexSerial" and it's use in these files. Is it for debug purposes such as displaying information on the screen? If so, I can delete all the messages in the files in order to conserve space, correct? After all, this is a massive set of files.

Philldapill
01-10-2008, 02:08 PM
New Question. Once you have written to the file, how do you read from it? I'm looking at most of these read functions and they look like they are just for eeprom, except getByte, but it doesn't seem to work right.

mosquito56
01-10-2008, 11:19 PM
I installed brians spi card reader and ran Tomas Rokicki's test program. Test program seemsto be working ok. I don't get any numbers but I do see the files I added from the pc to the 1gig card.
I loaded up donglebasic and I don't get anything on either propterminal or hyperterminal. I don't have an eeprom hooked up at the moment("Don't ask if you have kids"). Does the dongle require an eeprom to work correctly? Can I disable till my order comes in from parallax?

Another problem is changing the baudrate on propterminal. It whites out all the speeds and I can't change it to 9600.
Any help appriciated.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mosquito: An animal which buzzes in your ear and never stops. He may byte you, he may nibble you, but you will know you were bit.


Technologically challenged individual, Please have pity.

Mike Green
01-10-2008, 11:39 PM
Philldapill,
BB_FullDuplexSerial is a modified version of the FullDuplexSerial driver that includes a few extra methods mostly for handling a "break key" and a configurable receive and transmit buffer size with the sizes defined in BB_Definitions.spin.

To read a file, you have to open it in read mode ("r"), then you can use getByte (or readFile). In the Basic interpreter, you would use READ or FILE as a function call in an expression.

mosquito56,
I've not tested any of the FemtoBasic derivatives without an EEPROM connected. They should work. I normally download to RAM for testing purposes. DongleBasic checks for the presence of EEPROM when it's looking for a saved program to automatically run, but will ignore the EEPROM if there's any error.

I've used Hyperterminal as a console for DongleBasic. It seems to work fine. I haven't tried PropTerminal and I can't help you there.

mosquito56
01-10-2008, 11:55 PM
working, Time to rtfm thanx

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mosquito: An animal which buzzes in your ear and never stops. He may byte you, he may nibble you, but you will know you were bit.


Technologically challenged individual, Please have pity.

mosquito56
01-11-2008, 12:30 AM
i feel like i'm back in the 80's. We have a trs-80 with a 1 gig hd, lol. Well done great job

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mosquito: An animal which buzzes in your ear and never stops. He may byte you, he may nibble you, but you will know you were bit.


Technologically challenged individual, Please have pity.

Oldbitcollector (Jeff)
01-11-2008, 01:55 AM
A 32bit TRS-80... :)

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?

Getting started with the Protoboard? - Propeller Cookbook (http://ucontroller.com/Propeller%20Protoboard%20Designs%20for%20the%20Beg inner.pdf)
Got an SD card? - PropDOS (http://www.orrtech.net/propdos/)
A Living Propeller FAQ - The Propeller Wiki (http://propeller.wikispaces.com/)
(Got the Knowledge? Got a Moment? Add something today!)

Philldapill
01-11-2008, 04:46 AM
Here's another for you guys... I am now able to read/write to the SD Card no problem. The only thing is, I can't write linefeeds/returns into a text file and have notepad read it as a return. Instead, I get a "box" character where the linefeed should be. Any idea on how to write the correct character?

Paul Baker
01-11-2008, 06:04 AM
You need to trap special characters in stream ($0D carriage return $13 line feed etc) and process them seperately (alter cursor position etc), take a look at VGA_text or TV_text for ways this is accomplished.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

Philldapill
01-11-2008, 06:32 AM
Yeah, that's actually what I was using when writing from the prop to the card. I tried writing to the card in a .CSV format and opening with Excel. When opened with excel, mass.out(13)(or $0D) read into excel as a line return, i.e. a new row. This is actually what I wanted as I want to be able to log info on an excel spreadsheet and analyze it that way. So, basically, I guess it works now, although $0D is still read by notepad as a rectangle character but in excel it's fine... I'm assuming it's just how each program interprets the font set. Thanks Guys!