read all files on SD card
read all files on SD card
Hello,
I'm using the XMEGA for AVR and planning to make an mp3 player. Perhaps someone can give me mikroC code example for reading all files on sd and listing them on tft or putting them in a .txt .
Thanks in advance.
I'm using the XMEGA for AVR and planning to make an mp3 player. Perhaps someone can give me mikroC code example for reading all files on sd and listing them on tft or putting them in a .txt .
Thanks in advance.
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: read all files on SD card
Hello,
Please take a look at this topic.
It demonstrates how to do DIR and save result in a txt file:
http://www.mikroe.com/forum/viewtopic.p ... ir#p183856
Best regards.
Please take a look at this topic.
It demonstrates how to do DIR and save result in a txt file:
http://www.mikroe.com/forum/viewtopic.p ... ir#p183856
Best regards.
Re: read all files on SD card
I've already tried to modify that example before , unsuccesfully. it's in mikroBasic i think?
I need example for mikroC.
i'm new to this. can you please give an example in mikroC?
thanks.
I need example for mikroC.
i'm new to this. can you please give an example in mikroC?
thanks.
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: read all files on SD card
Hello,
Best regards.
Code: Select all
char buffer[256];
char fhandle, i;
void fillbuffer(char ch){
buffer[i] = ch;
i++;
}
....
Mmc_Fat_Dir(&fillbuffer);
buffer[i] = 0;
fhandle = Mmc_Fat_Open("newfile.txt", FILE_APPEND, 0xA0);
Mmc_Fat_Write(buffer, strlen(buffer));
Re: read all files on SD card
thanks, this is my code:
there are supposed to be 20 files on the sd card, and the result i get is
" 1:63:62 Dp
--A----- 2492289 28/04/2007 00:12:40 THCE51~1.MP3
----LSHR 31/15/2107 31:63:62 Dm
--A----- 2806177 28/04/2007 00:08:58 TH9B22~1.MP3
--A----- 3326954 28/04/2007 00:11:34 SOUND.MP3 "
what am missing or what am I doing wrong?
Code: Select all
/*************************************************************************************************
*read_dir
**************************************************************************************************/
char buffer[256];
char fhandle, i, ch;
void fillbuffer(char ch){
buffer[i] = ch;
i++;
}
/**************************************************************************************************
* main function
**************************************************************************************************/
void main(){
InitMCU();
DrawMP3Scr();
MP3_Start();
MP3_Test(&ucMP3_run_test);
fillbuffer(ch);
Mmc_Fat_Dir(&fillbuffer);
buffer[i] = 0;
Mmc_Fat_Assign("test.doc", 0xA0);
mmc_fat_rewrite();
Mmc_Fat_Write(buffer, strlen(buffer));
}
there are supposed to be 20 files on the sd card, and the result i get is
" 1:63:62 Dp
--A----- 2492289 28/04/2007 00:12:40 THCE51~1.MP3
----LSHR 31/15/2107 31:63:62 Dm
--A----- 2806177 28/04/2007 00:08:58 TH9B22~1.MP3
--A----- 3326954 28/04/2007 00:11:34 SOUND.MP3 "
what am missing or what am I doing wrong?
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: read all files on SD card
Hello,
At the moment our FAT library supports short file name format (DOS8.3).
Please try to rename your files on the SD card according to this standard and try again.
Best regards.
At the moment our FAT library supports short file name format (DOS8.3).
Please try to rename your files on the SD card according to this standard and try again.
Best regards.
Re: read all files on SD card
Hello,
does fat32_dir() work the same way, and is there any way to read LFN?
thanks.
does fat32_dir() work the same way, and is there any way to read LFN?
thanks.
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: read all files on SD card
Hello,
FAT32_dir works the same way.
At the moment LFN is not supported in FAT32 library.
Only short (8.3) format.
Best regards.
FAT32_dir works the same way.
At the moment LFN is not supported in FAT32 library.
Only short (8.3) format.
Best regards.
Re: read all files on SD card
thank you.
when i try the same routine, but instead of mmc_fat_dir(&fillbuffer), I use fat32_dir(&fillbuffer), it says, "to many actual parameters".
and also mmc_fat_open doesn't work for me, for both fat and fat32 libraries, it says "undeclared identifier".
thanks.
when i try the same routine, but instead of mmc_fat_dir(&fillbuffer), I use fat32_dir(&fillbuffer), it says, "to many actual parameters".
and also mmc_fat_open doesn't work for me, for both fat and fat32 libraries, it says "undeclared identifier".
thanks.
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: read all files on SD card
Hello,
DIR function in FAT32 library has default function which is used for output.
Please check FAT32_Put_Char function in help file.
You can declare this function as I did in my example with fillbuffer function.
You are getting undeclared identifier because you need to include proper header file in your project.
With regular FAT library add:
Just like we did in our example.
Best regards.
DIR function in FAT32 library has default function which is used for output.
Please check FAT32_Put_Char function in help file.
You can declare this function as I did in my example with fillbuffer function.
You are getting undeclared identifier because you need to include proper header file in your project.
With regular FAT library add:
Code: Select all
#include "__Lib_MmcFat16.h"
Best regards.
Re: read all files on SD card
hello,
I was wondering if there is a solution for the floating point results that is displayed in the calculator example for the mikromeadia for xmega board. for example 56/2 returns 27.99999, instead of 28. I am looking for a mikroC solution.
thanks.
I was wondering if there is a solution for the floating point results that is displayed in the calculator example for the mikromeadia for xmega board. for example 56/2 returns 27.99999, instead of 28. I am looking for a mikroC solution.
thanks.
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: read all files on SD card
Hello,
I believe that this is fixed in latest version of the VisualTFT Tool.
You can also try with following calculation:
Best regards.
I believe that this is fixed in latest version of the VisualTFT Tool.
You can also try with following calculation:
Code: Select all
result = first_operand + second_operand;
IntToStr((int)ceil(result), Label6_Caption);
Re: read all files on SD card
hello,
yes, but if the result is float not integer, as in 55/2 = 27.5, ceil function will make it 28. This does'nt happen all the time and only with random numbers. for example 1/4 returns 0.25, but as said before 56/2 always returns 27.99999.
yes, but if the result is float not integer, as in 55/2 = 27.5, ceil function will make it 28. This does'nt happen all the time and only with random numbers. for example 1/4 returns 0.25, but as said before 56/2 always returns 27.99999.
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: read all files on SD card
Hello,
You can try to implement some algorithm for rounding results.
It is known that float point numbers have issues with accuracy and this kind of number representation may occur.
Best regards.
You can try to implement some algorithm for rounding results.
It is known that float point numbers have issues with accuracy and this kind of number representation may occur.
Best regards.
-
- Posts: 13
- Joined: 15 Feb 2014 17:00
Re: read all files on SD card
Hi ,
I am using EasyPIC V7. with SmartMP3 Board and Fat32 Lib.
Fat32 Lib commands doesn't return LFN File Names but returns 0x0F attributes with empty file names.
I don't want to get LFN File Names but i just want to play them without knowing names.(For example StartCluster value)
Can i do this with Mikroe FAT32 Lib and how?
Best Regards,
I am using EasyPIC V7. with SmartMP3 Board and Fat32 Lib.
Fat32 Lib commands doesn't return LFN File Names but returns 0x0F attributes with empty file names.
I don't want to get LFN File Names but i just want to play them without knowing names.(For example StartCluster value)
Can i do this with Mikroe FAT32 Lib and how?
Best Regards,