Help with getting SD to work


+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 26

Thread: Help with getting SD to work3826 days old

  1. #1
    nigelstephens
    Guest nigelstephens's Avatar

    0 Not allowed!

    Default Help with getting SD to work

    Hi

    I'm trying SD Library for the first time having worked out the connections and done my code.

    My first problem is that SD_Init FS takes over 5 seconds to return a 0. My guess it is timing out.
    Here is the line

    Response = SD_Init_FS SD_SPI_FOSC_04

    I have declared my pins as
    Symbol SD_CS = PORTA.0
    Symbol SD_DI = PORTA.1
    Symbol SD_CLK = PORTA.3
    Symbol SD_DO = PORTA.2
    TRISA.0 = 0
    TRISA.1=0
    TRISA.2=1
    TRISA.3=0

    My PIC is a 18F452 at 20Mhz

    I have followed the circuit diagram as per the help file. My only worry is over my CS connection.
    I have an SD socket module I'm using for the card. It has no CS marked on the connections. It has SS and I have assumed this is the connection for CS.

    The card is made by ghielectronics. Its called SPexp and version 1.1.
    It has two connector strips. One is labelled SV1 (the one Im using). The other is labelled SV2 and has pins such as DT, WP that SV1 does not have.

    Any help would be great!

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    nigelstephens
    Guest nigelstephens's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    Im next going to try not using the boards connections but solder direct to the correct pins in the SD socket. Watch this space.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Maverick
    Guest Maverick's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    set back pin in SPI mode is CD/DAT3 but although the first connection its actually counted pin 9 on most data sheets as it was added to the connector specification later for MMC/SD connectors
    if you have an MMC connector then ignore pins 9 (first pin set back),10(second from last),11(last pin) ,
    so going from the the set back pin on the SD card its

    9=NC (DAT2) ---- the set back small pad on SD , MMC doesnt have it
    1=CS (CD/DAT3)
    2=SDI (CMD/D1)
    3=GND
    4=3.3V
    5=SCK (CLK/SCLK)
    6=GND
    7=SDO (DAT0)
    8=NC (DAT1) ------------ SD ignore of MMC
    10=Card detect --------- SD ignore for MMC
    11=Write protect -------- SD ignore for MMC

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    nigelstephens
    Guest nigelstephens's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    I dont know what standard this card is made to but the V+ edge connector pin goes to pin 1 and 8 on the SD socket. That was using an ohm meter. I think I will seperate the socket from the board and do it as to the standard as you have given. Also here.
    http://pinouts.ru/Memory/sdcard_pinout.shtml

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Maverick
    Guest Maverick's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    Attachment 351 notice the image of the SD card though first pin is pin 9 ,, this throws a lot of people out

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    nigelstephens
    Guest nigelstephens's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    the set back pin is 9. Then it starts from 1. My understanding. It is confusing.

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Maverick
    Guest Maverick's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    it is but it was done like that as an after thought to make MMC and SD compatible , you can put an mmc card in a SD socket ,, but not an SD card in an MMC socket

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    nigelstephens
    Guest nigelstephens's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    I have checked and double checked my connections and I have what Maverick has provided.

    In the following code SD_INit_FS takes about 5 seconds. Seems too long to me.
    Then it runs quickly to R2a and sits there for ever more trying SD_New_File.

    The card is formatted as FAT and I can read it on my PC.

    Any ideas anyone?


    Print At 2,17, "R0"
    Repeat
    Response = SD_Init_FS SD_SPI_FOSC_04
    Until Response=0
    Print At 2,17, "R1"
    SD_File_Name="data"
    SD_File_Ext="txt"
    Response=SD_Check_For_File
    Print At 2,17, "R2"
    If Response<>0 Then
    Print At 2,17, "R2a"
    SD_New_File
    Print At 2,17, "R2A"
    Else
    Print At 2,17, "R2b"
    SD_Append_File
    Print At 2,17, "R2B"
    EndIf
    Print At 2,17, "R3 "
    SD_IO_String= Str$(Dec1 Seconds) + "," + Str$(Dec InjIn0Duty_us) + "," + Str$(Dec InjIn0Rest_us) + "," + Str$(Dec InjIn1Duty_us) + "," + Str$(Dec InjIn1Rest_us)
    SD_IO_String=SD_IO_String + Str$(Dec HT_T) + 13 + 10
    SD_Write_String_To_File
    Print At 2,17, "R4 "
    SD_Close_File
    Print At 2,17, "R5 "
    Last edited by nigelstephens; 2nd April 2010 at 11:30.

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    nigelstephens
    Guest nigelstephens's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    My init appears to be working but taking 7 seconds. If I remove the card it never gets past the initiation which is correct.
    Then the SD_Check_For_File comes back quickly indicating file is not present which is correct.
    Then it hangs forever on SD_New_File.

    I have corrected the file name and ext to upper case.
    Why wont it create a new file?
    The card is a 1MB SD card formatted with FAT16. It is blank.

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    chuckieboy
    Guest chuckieboy's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    Nigel
    I've had a quick looked through your code
    Not sure if this will make it work
    Change this line
    Code:
    If Response<>0 Then
    to this line
    Code:
    If Response>0 Then
    But I'm not 100% sure if your SD_New_file is correct this is how I do mine

    Code:
    RESPONSE = SD_Init_FS
    Until RESPONSE = 0
    SD_File_Name = "NPL"+ Str$(Dec5 TEMP8)'HOLD THE VALUE OF THE FILE NAME
    SD_File_Ext = "CSV" 
    RESPONSE = SD_Append_File
    If RESPONSE >0 Then
    TEMP8 = TEMP8 +1
    GoSub ADD_FILE
    EndIf
     
    SD_IO_String = Str$(Dec2 RTCDATE)+"/" +Str$(Dec2 RTCMONTH) + "/" + Str$(Dec2 RTCYEAR)+ "," + Str$(Dec2 RTCHR)+":"+ Str$(Dec2 RTCMIN)+":"+ Str$(Dec2 RTCSEC)+","+ Str$(Dec2 AD_RESULT1)+ 13 + 10
    RESPONSE = SD_Write_String_To_File 'Write SD_IO_String to file 
    SD_Close_File
     
    Print At 1,1,"NEW FILE "
    Print At 2,1,"NPL:",Dec4 TEMP8
    Repeat 
    RESPONSE = SD_Init_FS
    Until RESPONSE = 0
    '-----------------------------------------------------------
     
    SD_File_Name = "NPL"+ Str$(Dec5 TEMP8)'+ LEFT$(TEMP,6) 'FILE NAME, UPPER CASE ONLY!
    SD_File_Ext = "CSV" 'FILE EXT, UPPER CASE ONLY! 
    RESPONSE = SD_Check_For_File 'CHECK IF FILE ALREADY EXISTS
    If RESPONSE = 0 Then
    TEMP8 = TEMP8 + 1
    DelayMS 10
    GoTo ADD_FILE
     
    Else 
     
    Print At 1,1,"OPENING FILE "
    Print At 2,1," "
    ' SD_WRITE_STRING_TO_FILE 
    SD_New_File 'OPEN NEW FILE
    DelayMS 75
     
    SD_Close_File
    Print At 1,1,"CLOSING FILE"
    DelayMS 500
    EndIf
    GoTo MAINLOOP_ENTRY
    
    I will try out your code a bit later

    I May be wrong but I remember something about the file name has to be 8 characters long for it to work.
    Last edited by chuckieboy; 2nd April 2010 at 19:39. Reason: another thought

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  21. #11
    Prolific Poster normnet's Avatar
    Join Date
    Jul 2004
    Posts
    2,423
    Thumbs Up
    Received: 81
    Given: 48
    Total Downloaded
    1.40 GB

    0 Not allowed!

    Default Re: Help with getting SD to work

    I May be wrong but I remember something about the file name has to be 8 characters long for it to work.
    Upper case letters A Z
    Numbers 0 9
    Trailing spaces only
    ! # $ % & ' ( ) - @ ^ _ ` { } ~
    DOS 8 char file name limit + .extension

    Norm

  22. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  23. #12
    nigelstephens
    Guest nigelstephens's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    Quote Originally Posted by chuckieboy View Post
    I May be wrong but I remember something about the file name has to be 8 characters long for it to work.
    I tried it with eight upper case character name. but no difference.

  24. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  25. #13
    nigelstephens
    Guest nigelstephens's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    I have scoped the connections to the SD card.
    The SD_Init_FS takes about 6 seconds. It returns 0 and my code moves on. The SD_Check_For_File is performed quickly and returns 1.
    SD_New_File is then issued and the code does not move on and will spend forever at this step.

    The clock line is continually active with a set of 8 square waves with a short gap then 8 square waves continuously.
    The DO pin 7 is high with the occasional low pulse every 4 seconds.
    The DI pin 2 is high with the occasional low pulse every 4 seconds.
    The CS pin 1 is held low with a high pulse every 4 seconds.
    The last three appear to pulse together at the same time.

    Print At 2,1, "R0 "
    Repeat
    Response = SD_Init_FS
    Until Response=0
    Print At 2,1, "R1 "
    SD_File_Name="DATA1234"
    SD_File_Ext="TXT"
    Response=SD_Check_For_File
    Print At 2,1, "R2 ",Dec Response
    DelayMS 10
    If Response>0 Then
    Print At 2,1, "R2a" ,Dec Response
    SD_New_File
    DelayMS 75
    Print At 2,1, "R2A" ,Dec Response
    Else
    Print At 2,1, "R2b" ,Dec Response
    SD_Append_File
    DelayMS 75
    Print At 2,1, "R2B" ,Dec Response
    EndIf
    Print At 2,1, "R3 "
    SD_IO_String= Str$(Dec1 Seconds) + "," + Str$(Dec InjIn0Duty_us) + "," + Str$(Dec InjIn0Rest_us) + "," + Str$(Dec InjIn1Duty_us) + "," + Str$(Dec InjIn1Rest_us)
    SD_IO_String=SD_IO_String + Str$(Dec HT_T) + 13 + 10
    SD_Write_String_To_File
    DelayMS 75
    Print At 2,1, "R4 "
    SD_Close_File
    Print At 2,1, "R5 "

  26. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  27. #14
    pverburg
    Guest pverburg's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    How big is the card you said 1Mb but mean 1Gb ? do you have a smaller one. I found that bigger cards can take more time. try this reformat the card on pc and then create a notepad text file with some text in it this should be right at the beginning of the card and not fragmented. now check if exist and open then append and close read back on the pc.

    Paul V.

  28. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  29. #15
    nigelstephens
    Guest nigelstephens's Avatar

    0 Not allowed!

    Default Re: Help with getting SD to work

    It is 1 gb sorry. I created a file in notepad and named it DATA1234.TXT the same as in my code. But no change. The file name was not detected , SD_Check_For_File returned >0, and it wanted to create a new file. I have reformated the card and saved and opened a file to make sure it works on the PC. All working as far as this goes. I don't know where to go next. SD is not working for me.
    Last edited by nigelstephens; 3rd April 2010 at 22:54. Reason: the

  30. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. [SOLVED !] lost al my work
    By raf in forum Proton Plus Compiler v3
    Replies: 20
    Last Post: 9th December 2015, 18:37
  2. Still can't get my LCD to work
    By jimmy in forum Absolute Beginners Section
    Replies: 4
    Last Post: 28th June 2014, 16:33
  3. Replies: 0
    Last Post: 18th July 2012, 11:21
  4. How to work with PIC18F46K20
    By TEEGEE in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 19th November 2008, 21:42
  5. [SOLVED !] POSTINC0 seems not work
    By pdgnr in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 29th March 2008, 19:37

Tags for this Thread

Posting Permissions

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