element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Cypress Kits
  • Products
  • Dev Tools
  • Cypress Kits
  • More
  • Cancel
Cypress Kits
Forum PSoC 4 Pioneer Kit Community Project#050 – SD Card Example
  • Blog
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Cypress Kits requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 30 replies
  • Subscribers 21 subscribers
  • Views 859 views
  • Users 0 members are here
  • 100projects
Related

PSoC 4 Pioneer Kit Community Project#050 – SD Card Example

cy.wbz
cy.wbz over 8 years ago

Hello!

 

Today we are starting a short series targeting SD memory cards. In this first example we are introducing users to the SD card using the custom SD card component. This component will expose simple API level commands to read from and write to the SD card. In this example we are targeting a 2gig SD memory card.


  • PSoC 4 Pioneer Kit
  • SD Card shield
  • 2 gig SD card

 

 

Forum Post Attachments:

 

At the bottom of this post we are including the following items:

  • Example Project Zip File
  • Zip File of Images
    • Project Schematic
    • Component Configurations
  • Custom Component Datasheet

 

Components Used:

 

The user can download the example project at the bottom of this post. The project uses the following list of Creator Components:

  • SD Card
  • CyClock
  • CyPins

 

The components are configured by right clicking on the component in your Top Design schematic view and selecting Configure. Please enable the following selections in the Configuration windows for the listed components above.

 

Firmware Description:

 

The main.c firmware is included in the example project. Please review the commented sections for more details.

 

In this example we ship a custom SD card component and component datasheet to describe the functionality and available APIs and source files. The Component datasheet has been attached to this post. We have used custom components in the past so please refer to those examples for guidance. You will need to import the SD card component from the example project into your design if you want to use the custom component.

 

 

This SD card component uses the SPI interface to communicate to the SD card. The SPI interface is part of the SD card component and should be configured in the pin selections in the PSoC Creator DWR window.


In this example we show the user how to setup and initialize the SD card on the SD card shield. The remaining set of code in the example shows the user how to perform a number of common actions on the SD card:


  • Write File
  • Append File
  • Read File
  • Rename File
  • Copy File
  • Delete File

 

An important note before using the SD card, you will need to format the SD card prior to using it in this example. To format the SD card please navigate to the SD card web site to download the SDFormatter tool. Formatting the SD card is a one-time activity to enable it’s use. You will want to use a SD card reader or your SD card slot on your PC.

 

https://www.sdcard.org/downloads/formatter_4/

 

Hardware Connections:

 

The SD card shield uses the 6 pin header for SPI communications. This header on the Pioneer board is, by default, not populated. You will need to solder on a 6 pin header to enable this connection. The Seeedstudio SD card reader uses the 6 pin header to communicate over SPI to the SD card. Once you have added this header connect the Seeedstudio shield to the Pioneer kit.

 


 

Test Your Project:

 

Program the example into the PSoC 4 kit. Edit and play around with the commented code to create new files. Then remove the SD card and plug into an SD card reader or PC that has an SD card port to verify the PSoC 4 actions.

 

 

I hope this example can help you in your design.

 

Best,

Matt

Attachments:
SDCard_Mass_Storage_Example.zip
6305.Project Images.zip
SDCard_V1_0.pdf
  • Reply
  • Cancel
  • Cancel

