Close
0%
0%

Propeller Weekender: SD-Card Experimentation!

Testing the SD-Card on the Parallax Propeller!

Similar projects worth following
This is not a full tutorial on starting Propeller - there are various documentations around the Parallax website on that. I'm here on how to get the SD-Card and the Propeller working.

If you do not know about Parallax's Propeller, you can get the info here: https://www.parallax.com/product/p8x32a-d40

Key Features from the Website:

  • Multicore processing simplifies designs subject to asynchronous requirements
  • DIP package for easy prototyping with a breadboard
  • Built-in Spin language is easy to learn 
  • PropGCC support provides a familiar feel for C/C++ programmers
  • Propeller Assembly language supports deterministic timing using single-path, multi-decision techniques
  • Internal or external clock sources provide flexible speed options 

This page explains how am I going to get the SD-Card and the Propeller to work. Searching around the net, the drivers for the SD-Card looks quite old and sparse, and the challenge is to get these to work.

  • Reading a file now!

    NYH-workshop08/18/2019 at 13:30 0 comments

    So after messing and futzing around with their novel Spin language (I suspect it's a hybrid of Python, some C and probably Pascal?) I managed to coax that thing to print out an excerpt from the Propeller Manual. (source: https://www.parallax.com/sites/default/files/downloads/P8X32A-Web-PropellerManual-v1.2.pdf

    I named the text file "textfile.txt" and written the excerpt into it :

    The Propeller chip is designed to provide high-speed processing for embedded systems while
    maintaining low current consumption and a small physical footprint. In addition to being
    fast, the Propeller provides flexibility and power through its eight processors, called cogs,
    that can perform simultaneous independent or cooperative tasks, all while maintaining a
    relatively simple architecture that is easy to learn and utilize.

    And also the code to read the file:

    { FSRW Test }
    
    
    CON
            _clkmode = xtal1 + pll16x                                               'Standard clock mode * crystal frequency = 80 MHz
            _xinfreq = 5_000_000
    
            SDO = 15
            SDI = 13
            SCK = 14
            CS  = 16
    
    VAR
      long symbol
      byte isMounted
      byte textBuf[512]
      byte bufCount
       
    OBJ
      fsrw: "fsrw.spin"
      pst: "Parallax Serial Terminal.spin"
      spisd: "safe_spi.spin"
      
    PUB main
    
      DIRA[3] := 1   
      pst.Start(115200)
      pst.Str(String("Hello World Propeller!",13))
    
      bytefill(@textBuf, 0, 128)
      isMounted := fsrw.mount_explicit(SDO, SCK, SDI, CS)
    
      if(isMounted == 0)
        pst.Str(String("SD-Card Detected!",13))
      else
        pst.Str(String("SD-Card error or not found!",13))
        repeat
          'wait here and blink LED for 500ms if error or not found!
          OUTA[3] := 0
          waitcnt(cnt + (clkfreq/2))
          OUTA[3] := 1
          waitcnt(cnt + (clkfreq/2))
    
      fsrw.Seek(0)    
      pst.Str(String("Reading SD Card!",13))
      if( fsrw.popen(String("textfile.txt"), "r") == 0 )
         pst.Str(String("File is found, reading it now!",13))
         if( fsrw.pread(@textBuf, 512) < 0 )
            pst.Str(String("Reached end of the file!",13))
         pst.Str(@textBuf)   
      else
        pst.Str(String("File not found!",13))
    
      pst.Str(String(13))    
      fsrw.pclose    
      waitcnt(cnt + (clkfreq))
      pst.Str(String("Done, unmount!",13))
      fsrw.unmount
    
    
      repeat
    
    
    PRI private_method_name
    
    
    DAT
    name    byte  "string_data",0        
            

    And the output:

    Success! That'll be the reference for me (and the readers) to write more code for the Propeller.

  • SD-Card detected!

    NYH-workshop08/18/2019 at 09:59 0 comments

    I got myself a bunch of these Propeller chips and the Prop tool back in late 2010 when I have already graduated. The tough part was getting these libraries to work. I was very young at that time and inexperienced, and tried to get Propeller to work with SD-Card, but failed miserably. 

    Many years later, I chanced upon these stuff when I'm cleaning the room. Maybe I can give it a try again? What problems would I see again?

    Here are the bare minimum to connect the SD-Card to the Propeller:

    Looks fine eh? Oh well, back then I did not bother to put the pull-ups. Prolly why it kept failing. In the schematic, it's not labelled, but it's usually 10K.

    I got these pieces of code from http://obex.parallax.com/object/33. That was the simplest, and doesn't look like the drivers are scattered all over the place.

    Then the fun part begins - I try to get it to be detected. That was that itch I wanna scratch since 2010:

    { FSRW Test }
    
    CON
            _clkmode = xtal1 + pll16x                                               'Standard clock mode * crystal frequency = 80 MHz
            _xinfreq = 5_000_000
    
            SDO = 15
            SDI = 13
            SCK = 14
            CS  = 16
    
    VAR
      long  symbol
      byte isMounted
       
    OBJ
      fsrw: "fsrw.spin"
      pst: "Parallax Serial Terminal.spin"
      spisd: "safe_spi.spin"
      
    PUB main
      
      pst.Start(115200)
      pst.Str(String("Hello World Propeller!"))
      
      isMounted := fsrw.mount_explicit(SDO, SCK, SDI, CS)
    
      if(isMounted == 0)
        pst.Str(String("SD-Card Detected!"))
      else
        pst.Str(String("SD-Card error or not found!"))  
          
      DIRA[3] := 1
    
      repeat
        OUTA[3] := 0
        waitcnt(cnt + (clkfreq/2))
        OUTA[3] := 1
        waitcnt(cnt + (clkfreq/2))
    
    
    PRI private_method_name
    
    
    DAT
    name    byte  "string_data",0        
            

     Did it work? At the start, no. It hung after the "mount_explicit".

    I searched around for an hour or so. Then went to nap. After the nap I looked at the breadboard and I found the SD-Card didn't get powered up (the little red and black wires below the pull-up resistors):

    Damn, I looked really stupid on that one! Connecting to it, it's all working!

    What am I gonna do next? It's simple: I'm trying to see if I can read or write something on it!

    Firstly, if it doesn't get detected or hang up:

    • Flip the SDI and SDO pin numbers on the "CON" area.
    • Make sure the SD-Card is powered.
    • Make sure the SD-Card is fully inserted into the slot!

View all 2 project logs

Enjoy this project?

Share

Discussions

cluso wrote 08/30/2019 at 22:40 point

Just noticed the full pic. Pin 29 MUST be connected to GND. Otherwise the PLL is likely to blow!!!

  Are you sure? yes | no

NYH-workshop wrote 09/01/2019 at 04:13 point

Hi cluso, I have already connected this pin29 to the GND. Thanks for pointing that out too! Updating the pic now. :)

  Are you sure? yes | no

cluso wrote 08/26/2019 at 21:40 point

There doesn't appear to be any bypass caps. You will need them!

The SD card will require 100nF and 10uF good quality capacitors right at the socket pins! Pullups are not required although I always include one 10K on the /CS pin. If it's not there then you can detect when a card is plugged in as it has its' own pullup. The other pullups can help if you are plugging in/out with the power on although I never advise this.

You'll need at least 100nF at each set of power pins on the propeller chip too, and possibly 10uF and 100nF at the power input to the board.

Make sure you ALWAYS connect ALL power pins and ALL ground pins on any chip as otherwise you may damage it, and keep those lines short as possible.

Sadly, if you had asked for help on the Parallax Propeller Forum you would have been given this help. Engineers know these design requirements, but sadly, it's not common knowledge amongst hobbyists.

Cluso99

  Are you sure? yes | no

NYH-workshop wrote 09/01/2019 at 04:20 point

Thanks cluso for the helpful feedback. I have added these capacitors near the SD-Card too! :)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates