SDFileSystem.bas ???
Moderators: David Barker, Jerry Messina
Try downloading the wiki version - as far as I know, the CD does not include this latest version. You will have to change the Init line in your code though - the SPI speed is set as a #option now, before the include statement at the top of the code. The examples at the bottom of the wiki page should help with this. If the newer version still doesn't work, let me know again.
-
- Registered User
- Posts: 26
- Joined: Sun Oct 12, 2008 11:21 pm
- Location: Utah
Down loaded the new version from wiki. Made the code changes relating to Init. Added line to send the error number from init to usart. I get error 10, noresponse.
I am using a microSD card and connector. The pinout is diferent from the SD card example in the help file. I have check this with the pinouts listed on several sites and believe i have it correct. Have also done continuity and short checks on the board. As well as added 10K resistors to the SD0 and SDI lines.
I also looked thru the SD.Init code to verify that the register names in the code matched with the names for the 18F24J10, it appears they do.
Going to recheck all conections, and continuity/shorts. And add a pullup on the CS line.
I checked that the microSD card does work by checking it on my PC. I believe i read some where that there must be a master boot record on the card, and that some cards do not include this. Not sure how i would check to see if there is a master boot record.
I also downloaded a formater from panasonic to format the card. Supposedly this will place a Master boot record on the card.
Any other suggestions wellcom.
RD
I am using a microSD card and connector. The pinout is diferent from the SD card example in the help file. I have check this with the pinouts listed on several sites and believe i have it correct. Have also done continuity and short checks on the board. As well as added 10K resistors to the SD0 and SDI lines.
I also looked thru the SD.Init code to verify that the register names in the code matched with the names for the 18F24J10, it appears they do.
Going to recheck all conections, and continuity/shorts. And add a pullup on the CS line.
I checked that the microSD card does work by checking it on my PC. I believe i read some where that there must be a master boot record on the card, and that some cards do not include this. Not sure how i would check to see if there is a master boot record.
I also downloaded a formater from panasonic to format the card. Supposedly this will place a Master boot record on the card.
Any other suggestions wellcom.
RD
The SD module will accept cards with or without a Master Boot Record, so don't worry on that one. With the new version of the module, all that is needed is a FAT16 or FAT32 format. A pull-up on CS shouldn't be required either. Is it worth checking that you have SDI on the card connected to SDO on the PIC and vice versa?
-
- Registered User
- Posts: 26
- Joined: Sun Oct 12, 2008 11:21 pm
- Location: Utah
In order to check if the DI, DO lines where reversed i changed to SW control and set the SD_DO etc. to their respective pins on the chip.
While in SW control i reversed the SD-DI and SD_DO pins
all resulted in the same result.
Included my code below so you can see where i added the SW control parts.
I put an extra uart.write that outputs "Set Baud" before the init sequence. I get the following on the serial comunicator.
--------------------------
Set Baud
Initialising card...
Set Baud
Initialising card...
Set Baud
Initialising card...
------------------------------
This repeats for ever. It appears to me that the processor is reseting. I looked thru the init code and could not see any way the code would cause the program to restart. Does the code do this OR is my processor reseting each time the init function is run? I am aparently never getting a return value from the init function.
I even added an extra 10uF across the power supply to see if that would help.
While in SW control i reversed the SD-DI and SD_DO pins
all resulted in the same result.
Included my code below so you can see where i added the SW control parts.
I put an extra uart.write that outputs "Set Baud" before the init sequence. I get the following on the serial comunicator.
--------------------------
Set Baud
Initialising card...
Set Baud
Initialising card...
Set Baud
Initialising card...
------------------------------
This repeats for ever. It appears to me that the processor is reseting. I looked thru the init code and could not see any way the code would cause the program to restart. Does the code do this OR is my processor reseting each time the init function is run? I am aparently never getting a return value from the init function.
I even added an extra 10uF across the power supply to see if that would help.
Code: Select all
// device and clock...
Device = 18F24J10
Clock = 20
Config
DEBUG = OFF,
XINST = OFF,
STVREN = ON,
WDTEN = ON,
FCMEN = ON,
IESO = OFF,
FOSC2 = ON,
FOSC = HS,
WDTPS = 128
// import SD file system, usart and conversion modules...
#option SD_SPI = MSSP // use hardware SPI
#option SD_SPI_SPEED = spiOscDiv64
'#OPTION SD_CS = PORTC.2
'#OPTION SD_DI = PORTC.5
'#OPTION SD_CLK = PORTC.3
'#OPTION SD_DO = PORTC.4
Include "SDFileSystem.bas"
Include "usart.bas"
Include "Convert.bas"
// variables...
Dim Index As Byte
Dim InitError As Byte
// program start...
SetBaudrate(br19200)
DelayMS(500)
USART.Write("Set Baud ", 13, 10)
USART.Write("Initialising card...", 13, 10)
InitError = SD.Init()
If InitError = errOK Then
// format SD card...
USART.Write("Formatting, please wait...", 13, 10)
QuickFormat
// write data to SD card...
USART.Write("Writing data, please wait...", 13, 10)
If SD.NewFile("test.txt") = errOK Then
For Index = 0 To 255
SD.Write("Line ",DecToStr(Index,3), 13, 10)
Next
SD.CloseFile
EndIf
// read data back...
USART.Write("Reading data...", 13, 10)
If SD.OpenFile("test.txt") = errOK Then
Repeat
USART.Write(SD.ReadByte())
Until SD.EOF
SD.CloseFile
USART.Write("Finished.", 13, 10)
EndIf
Else
USART.Write("Not Initialized...",DecToStr(InitError,4), 13, 10)
EndIf
End
-
- Registered User
- Posts: 26
- Joined: Sun Oct 12, 2008 11:21 pm
- Location: Utah
This page on the wiki might help - http://www.sfcompiler.co.uk/wiki/pmwiki ... ish.FAQ#Q1. Good to hear that it is now working. I'd be grateful to know if it works with the watchdog re-enabled, but with the #option set for it.
-
- Registered User
- Posts: 26
- Joined: Sun Oct 12, 2008 11:21 pm
- Location: Utah