1 Attachment(s)
SDHC (FAT32 for SD cards)
IF
You have used SDFS3 from MeLabs
http://www.melabs.com/resources/samples/pbp/sdfs3.zip AND
Now you would like to be able to use High Capacity cards THEN
Try SDFSHC32d
Attachment 4910
ENDIF
:)
I have been using it with a 4 gig card. The only change I had to make in my code from MELABS SDFS was the INCLUDE statement and in SDFSHC32d change the pin aliases to match my hardware.
Thank you Jeremy for making the modifications.
1 Attachment(s)
SDHC32D need help i am stuck here =[
Hello Guys,
i am new with sd cards and i have read almost all posts about them and seriously only you are talking about FAT32 format and have the files.Can anyone guide me?? I am not asking to get free code or something im just stuck here :frown: :frown:. I have tried just to initialize the card but i failed. Iam using 18F26K22 hardware SSP1 module for communicating with the card and hardware EUART to debug the programm. I dont want to use the SD_WE and SD_CD and i simply didn't connect them.
Here is what i tried so far but the programm is stucked at "Gosub FSinit" command.
Code:
'-------------------------------------------------------------------------------
'DEFINES DEFINES DEFINES DEFINES DEFINES DEFINES DEFINES DEFINES DEFINES
'-------------------------------------------------------------------------------
include "modedefs.bas"
include "fuses_18f26k22.bas"
include "eusart_defines_ep7.bas"
DEFINE OSC 32
'-------------------------------------------------------------------------------
'VARIABLES VARIABLES VARIABLES VARIABLES VARIABLES VARIABLES VARIABLES
'-------------------------------------------------------------------------------
i var byte
' COUNTERS COUNTERS COUNTERS COUNTERS COUNTERS COUNTERS COUNTERS COUNTERS
'-------------------------------------------------------------------------------
' FLAGS FLAGS FLAGS FLAGS FLAGS FLAGS FLAGS FLAGS FLAGS FLAGS FLAGS
'-------------------------------------------------------------------------------
' ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAYS ARRAY
'-------------------------------------------------------------------------------
' PORTS PORTS PORTS PORTS PORTS PORTS PORTS PORTS PORTS PORTS PORTS
'-------------------------------------------------------------------------------
' REGISTERS REGISTERS REGISTERS REGISTERS REGISTERS REGISTERS REGISTERS
'-------------------------------------------------------------------------------
TRISA= %00000000
TRISB= %00000011
TRISC= %00010000
ANSELA=0
ANSELB=0
ANSELC=0
include "SDFSHC32original.bas"
SDC_UseHardSPI = TRUE
goto Init
'-------------------------------------------------------------------------------
'ISR ISR ISR ISR ISR ISR ISR ISR ISR ISR ISR ISR ISR
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
' Initialization Initialization Initialization Initialization
'-------------------------------------------------------------------------------
Init:
PORTB= 0
PORTA= 0
PORTC= 0
FAT_FileName[0] = "N"
FAT_FileName[1] = "A"
FAT_FileName[2] = "M"
FAT_FileName[3] = "E"
FAT_FileName[4] = "S"
FAT_FileName[5] = " "
FAT_FileName[6] = " "
FAT_FileName[7] = " "
FAT_FileName[8] = "T"
FAT_FileName[9] = "X"
FAT_FileName[10]= "T"
Hserout ["Init routine: OK!",13,10]
for i=0 to 10
Hserout [fat_filename[i]]
next i
Hserout [13,10]
i= 0
PAUSE 100
'-------------------------------------------------------------------------------
' Main Programm Main Programm Main Programm Main Programm Main Programm
'-------------------------------------------------------------------------------
Main:
Hserout ["LoopCount= ",dec i," FAT_error= ",dec fat_error," SDC_status= ",_
dec SDC_status," SDC_response= ",dec SDC_response,13,10]
Gosub FSInit
pause 10
Gosub FSInit
i= i+1
goto Main
'-------------------------------------------------------------------------------
'Subroutines Subroutines Subroutines Subroutines Subroutines Subroutines
'-------------------------------------------------------------------------------
end
and my SDFSHC32D.bas file is attached.
Attachment 7084
Im looking forward for an answer, Kostas.
Re: SDHC (FAT32 for SD cards)
I'm having the same problem described at the end of this (dead?) thread. Was there ever a solution? BTW, I had it working for FAT16 - so hardware is probably OK.
Thx
Re: SDHC (FAT32 for SD cards)
FAT16 works. For 32 there is nothing good up to this moment. Also other compilers are good only at 16 as far as I know.
Ioannis
Re: SDHC (FAT32 for SD cards)
Quote:
Originally Posted by
Ioannis
FAT16 works. For 32 there is nothing good up to this moment. Also other compilers are good only at 16 as far as I know.
But what about the posts above. Looks like some folks had a FAT32 library working. Am I missing something?
Re: SDHC (FAT32 for SD cards)
Officially there is no library for FAT32 by Melabs. All others are experimental and with no warranty that it will not corrupt your card.
You said on post #14 you are having problems. Same #13. Same with me.
Ioannis
Re: SDHC (FAT32 for SD cards)
Quote:
Originally Posted by
mackrackit
IF
You have used SDFS3 from MeLabs
http://www.melabs.com/resources/samples/pbp/sdfs3.zip AND
Now you would like to be able to use High Capacity cards
THEN
Try SDFSHC32d
Attachment 4910
ENDIF
:)
I have been using it with a 4 gig card. The only change I had to make in my code from MELABS SDFS was the INCLUDE statement and in SDFSHC32d change the pin aliases to match my hardware.
Thank you Jeremy for making the modifications.
hi, i try this code but i can not worked. this code loops "waitfortime" function.what can i do?
Re: SDHC (FAT32 for SD cards)
I have 2 SD cards 2GB and 16GB, both formated as FAT32. 2GB works fine, 16 fails initialization.
It fails to select FAT32
Code:
Select Case (DISK_buffer[450])
Case $01
DISK_type = FAT12 : FAT_error = CE_CARDFAT12
Case $04, $06, $0e
DISK_type = FAT16
Case $0b, $0c
DISK_type = FAT32
Case Else
FAT_error = CE_BAD_PARTITION
End Select
Goes straight to FAT_error = CE_BAD_PARTITION
Tried to select FAT32, but then fails later..
As far as I understand up to 32GB should be supported.
Any update on that?
Re: SDHC (FAT32 for SD cards)
What IS the partition type value in DISK_buffer[450]?
Looking at that byte isn't really the way to determine FAT16/FAT32...
Re: SDHC (FAT32 for SD cards)
I think $72. I'll check later.
But that is way they do it... I'm not familiar at all with anything regarding SD.
I was hoping that I could just use module as is...
First I edited my project from 2012, and it would create file on sd card, but wouldn't write nothing into file. That was case with both cards(2 and 16 gb)...
Then I remove all files, and download new. First I get it to work with FAT16(2gb card), then replace INCLUDE "SDFS.pbp" with INCLUDE "sdfshc32d.pbp". Tried 2GB formated as fat 16 and fat32 and it worked. Then tried 16gb fat32 and then get it to fail at FSInit, error 6 (CE_INIT_ERROR Con 6 ' An initialization error has occured)
What else I could check and report back, if you are interested in improving sdfshc32d.
Re: SDHC (FAT32 for SD cards)
Now fails here
Code:
For SDC_timeout1.lowbyte = $ff To 0 Step -1
SDC_sector_addr = 0 : Gosub SectorRead ' Long SDC_sector_addr is the sector to read. Returns Byte SDC_status.
If (SDC_status = sdcValid) Then SDC_timeout1 = 0 ' Got a valid response, end the loop.
Next SDC_timeout1.lowbyte
If (SDC_status != sdcValid) Then SDC_status = sdcCardNotInitFailure : Goto InitError
Return ' Return Byte SDC_status.
SDC_status=2
SDC_response=$A9
FAT_error=6
Re: SDHC (FAT32 for SD cards)
I don't have answers, only more questions:
- Are you sure it's even a coding issue?
Doesn't going over 2GB put you into another category of card speeds?
Are PIC18Fs even fast enough to process these I/Os?
For example:
https://www.spypoint.com/en/blog/41/...-types-classes
I'm sure the larger/faster/newer PICs can do it, but I know nothing about them except Microchip advertisements.
Robert