[SOLVED !] PIC24FJ64GA002 and SD-card


Closed Thread
Results 1 to 15 of 15

Thread: PIC24FJ64GA002 and SD-card1756 days old

  1. #1
    emwlond
    Guest emwlond's Avatar

    0 Not allowed!

    Default PIC24FJ64GA002 and SD-card

    Hi!

    I encountered some problems when I tried to get the µP to connect to the SD-card.

    Question: Is the SPI-function in FileSys24.inc HW or SW?

    I have to put the "Include "FileSys24.inc"" before my SD $define and I have to modify the PIN $defines inside the FileSys24.inc to get things to work.

    Am I doings something wrong in my code?

    /// Marcus

    My test code:
    Code:
    '****************************************************************
    '*  Name    : Time_test.BAS                                     *
    '*  Author  : Marcus Löfstrand                                  *
    '*  Notice  : Copyright (c) 2015 Marcus Löfstrand               *
    '*          : All Rights Reserved                               *
    '*  Date    : 2015-08-04                                        *
    '*  Version : 0.00.20                                           *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    
    
    'µP
    ;-------------------------------------------------------------------------------
    ;**** Added by Fuse Configurator ****
    ; Use the Fuse Configurator plug-in to change these settings
    
    Device = 24FJ64GA002
    
    Config CONFIG2 = FCKSM_CSDCMD, FNOSC_FRC, I2C1SEL_PRI, IESO_OFF, IOL1WAY_OFF, OSCIOFNC_ON, POSCMOD_NONE, SOSCSEL_LPSOSC, WUTSEL_FST
    Config CONFIG1 = BKBUG_OFF, COE_OFF, FWDTEN_OFF, FWPSA_PR128, GCP_OFF, GWRP_OFF, ICS_PGx1, JTAGEN_OFF, WDTPOST_PS1, WINDIS_OFF
    
    ;**** End of Fuse Configurator Settings ****
    ;-------------------------------------------------------------------------------
            
            Declare Reminders = OFF
            
    'µP speed
            Declare Xtal = 8
            
    'Bootloader
            Declare Bootloader = 0          
    
    ' -----[ I/O Definitions ]-------------------------------------------------
    
            'Leds
            Symbol LED = PORTB.4
                    
            'SD
            Include "FileSys24.inc"
    
            $define SD_CLK = PORTB.12       ' Clock pin
            $define SD_SDO = PORTB.11       ' Data out pin
            $define SD_SDI = PORTB.13       ' Data in pin
            $define SD_CS = PORTB.10        ' SD CE pin
            
            'Hw RX/TX
            Declare HRsout2_Pin PORTB.0
            Declare Hserial2_Baud = 9600    ' Set baud rate to 9600
            
    ' -----[ Constants ]-------------------------------------------------------
    
            Dim CR As $0D                   ' Carriage Return
            Dim LF As $0A                   ' Line Feed
            
    ' -----[ Variables ]-------------------------------------------------------
    
            
    ' -----[ Initialization ]--------------------------------------------------
    
    OSCCON = 00000000000000  ' 8MHz
    CLKDIV = 00000000000000
    
    PPS_Output(cOut_Pin_RP0, cOut_Fn_U2TX)
    
    DelayMS 500
    
    ' -----[ Program Code ]----------------------------------------------------
    
    Main:
    
    If FAT_Init() = cErrOK Then
        HRSOut2 "SD initialised", CR, LF
    Else
        HRSOut2 "Cannot initialise SD", CR, LF
    EndIf
    
    Low LED
    
    End
    
    ' -----[ Subroutines ]-----------------------------------------------------
    
    ' -----[ CData ]-----------------------------------------------------------

  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
    emwlond
    Guest emwlond's Avatar

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    Hi again!

    I have a new question: how do I set the file creation date?

    /// Marcus

  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
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,402
    Thumbs Up
    Received: 48
    Given: 40
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    Hi Marcus

    To answer the question you asked in your first post: the SPI is done by software in the FileSys24.inc file.
    As for your second post, do you mean the date a file is created on an SD card using the File_Create code?

    Charlie

  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
    emwlond
    Guest emwlond's Avatar

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    Hi!

    I have figure out that it is SW SPI. Is it possible to modify for HW SPI?

    And to my second post, yes. There was a option in Steven Wright's old SD_File_System Library to set file creation date/time that I miss in the FileSys24.

    /// Marcus

  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
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,402
    Thumbs Up
    Received: 48
    Given: 40
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    If you look inside FileSys24.inc you will see all the code. Yes, it would be possible to change it for HW SPI (a bit of work) and yes, it would be possible to add date/time created. If you smile very sweetly at Les he might do it for you. I could suggest where the time/date would go, I'll have a look and come back here later.

    Charlie

  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
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,584
    Thumbs Up
    Received: 337
    Given: 161
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    You should remember, on a PIC24 device, software SPI can be faster than hardware SPI, and the code efficiency for software SPI is excellent because of the architecture of the devices.

    Why do you wish to use the SPI peripheral instead of bitbashed?

    As Charlie pointed out, the variables are there for time and date creation and they can be loaded if required before a file is created etc.... See the Dim section of the include file.

    It would be fairly straightforward to create a procedure that altered the file's time and date, which is why the code is fully open source and full of comments. I'm hoping that some of our users add to it, or as Charlie has done, correct some anomalies. However, any anomalies that are corrected, or additions made, should be placed on the forum so that other users can benefit.
    Last edited by top204; 28th December 2015 at 10:04.

  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
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,402
    Thumbs Up
    Received: 48
    Given: 40
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    Thanks Les, that makes it clear. If I understand you, if we alter/correct somebody else's code, do we do it by adding something to the end of your Wiki article? That would be the best place for it. A free-standing post would eventually get lost.

    Happy new year to you and your good lady.

    Charlie

  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
    emwlond
    Guest emwlond's Avatar

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    Hi!

    I guess I should use the following Dim to set the file create date/time:
    Code:
    Dim Global_bDay As Byte = 1
    Dim Global_bMonth As Byte = 1
    Dim Global_bYear As Byte = 1
    Dim Global_bHours As Byte = 0
    Dim Global_bMinutes As Byte = 0
    Dim Global_bSeconds As Byte = 0
    And about HW SPI is that my code for the RFID-chip is HW SPI-based and I'm more used with HW SPI because I find it simpler to use, but that is just me

    I did some changes in the old SD-code to be able to use HW SPI2 instead of SPI1 that was occupied with HW I2C.

    /// Marcus

  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
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,402
    Thumbs Up
    Received: 48
    Given: 40
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    That looks good Marcus. What is your project?

    Charlie

  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
    emwlond
    Guest emwlond's Avatar

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    For the moment a small timelapscamera:




    I'm also working on a new "brain" to my Litter-Robot and a pH-meter.

    /// Marcus

  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
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,584
    Thumbs Up
    Received: 337
    Given: 161
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    Well done. It would be very beneficial to see the modified code, and may be practical to users. Will you add it to the forum please?

  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
    emwlond
    Guest emwlond's Avatar

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    I posted my changes for the old SD-file code here: http://www.protonbasic.co.uk/showthr...17-Great-job-2

    /// Marcus

  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
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,402
    Thumbs Up
    Received: 48
    Given: 40
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    Your project looks good.

    Les, what is the preferred method of posting changes? I have altered your FileSys24.inc file in a few places. If I post just the changes then after a few weeks they (the posts) will be lost. Could I add something like "User notes" to the end of your Wiki entry?

    Happy new year to you, your good lady and everybody.

    Charlie

  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
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,584
    Thumbs Up
    Received: 337
    Given: 161
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    Could I add something like "User notes" to the end of your Wiki entry?
    Yes Charlie, that's a good idea.

  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
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,402
    Thumbs Up
    Received: 48
    Given: 40
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: PIC24FJ64GA002 and SD-card

    Will do when I get back to the UK in two weeks time.

    Charlie

  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 !] PIC24FJ64GA002 working on 4 Mhz
    By Roshan in forum Proton 24
    Replies: 14
    Last Post: 30th November 2015, 06:37
  2. hpwm on pic24fj64ga002
    By paulbrohan in forum Absolute Beginners Section
    Replies: 1
    Last Post: 6th August 2015, 11:57
  3. [SOLVED !] Sd card
    By ADLIN SYSTEMS in forum The Lounge
    Replies: 8
    Last Post: 28th May 2015, 21:36
  4. SD Card
    By ADLIN SYSTEMS in forum The Lounge
    Replies: 4
    Last Post: 29th November 2012, 08:10
  5. Sd card again :((
    By birey in forum SWright's Feedback Forum
    Replies: 5
    Last Post: 17th December 2011, 09:38

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