View previous topic :: View next topic |
Author |
Message |
manans
Joined: 30 Jan 2009 Posts: 18
|
Posted: Fri Jul 08, 2011 7:54 am Post subject: For Beginners... |
|
|
Hello Niclas,
Very goog work....I am new to SD card interfacing....I read your library, but honestly I could not relate it.... I want to interface SD_HC card with xmega controller...I want to create a file and write it to on SD card and save it....How to start is a question for me.....Your help will be great for me..... |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Fri Jul 08, 2011 6:52 pm Post subject: |
|
|
Hi Manans
I'm sorry, but I can't provide beginner's help. Please understand that I am providing this free of charge, which means the users need to learn on their own. This support forum is primarily intended for getting help when a real (or suspected) bug is found in my code.
Please see the files named Example_*.bas, Main.bas, and KokkeKat FAT-free SD library Application Note v1.0.pdf.
If anything is unclear after reading them, please post a detailed description of the problem you are facing.
You could also take a look in the other threads in this forum.
Kind regards
Niclas |
|
Back to top |
|
|
manans
Joined: 30 Jan 2009 Posts: 18
|
Posted: Wed Jul 13, 2011 11:41 am Post subject: |
|
|
I have read main program and after compiling it gives 4 errors...Assignement errors and if endif error
my SDusefind=0 and Sddirlist=1
how to remove this? |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Wed Jul 13, 2011 4:11 pm Post subject: |
|
|
Hi Manans
Could you please post your developer settings from the declarations file and also the exact error messages you receive?
Kind regards
Niclas |
|
Back to top |
|
|
manans
Joined: 30 Jan 2009 Posts: 18
|
Posted: Thu Jul 14, 2011 7:03 am Post subject: |
|
|
Hi Niclas,
I found it that when I include write file example then I get those errors, but when I comment it then it goes...
It belongs to write file example ....
now in write file example...
Sdentrynames = "138 TXT"
what does it mean?? |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Thu Jul 14, 2011 8:37 am Post subject: |
|
|
Hi Manans
Without any information to go on, I would guess that you either have a non-working combination of developer settings or you are including an example file that doesn't work with your developer settings. It might be that variable Sdentrynames gets declared twice because of this.
If you want me to help you further, you must follow my instructions so I can get the information I need. Could you please post your developer settings from the declarations file and also the exact error messages you receive?
Kind regards
Niclas |
|
Back to top |
|
|
manans
Joined: 30 Jan 2009 Posts: 18
|
Posted: Thu Jul 14, 2011 12:57 pm Post subject: |
|
|
sorry for not giving what you want....
switches...
' Developer switches:
' 1 = minimum detail (only make sure that the init is successful)
' 0 = full detail (return full detail if init is unsuccessful)
Const Sdinitdetail = 1
' 1 = FAT16/32 file system active
' 0 = FAT16/32 file system not active (only read and write raw sectors)
Const Sdfsactive = 1
' 1 = Use the FIND routine
' 0 = Don't use the FIND routine
Const Sdusefind = 0
' 1 = Enable Sdusefindstoreentry
' 0 = Don't enable Sdusefindstoreentry
Const Sdusefindstoreentry = 0
' 1 = Use Sddirlist
' 0 = Don't use Sddirlist
Const Sdusedirlist = 1 ' Use or don't use
Const Sddirlistarraysize = 12 ' If used, set the size of the array that holds the cluster numbers
' 1 = read
' 0 = not reading
Const Sdrmode = 1
' 2 = write unbuffered
' 1 = write buffered
' 0 = not writing
Const Sdwmode = 0
' 1 = Use Sdappend
' 0 = Don't use Sdappend
Const Sduseappend = 0
' 1 = Clear the unused end of the sector before writing it to the SD card
' 0 = Don't clear the unused end of the sector before writing it to the SD card
Const Sdcleartail = 0
' 1 = Use FAT32 fsinfo sector data
' 0 = Don't use FAT32 fsinfo sector
Const Sdusefsinfo = 0
' 1 = Use Long FileNames when reading
' 0 = Don't use Long FileNames when reading
Const Sduselfn = 1
' 1 = When using lfn, also support file name comparison
' 0 = When using lfn, don't support file name comparison
Const Sduselfncompare = 0
' 1 = Use wipe
' 0 = Don't use wipe
Const Sdusewipe = 0
' 1 = Use the size info routine
' 0 = Don't use the size info routine
Const Sdusesizeinfo = 0
' 1 = Use the CRC7 function
' 0 = Don't use the CRC7 function
Const Sdusecrc7 = 0 ' This has no practical use in the library - use it if you want to add CRC7 checks yourself
Error message:File is attached. |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Thu Jul 14, 2011 1:17 pm Post subject: |
|
|
Hi Manans
Thanks. If you want to write, you need to set this switch to 1 or 2:
' 2 = write unbuffered
' 1 = write buffered
' 0 = not writing
Const Sdwmode = 0
In this case, I also recommend setting this switch to 1:
' 1 = Use FAT32 fsinfo sector data
' 0 = Don't use FAT32 fsinfo sector
Const Sdusefsinfo = 0
Please also notice the bugs and fixes reported in one of the sticky threads.
Kind regards
Niclas |
|
Back to top |
|
|
manans
Joined: 30 Jan 2009 Posts: 18
|
Posted: Sun Jul 24, 2011 7:48 pm Post subject: |
|
|
Hi Niclas,
I am currently following your code, meanwhile I want to ask you couple of questions..
1. If I create a file, where I can write the file name?....which can be dynamic.....
2. After writing so many file (say 100) then If I want to search file from SD card....is it possible....? |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Wed Jul 27, 2011 1:23 am Post subject: |
|
|
Hi Manans
Yes. Please see the example code included in the download zip file.
Kind regards
Niclas |
|
Back to top |
|
|
manans
Joined: 30 Jan 2009 Posts: 18
|
Posted: Tue Aug 02, 2011 1:17 pm Post subject: |
|
|
Hi Niclas,
I am building the schematic as shown in the pdf of yours. I wonder you have shown 5 resistors one side connected to 3.3v and other side at respective pins..Is it for pulling up or is it something related 5v-3.3v adjustment...
Secondly after this when I compile and load hex file of Main.bas for writing a file, do I need to copy and paste whole program of "example_write_file_"in the main.bas ? or include statement itself executes the whole program(like any function)....If yes then how I can give dynamic file name and write dynamic data?
sorry for troubling...it seems I am not following good enough... |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Tue Aug 02, 2011 1:35 pm Post subject: |
|
|
Hi Manans
Yes, the resistors are needed for pull-up to 2.7-3.6V. It is absolutely necessary that you have a good power supply that can deliver enough current within this voltage range. Any 3.3V voltage regulator with matching filter capacitors should work. If you use 5V, you are very likely to fry the SD card sooner or later.
Please see the Bascom help from inside the editor. Type "include", position your cursor and click inside this text and then press F1. INCLUDEs are used so that you don't have to physically copy the code into your program. Just include it and make sure that you include the data declarations at the beginning and the code at the end. The code in the include file typically is functions, subroutines, or gosubs.
See the example file for writing a file. The filename should be placed either in string Sdentrynames or in byte array Sdentrynameb(). Make sure that you follow the 8.3 naming rules. Simple rule: Use only CAPITAL English letters and "_" and you'll be fine. Don't enter the "." It is implicit.
Kind regards
Niclas |
|
Back to top |
|
|
manans
Joined: 30 Jan 2009 Posts: 18
|
Posted: Wed Aug 03, 2011 8:31 am Post subject: |
|
|
Hi Niclas,
Thank you so much for reply, its making me more interesting...
As I understand about include statement which is just like any function residing as a different file name....now as I want to give dynamic file name I have to declare sdentrynames or byte array Sdentrynameb in the Main file OR it is declared at in other file(global so I can use it anywhere)... and after doing so I have to modify statements in "write_file" regarding file name...(sdentrynames should be deleted from file)
And same thing for dynamic data entry....sdtempb2 declaration and data assignment....
If I want to write 20 different bytes what I should write in my Main file....
I wonder If I can remove the include statement and use that file inside main.bas as a function....is it possible? |
|
Back to top |
|
|
KokkeKat
Joined: 08 May 2011 Posts: 59 Location: Stockholm
|
Posted: Wed Aug 03, 2011 10:53 am Post subject: |
|
|
Hi Manans
Please look at the two library files included in the zip file. One contains the developer switches and data declarations and the other contains the code. All the declarations required for this library are included already.
Do not change the data declarations or code in the two library files (except for the bugfix found in a separate thread). (If you do, I won't be able to support you.)
When you have successfully used the example code to create a file, you can copy the code from Main.bas and Example_...bas into your own program.
Kind regards
Niclas |
|
Back to top |
|
|
manans
Joined: 30 Jan 2009 Posts: 18
|
Posted: Fri Aug 26, 2011 10:34 am Post subject: |
|
|
Hi Niclas!
I have one doubt, is this library work on Micro SD card? I have read that in MicroSD card the SPI mode is optional. So should I try on SD card? (the big one). Which card you have used? |
|
Back to top |
|
|
|