• Pic® Basic


  • SD_File_System

    SD_File_System

    The SD_File_System module is a macro library for use with Library Manager by JohnGB. This module has been written by Steven Wright (swright on PDS forum). The library module is offered on an as-is basis with no warranty as to its effectiveness, operation or reliability. Users use it at their own risk.

    Feature summary
    • Macros for accessing Secure Digital (SD) or Multimedia Memory Card (MMC) cards – SD_Init, SD_Sector, SD_Read and SD_Write.
    • Macros for writing files to these cards in the FAT16 format – such files can be read directly by a PC, using a card reader. The commands include SD_Init_FS, SD_Check_For_File, SD_New_File, SD_Append_File, SD_Write_Byte_To_File, SD_Write_String_To_File, SD_Save_File and SD_Close_File. Also commands for reading files, including SD_Open_File and SD_Read_Byte_From_File. Also file and disk management commands, including SD_Delete_File, SD_Free_Space, SD_Disk_Size, SD_Dir and SD_Psuedo_Format.





    Download module
    Download: SD_File_System





    Example 1

    Code:
          Device = 18F4550
          XTAL = 20
          '-----------------------------------------------------------
          ALL_DIGITAL = TRUE
          '-----------------------------------------------------------
          HSERIAL_BAUD = 115200                                       'Setup RS232 port
          HSERIAL_RCSTA = 010000                                        
          HSERIAL_TXSTA = 100100
          '-----------------------------------------------------------
          Dim Response As Byte
          Dim SD_IO As Byte
          '-----------------------------------------------------------
          Symbol SD_CS = PORTD.2                                      'SPI CS to SD CS (SD pin 1)
          Symbol SD_DI = PORTD.5                                      'SPI DO to SD DI (SD Pin 2)
          Symbol SD_CLK = PORTD.3                                     'SPI CLK to SD CLK (SD Pin 5)
          Symbol SD_DO = PORTD.4                                      'SPI DI to SD DO (SD Pin 7)
          '-----------------------------------------------------------
          Include "SD_MMC_Read_File_Lib.pbp"                          'Include managed library file
          '-----------------------------------------------------------
          GoTo Over_Sub                                               'Jump over the subroutines
          '-----------------------------------------------------------
          Over_Sub:                                                  
              DelayMS 200
          '-----------------------------------------------------------
          Main_Prog:
              HSerOut ["INSERT SD OR MMC",13]
              Repeat
                  Response = SD_Init_FS
              Until Response = 0
              HSerOut ["OPENING FILE",13]
              SD_File_Name = "TEST001"                                'File Name, upper case only!
              SD_File_Ext = "TXT"                                     'File Ext, upper case only!  
              Response = SD_Open_File
              If Response = 1 Then
                  HSerOut ["FILE NOT FOUND",13]
                  Stop
     
              EndIf
              HSerOut ["FILE OPEN",13]
              While SD_EOF < 1
                  Response = SD_Read_Byte_From_File
                  HSerOut [Response]
              Wend  
          '-----------------------------------------------------------
          Finish:
              HSerOut [13]
              HSerOut ["FINISHED",13]
              Stop
  • Recent Activity

    towlerg-21522

    PIC18F1330 PLL problem

    Thread Starter: rcurl

    I'm just starting out on a new project that uses a PIC18F1330. I haven't used this specific chip before, so I began by trying to blink an LED just...

    towlerg Today, 16:26 Go to last post
    towlerg-21522

    Pic16f18877 oread

    Thread Starter: evoortman

    Hi, On a PIC16F18877 the OREAD command doesn't seem to work. The code is working on a PIC16F1939. Both controllers use 32MHz int osc. If i...

    towlerg Today, 16:25 Go to last post
    palamont-28794

    MID$ Problem with a PIC18F25K22

    Thread Starter: palamont

    Hi everybody, I encounter a strange problem : I have a string of 230 characters. This string is divided into 10 segments of 23 characters, with a...

    palamont Today, 10:08 Go to last post