Shop OBEX P1 Docs P2 Docs Learn Events
umount and date/time for fsrw SD card driver ?? — Parallax Forums

umount and date/time for fsrw SD card driver ??

RaymanRayman Posts: 14,162
edited 2007-12-02 08:08 in Propeller 1
I've discovered the need for a "umount" (un-mount) command for Rockiki's SD card driver so that the pins go high-impedance without killing the cog (what I'm doing now...).· Anybody done this already?

Also, it would be nice to add date/time stamps to the files...· Does this exist already?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-28 22:07
    Date / time stamps for the files is not in there since there is no "standard" date and time source for the Propeller. If you use the modified SD card driver that's part of FemtoBasic, it includes an unmount call. The low level I/O is different, so you have to use the low level I2C/SPI driver that's also part of FemtoBasic. The high level calls are pretty much the same as those in the Object Exchange Rokicki package.
  • RaymanRayman Posts: 14,162
    edited 2007-11-28 22:30
    Thanks!

    PS: I vote we make the DS1307 the standard time source...
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-11-28 22:33
    Seconded!

    What pins shall we call standard? IIRC, couldn't we just stack it on the EEPROM pins? (30,31)

    I'd love to add time/date to PropDOS!

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just getting started with Propeller?

    Propeller Cookbook

    PropDOS
  • parts-man73parts-man73 Posts: 830
    edited 2007-11-29 04:30
    Rayman said...
    PS: I vote we make the DS1307 the standard time source...

    Thirded (is that even a word???)

    OBC said...
    What pins shall we call standard? IIRC, couldn't we just stack it on the EEPROM pins? (30,31)

    Since the DS1307 is an I2c device, it can be on the same pins as the EEPROM. I'm soldering together a RTC based on the DS1307 on one of my new ProtoCards, I'll post a picture when I'm done. Since the ProtoCard has direct access to the I2c bus, it's a simple project, and very useful. With an onboard battery backup, the ProtoCard mounted DS1307 will keep on ticking. This type of thing is a perfect example of why I made the ProtoCard in the first place.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio

    PropNIC - Add ethernet ability to your Propeller!

    SD card Adapter
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-11-29 05:16
    Yeah, I was thinking the same direction, only with an additional Spinstudio connection off the top of the card for the keyboard/mouse board.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just getting started with Propeller?

    Propeller Cookbook

    PropDOS
  • parts-man73parts-man73 Posts: 830
    edited 2007-11-29 05:42
    It'd be easier to add a 6 pin connector on to the ProtoCard to stack an SD card adapter on top, like I did on the XBee adapter.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio

    PropNIC - Add ethernet ability to your Propeller!

    SD card Adapter
  • RaymanRayman Posts: 14,162
    edited 2007-11-29 13:14
    I bet we could use the DS1307's RAM for something clever too... Maybe offset from GMT, or DST status...
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-11-29 17:00
    @Rayman

    I've been eyeballing that ram too.. [noparse]:)[/noparse]

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just getting started with Propeller?

    Propeller Cookbook

    PropDOS
  • parts-man73parts-man73 Posts: 830
    edited 2007-11-29 17:41
    @ OBC

    I remember you mentioned looking into passing data to a program when launching from PropDOS, that might be the place to store the passed data?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio

    PropNIC - Add ethernet ability to your Propeller!

    SD card Adapter
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-12-01 17:58
    Been looking at how the time/date stamp can be added to fsrwFemto and stumbled on this little gem.

    pri pdate
    {{
    '   Get the current date and time, as a long, in the format required
    '   by FAT16.  Right now it"s hardwired to return the date this
    '   software was created on (December 26, 2006).  You can change this
    '   to return a valid date/time if you have access to this data in
    '   your setup.
    }}
       return constant(((2007-1980) << 25) + (1 << 21) + (6 << 16) + (12 << 11))
    
    



    I'm lost as to how the date is obtained from the above statement. If someone could explain
    the breakdown I'd appreciate it. IIUC, it looks like December 16,1980-2007 *confused!

    On the upside, it looks like applying the date will be a snap.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just getting started with Propeller?

    Propeller Cookbook

    PropDOS
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-01 18:24
    You can find the FAT format by searching for "wiki fat16".

    Here's a routine for building a date/time from pieces

    PRI dateTime(year,month,day,hours,minutes,seconds)
       return (year - 1980) << 25 | month << 21 | days << 16 | hours << 11 | minutes << 5 | seconds / 2
    
    



    I got the bit positions wrong for minutes and hours. The above is corrected.

    Post Edited (Mike Green) : 12/2/2007 1:48:30 AM GMT
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-12-02 01:33
    @Mike

    You are solid gold! Thank you! I assume that the time stamp is compatible with the existing routines?

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just getting started with Propeller?

    Propeller Cookbook

    PropDOS
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-02 01:49
    The above date/time is the format for FAT16 and is what pdate returns. Basically, change pdate to read the time and date from whatever RTC you want to use, then use the above formula to pack the date and time into a 32 bit long value that pdate can return.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-12-02 03:47
    Is this still considered proper connection for the DS1307?
    (Sorry about the really ugly clip.)

    ''                        4.7K                   5.0V       
    ''                    &#9484;&#9472;&#9472;&#9472;&#61623;&#61623;&#61623;&#61623;&#9472;&#9472;&#9472;  3.3V   DS1307-&#9472;&#9496;    
    ''                    &#9474; &#9484;&#9472;&#61623;&#61623;&#61623;&#61623;&#9472;&#9472;&#9472;  3.3V   &#9474; &#9474;              
    ''               1k   &#9474; &#9474;                &#9474; &#9474;            
    ''   Pin29/SDA &#9472;&#9472;&#61629;&#61629;&#61629;&#9472;&#9472;&#9531;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9531; &#9474;
    ''               1k     &#9474;                  &#9474;            
    ''   Pin28/SCL &#9472;&#9472;&#61629;&#61629;&#61629;&#9472;&#9472;&#9472;&#9472;&#9531;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9531;
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just getting started with Propeller?

    Propeller Cookbook

    PropDOS
  • Thomas StickneyThomas Stickney Posts: 23
    edited 2007-12-02 04:33
    I am assuming that the 'days' variable is the number of days in the current month and not the day of the week.
    please confirm.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-02 05:08
    Which days variable? If you're referring to the register in the RTC chip, it is the current day of the week.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-12-02 05:14
    Oldbitcollector said...
    Is this still considered proper connection for the DS1307?

    (What do they call it when you start quoting yourself? [noparse]:)[/noparse] [noparse]:)[/noparse]

    Looking at the SpinStudio Protoboard specs tonight I noticed that Brian has already
    taken care of all the pull-ups. Kudo's for being two steps ahead of us!

    Looks like I have just enough room on the board to replicate the SpinStudio socket,
    and place the DS1307 with the battery mounted sideways on the rear of the board.
    (I'll post pics soon, if I can find that required crystal in my junkbox.)

    OBC

    Edit[noparse][[/noparse]

    @Mike, thanks for the wiki reference! Good reading. Although I'm now a little
    worried about all of the world's handheld fat-based devices crashing on Jan 1, 2108. <smirk>

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just getting started with Propeller?

    Propeller Cookbook

    PropDOS

    Post Edited (Oldbitcollector) : 12/2/2007 5:23:47 AM GMT
  • Thomas StickneyThomas Stickney Posts: 23
    edited 2007-12-02 05:17
    Thanks for reply, what I meant was do I use the date register of RTC for the days variable in the PRI datetime code?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-02 06:52
    Yes. The DS1307 field shown as "date" is the day of the month and, in the routine above, would be the day parameter.
  • Goran (Sweden)Goran (Sweden) Posts: 68
    edited 2007-12-02 06:58
    Hi,

    I am using this code to set the time on a created file on a SDcard.

    PUB DateForSDcard

    · year:=BCD2Dec(year)
    · month:=BCD2Dec(month)
    · day:=BCD2Dec(day)
    · Hours:=BCD2Dec(Hours)
    · minutes:=BCD2Dec(minutes)
    · seconds:=BCD2Dec( seconds)
    · sdfat.pSetTimeDate(year, month, day, Hours,minutes, seconds)

    ·PUB BCD2Dec (value) : Decimalt
    · datum:=(value <<4)
    · datum2:=(value >>4)*10
    · datum1:=(datum >>4)
    · Decimalt:=(datum2+datum1)
    · return· Decimalt

    I use the DS1302 .

    Might be of some help

    Goran
  • parts-man73parts-man73 Posts: 830
    edited 2007-12-02 08:08
    Here's a picture of my DS1307 ProtoCard. The bright blue LED is a "Heartbeat" The DS1307 is outputing 1 hz on pin 7 as I have it set.

    I plan to add a 6 pin header to plug my SD Card adapter into so the clock and SD card can occupy 1 "Socket"

    I tested it with the object created by Beau Schwabe shown here http://forums.parallax.com/showthread.php?p=604475

    His example synthesizes 32.768 khz to avoid using a crystal. I stripped that code out, as I am using a crystal. Also changed SCL and SDA to P28+P29.

    I can provide details on the circuit if needed, but right now it's after 3am, time to get some sleep!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio

    PropNIC - Add ethernet ability to your Propeller!

    SD card Adapter
    350 x 262 - 28K
Sign In or Register to comment.