Shop OBEX P1 Docs P2 Docs Learn Events
Troubles with PropC3 and SD-Card — Parallax Forums

Troubles with PropC3 and SD-Card

nomadnomad Posts: 276
edited 2013-01-25 01:45 in Propeller 1
hi
in the moment i working on the C3 with gps + sd-card with spin.
on the "programming & customizing the multicore Propeller Microcontroller" Book
in chapter 09 page 319 is a description of a GPS-DataLogger.
look at the attachment: Main_01.spin and sdspi.spin

under propC3 i have troubles with the descriptions of basepin
look under sdspi.spin
code:
pub start(basepin)
'
' Initialize the card! Send a whole bunch of
' clocks (in case the previous program crashed
' in the middle of a read command or something),
' then a reset command, and then wait until the
' card goes idle. If you want to change this
' method to make the pins not be adjacent, all you
' need to do is change these first four lines.
'
cs := basepin++
di := basepin++
clk := basepin++
do := basepin

if i working with simpleIDE and "filetest"
under PropC3
i can compile and run the SD-Card stuff
in the source-code mount.c
look at the attachment: mount.c
is the following source-code-snippets
c-code
#ifdef C3_CARD
static _SD_Params params =
{
AttachmentType: _SDA_SerialDeMUX,
pins:
{
SerialDeMUX:
{
MISO: 10, // The pin attached to the SD card's MISO or DO output
CLK: 11, // The pin attached to the SD card's CLK or SCLK input
MOSI: 9, // The pin attached to the SD card's MOSI or DI input
CLR: 25, // The pin attached to the counter's reset/clear pin
INC: 8, // The pin attached to the counter's clock/count pin
ADDR: 5, // The SD card's demux address (the counter's count)
}
}
};

i will change in spin-code on sdspi.spin the basebin with:

cs := ??? i dont know which pin
di := 9 ' - MOSI
clk := 11 ' - CLK
do := 10 ' - MISO

but what i do is wrong , dont run.....
can somebody help my in my troubles

thanks for help and hints and tricks
excuse my bad english
regards nomad

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-01-21 07:54
    Are you using Spin or are you using C? The version of sdspi.spin you are looking at is not written for the C3 and will not work with it. The C3 uses a different circuit for selecting the SD card. mount.c is written to use either the "standard" way to select an SD card or the C3 way. There is a version of sdspi.spin written for the C3 and uses a different .start method. I've attached a copy.
  • Dave HeinDave Hein Posts: 6,347
    edited 2013-01-21 08:05
    Here's a version of safe_spi.spin that works with FSRW and the C3 card. You have to call mount_explicit, and specify pin 25 for the CS. This assumes you are using FSRW 2.6.
  • ggg558877ggg558877 Posts: 40
    edited 2013-01-21 20:33
    Mike Green wrote: »
    Are you using Spin or are you using C? The version of sdspi.spin you are looking at is not written for the C3 and will not work with it. The C3 uses a different circuit for selecting the SD card. mount.c is written to use either the "standard" way to select an SD card or the C3 way. There is a version of sdspi.spin written for the C3 and uses a different .start method. I've attached a copy.

    Hi Mike
    I have some problem with SD Card in C3
    I want to write data in to SD Card in text
    con
    
       _clkmode = xtal1 + pll16x
       _xinfreq = 5_000_000
    
       spiCnt = 8
       spiDI  = 9
       spiDO  = 10
       spiClk = 11
       spiClr = 25
    
    obj
    
       sdfat : "fsrwFemto"
       pst   : "Parallax Serial Terminal"
    
    pub demo | mounted
    
        pst.start(115200)
        waitcnt(clkfreq + cnt)
        
        mounted := \sdfat.mount(spiClr,spiCnt,spiDI,spiDO,spiClk)
        if mounted < 0
           pst.str(string( 13 , "failed to mount" , 13 ))
           abort
    
        pst.str(string( 13 , "SD Card was found " , 13 ))
    
        sdfat.popen(string("test.txt"),"w")
        sdfat.pputs(string("Sending information to an SD card is easy!", 13,10 ))
        sdfat.pclose
    
        sdfat.unmount
    

    but when I'm not mount SD Card the string "failed to mount" dose not appear
    how can i solve this problem
    thanks
  • nomadnomad Posts: 276
    edited 2013-01-21 22:26
    hi all
    thanks for your answers :-)

    @mike:
    thanks for share the code.
    today i working with your code and the code of Dave Hein.

    zitat: working with "c" or with spin:
    last year i working on my quadcopter and buy the C3
    then i make some experiments with spin + C3 + sd-card:
    on spin : nothing runs , then i see the "filetest" for the SimpleIde
    and compile the whole stuff and its running.....

    now: i working with the c3 with the LaserRangeFinder, GPS, XBee etc (under spin)
    all is OK and running
    but not the SD-Card-stuff

    @Dave Hein: thanks for your Code

    today i make some experiments with the new spin code
    and i make posting of the results.

    on all thanks for your help
    regards nomad
  • nomadnomad Posts: 276
    edited 2013-01-22 02:31
    hi,
    @ mike:
    in the meantime i have tested the fsrwFemto / sdspiFemto.spin
    now i have some problems:
    for this i make a attachment : sdCardmain01.spin
    (its a verry chaotic source) but its only for testings.

    what i want:
    1) read once gps-datas (here dummy datas) this is ok
    2) mount sdcard
    3) open gps.txt
    4) write this datas to sdCard into gps.txt
    5) close gps.txt
    6) unmout sdcards

    in my program at line 220
    i write a variable into the sd-card
    ----
    'now output to the file the values we have
    if sdrecording == 1
    \sdfat.sdstr(latitude_degpart)
    ----

    on the fsrwFemto.spin i dont find a function to write a variable aka "latitude_degpart" to
    file

    it this possible ???

    and i have make a Test with your C3_FemtoBasic.spin on my C3-board and the PropellerTool
    its a failure -> object exceeds runtime memory limit by 50 longs ;-)

    @DaveHein:
    if working with your safe_spi-c3.spin - object i must change my whole program
    please look at "what i want"

    @ggg558877
    - thanks for your posting
    - you have the same problem

    thanks for your help
    regards nomad
  • Mike GreenMike Green Posts: 23,101
    edited 2013-01-22 06:53
    If you look in fsrwFemto.spin, you'll see that there are methods .dec, .hex, and .bin that are essentially the same as those in other I/O drivers. You'd use those to write variables to a file in human readable form (as ASCII strings). You can also use the numbers object to convert values to strings, then write the strings to a file.

    I don't know why your program is so large (to run out of memory). I can't tell from the information you've provided. FemtoBasic is larger and has more string constants used, yet has several thousand bytes left for the Basic program.
  • Dave HeinDave Hein Posts: 6,347
    edited 2013-01-22 08:14
    nomad, your code is using FSRW 1.6, which won't work with the C3 card. You should use FSRW 2.6 instead. This version provides a mount_explicit method that allows you to specify the 4 SD pins explicitly. In addition, you would need to change fsrw.spin to use the safe_spi_c3 that I posted earlier. You would then change your call to mount to mount_explicit(10, 11, 9, 25).
  • Mike GreenMike Green Posts: 23,101
    edited 2013-01-22 09:25
    I noticed that I posted a version of fsrwFemto that's more recent than the one in the ObEx and has some experimental features. Use the attached version here from the ObEx. Both this and the other version are based on FSRW 2.6
  • nomadnomad Posts: 276
    edited 2013-01-22 21:54
    hi,
    @mike #7 posting
    thanks for your answer and help.

    FemtoBasic: it's ok for me, i will dont work with FemtoBasic
    it was only a experiments, what happen :-)

    @DaveHein #8
    thank you for your help and the FSRW2.6

    @mike #9
    Thanks for the new fsrwFemto.spin

    today i working with the new stuff and make later a posting

    regards
    nomad
  • nomadnomad Posts: 276
    edited 2013-01-23 02:24
    hi
    now my first results of my experiments.
    as attachments:
    mike-sdcard.zip
    davehein-sdcard.zip

    in this zips are my testings included the spin-objects

    @mike:
    thanks for your help but i have some troubles
    when i would compile my spincode -> please look on the zip-file:
    following happened
    - 1.compile with mike_fsrwFemto + sdspiFemto.spin
    - failure access:
    -> pub initSDCard(DO, Clk, DI, CS)
    return sdspi.initSDCard(DO, Clk, DI, CS)
    - should be
    -> initSDCard(Sel,Clr,Inc,DI,DO,Clk)
    - wrong access to sdspiFemto
    - failure to compile....

    i think its my fault .....
    but in the moment i dont know what i should do ?

    @davehein:
    thanks for the fsrw26:
    -> i have not testing the test.spin
    i think its not for the c3-board

    -> instead i working with my code
    please look at your zip-folder
    i running the source (davehein-c3-sdcard.spin, and for the moment its no failure
    for the result look at the screenshot: davehein-c3-sdcard-run.jpg
    excuse the chaotic source (its only experiments)

    i think, i can mount the sdcard ?? is this correct

    i must say that i have not the big experience for sd-cards

    thanks for all your helps and hints

    regards
    nomad
  • Dave HeinDave Hein Posts: 6,347
    edited 2013-01-23 05:13
    In dave_fsrw.spin, change 'sdspi: "safe_spi" ' to 'sdspi: "safe_spi_c3" '.

    In davehein-c3-sdcard.spin remove 'ssc3 : "safe_spi_c3"' and 'ssc3.start_explicit(10,11,9,25)'.
  • ggg558877ggg558877 Posts: 40
    edited 2013-01-23 18:22
    nomad wrote: »

    @davehein:
    thanks for the fsrw26:
    -> i have not testing the test.spin
    i think its not for the c3-board

    -> instead i working with my code
    please look at your zip-folder
    i running the source (davehein-c3-sdcard.spin, and for the moment its no failure
    for the result look at the screenshot: davehein-c3-sdcard-run.jpg
    excuse the chaotic source (its only experiments)

    i think, i can mount the sdcard ?? is this correct

    i must say that i have not the big experience for sd-cards

    thanks for all your helps and hints

    Hi nomad,davehein,Mike
    i solve my problem
    thanks for your help
  • nomadnomad Posts: 276
    edited 2013-01-23 21:35
    hi
    @davehein
    thanks for your replay
    today i make some experiments

    @ggg559977
    fine "i solve my problem"
    please , can your share the solved problem (the source-code)

    thanks for all help
    regards
    nomad
  • ggg558877ggg558877 Posts: 40
    edited 2013-01-25 00:26
    nomad wrote: »
    hi
    @davehein
    thanks for your replay
    today i make some experiments

    @ggg559977
    fine "i solve my problem"
    please , can your share the solved problem (the source-code)

    thanks for all help
    regards
    nomad

    Hi nomad
    I used JonnyMac's jm_sd_text_read.spin in before thread
    and I can used it to write string into SD card
    I will test to write the GPS receive's string into SD card later
  • nomadnomad Posts: 276
    edited 2013-01-25 00:44
    hi ggg558877 (excuse 559977)
    thanks for sharing your code
    today i make some experiments.
    in the meantime i working with davehein_c3_sdcard.spin
    in the moment i can do:
    - mount sdCard
    - openDir
    - unmount sdCard

    no failure
    now i will working on
    -read the dirs
    - open / close a file
    - write and read the file

    regards
    nomad
  • nomadnomad Posts: 276
    edited 2013-01-25 01:45
    hi ggg558877
    thanks for your code...
    it's running and i am happy
    i think for me my problem is solved

    now i working with your code to write gps-datas (first dummys) then real gpsDatas

    thanks all for help, hints......
    regards
    nomad
Sign In or Register to comment.