Shop OBEX P1 Docs P2 Docs Learn Events
SD Card reader problem — Parallax Forums

SD Card reader problem

PhilldapillPhilldapill Posts: 1,283
edited 2008-01-10 23:32 in Propeller 1
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.

Comments

  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-10 05:11
    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)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-01-10 05:28
    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
    Got an SD card? - PropDOS
    A Living Propeller FAQ - The Propeller Wiki
    (Got the Knowledge? Got a Moment? Add something today!)

  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-10 05:40
    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?
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-10 05:59
    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*.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-10 06:21
    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 GreenMike Green Posts: 23,101
    edited 2008-01-10 06:32
    -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.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-10 06:40


    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[noparse][[/noparse]\]^_`abcdefghijklmnopqrstuvwxyz{|}~€
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-10 06:54
    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.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-10 07:08
    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.
  • mosquito56mosquito56 Posts: 387
    edited 2008-01-10 16:19
    · I installed brians spi card reader and ran Tomas Rokicki's test program. Test program seems·to 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 GreenMike Green Posts: 23,101
    edited 2008-01-10 16:39
    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.
  • mosquito56mosquito56 Posts: 387
    edited 2008-01-10 16:55
    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.
  • mosquito56mosquito56 Posts: 387
    edited 2008-01-10 17:30
    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)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-01-10 18:55
    A 32bit TRS-80... [noparse]:)[/noparse]

    OBC

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

    Getting started with the Protoboard? - Propeller Cookbook
    Got an SD card? - PropDOS
    A Living Propeller FAQ - The Propeller Wiki
    (Got the Knowledge? Got a Moment? Add something today!)

  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-10 21:46
    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 BakerPaul Baker Posts: 6,351
    edited 2008-01-10 23:04
    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
    Propeller Applications Engineer

    Parallax, Inc.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-10 23:32
    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!
Sign In or Register to comment.