Top Replies

  • Former Member
    Former Member over 8 years ago in reply to Former Member +2

    Hi Andrew,

     

    Few things to check:

    1. You need to format your SDCard with SDFormatter (https://www.sdcard.org/downloads/formatter_4/). Windows formatting does not create a boot record.

    2. SD Card should not…

  • Former Member
    Former Member over 8 years ago in reply to Former Member +2

    Sriram V S,

     

    Thank you, thank you, thank you! I was using a 16GB SD card (I must have missed the 2GB limit in my enthusiasm to try things out). Using a smaller card, everything is working well with my data…

  • danadak
    danadak over 8 years ago +1

    I am trying to bring up the shield and project in Creator 3.0. Some ques/observations -

     

    1) In 3.0 Creator produces ~ 40 warnings on type mismatches used in code. But compiles.

     

    2) In Creator debug I cannot…

  • DAB
    DAB over 8 years ago

    Hi Matt,

     

    I have been waiting for this example.  I want to set up the Psoc 4 as a data logging system.

     

    Hopefully I can get this project done before your series is over.

     

    Thanks

    DAB

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • jesusantoniocar
    jesusantoniocar over 8 years ago

    Hello Matt.

    Thanks for this project.

    Please could locate in the post an additional photo of  the sd shield on the opposite side, I would see the connection or the type of header that I soldered to the board, (pioneer kit) to make the connection with the sd arduino shield.

     

     

    thanks.

     

    Jesus Antonio.

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 8 years ago

    I've been trying to use the sample code with this shield: https://www.sparkfun.com/products/9802   All it manages to do is cause me to have to reformat the card. I've changed the CS pin to 2[6] to match the microSD card, but I've made no other changes. Is there something I'm missing? Could this be an incompatibilty with microSD cards or the shield I'm using? If anyone has any ideas, that would be great, otherwise I'll just keep hacking away at it.

     

    Thanks.

     

    -Andrew

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 8 years ago

    Andrew,

     

    I too am having problems. I am using an Adafruit card (real time clock and SD card support for data acquisition). I have discovered what appears to be an error in the main.c sample code. Line 38 is:

     

        SDCard_Select(SDCard_DISABLE);

     

    I believe it should be: SDCard_Select(SDCard_ENABLE). However, even after making that change (and necessary pinout changes for the Adafruit shield), I am unable to talk to the SD card. Stumped at this point.......

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 8 years ago in reply to Former Member

    Hi Andrew,

     

    Few things to check:

    1. You need to format your SDCard with SDFormatter (https://www.sdcard.org/downloads/formatter_4/). Windows formatting does not create a boot record.

    2. SD Card should not be high capacity. i.e. the size of card should be less than 2Gb. The file system cannot handle high capacity cards.

    3. There are two CS pins; in which you should use only the SD_CS pin and ignore the _ss0 pin.

    4. PSoC4 should operate at 3.3V

     

    Let me know if it still doesn't work. Can you also share the pin assignment, so that I can cross check with the shield's schematic you are using.

     

    Regards,

    Sriram

    • Cancel
    • Up +2 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 8 years ago in reply to Former Member

    Hi Mark,

     

    The SDCard_Select(SDCard_DISABLE); is intentional and does not interrupt the normal working of the code. Can you please answer the following questions, so that I can get to know the setup?

     

    1. Can you please make sure that you are following as per my post above - points 1 to 4?

    2. Please share the schematic and pin assignment (PSoC Creator) for your project.

     

    Regards,

    Sriram V S

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 8 years ago in reply to Former Member

    Sriram V S,

     

    Thank you, thank you, thank you! I was using a 16GB SD card (I must have missed the 2GB limit in my enthusiasm to try things out). Using a smaller card, everything is working well with my data logging shield (https://www.adafruit.com/product/1141, schematic is available there). My next challenge is talking to the on-board Real Time Clock.

     

    For the benefit of others, the revised PSoC4 pin assigments are:

     

    SDCard:SPIM:sclk_m      P0[6]

    SDCard:SPIM:miso_m     P3[1]

    SDCard:SPIM:mosi_m     P3[0]

    SDCard:SD_CS               P3[4]

    • Cancel
    • Up +2 Down
    • Reply
    • Cancel
  • danadak
    danadak over 8 years ago

    I am trying to bring up the shield and project in Creator 3.0. Some ques/observations -

     

    1) In 3.0 Creator produces ~ 40 warnings on type mismatches used in code. But compiles.

     

    2) In Creator debug I cannot get by the code line 46 (hangs here).

     

          

    cardInfo = SDCard_InitCard();

     

     

    And I see RGB LED on Pioneer board blinking red ? Makes no sense to me.

     

    3) I am using Pioneer board and SD Card Shield V4.0 (SLD01095P) Seed Studio

     

    4) SDCARD is 8GB, I partitioned it to 2 GB, and formatted with utility called out

    above.

     

    5) Pioneer board has no additional jumpers used, eg I am just looking at your project.

     

    6) I see clock and MISO and MOSI activity via oscilloscope.

     

    So I am a bit stuck, anything obvious ?

    • Cancel
    • Up +1 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 8 years ago in reply to danadak

    Hi Dana,

     

    I was going through my old emails and saw that this post went unanswered. Sorry for the inconvenience.

     

    Here are the answers to your questions:

    1) I haven't cleaned the code well. But, these wont break anything.

    2) The code has not identified a valid SD Card.

    3) It is compatible. You'll have to change the pinout though.

    4) This will not work. Any card with size more than 2GB capacity needs a "High Capacity" support. This is as simple as setting the high-capacity bit during card initialization in ACMD41 command.

    But, this also means that the File System should support the same. Unfortunately, this feature is not supported in the code attached here.

    So, you are limited to use only 2GB cards. I have seen that some cards from SanDisk with exactly 2GB capacity needs this bit to be set. Transcend cards work without any issues till 2GB.

    5) Normal settings should work. You can either use 5V or 3.3V setting, but I recommend using 3.3V.

    6) SDCard_InitCard() is trying to initialize the card. Since this function is kept in an loop, the initialization procedure happens till a valid card is identified.

     

    So, the only issue I see here is the 8GB card used. Please try with a true 2GB card. I suggest to use a Transcend 2GB SD card.

     

    Regards,

    Sriram V S

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 8 years ago

    I was trying out with micro sd but my program  hangs in this line

                                                                             cardInfo = SDCard_InitCard();

    please help me out..

     

     

    can i try this program for MICRO SD????


    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
>
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube