Using SPI


Closed Thread
Results 1 to 7 of 7

Thread: Using SPI

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697

    Default

    Hi, Ive done a lot of reading and it seems that the clock and be slowed down as much as you want which is good for testing. Im getting a little confused by the actual SD protocol though. Different sites are saying different things.

    I have some example code in C. I dont completely understand C but it looks like its saying things should happen in this order:-
    Enable the SPI interface
    Send 80 clocks using dummy bytes (0xFF)
    Enable CS (low)
    Send another dummy byte
    Send the init command (0x40, 0x00, 0x00, 0x00, 0x00, 0x95)
    Repeatedly send a dummy byte until the card replies

    Another site says the CS pin should be asserted before sending the 80 clocks. This is confusing as the pin is active low. It did read as though "assert" means low but as this C example seems to be the oposite i assume it means high.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    For SD card go here and look at SDFS3.zip
    http://www.melabs.com/resources/samples.htm
    It is so much easier than bit-banging. Added plus is the FAT16 file system.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697

    Default

    Hi, Since my last post Ive been doing some testing and i actually got a PIC to read data

    Ive been using the hardware SPI instead of bit-banging. Thanks for that link though because the next thing i need to do is figure out FAT16. Im working in ASM but having the example in PBP makes it easier to read :P Thanks!

Similar Threads

  1. Using SPI with External Interrupts
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th June 2008, 05:08
  2. 16-bit SPI problem
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th June 2008, 16:42
  3. SPI Interfacing
    By toofastdave in forum Serial
    Replies: 8
    Last Post: - 18th November 2007, 12:15
  4. SPI configuration PIC versus Atmel
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th July 2007, 20:17
  5. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 19:31

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts