MicroSD card

General discussion on mikroPascal PRO for ARM.
Post Reply
Author
Message
serg1980
Posts: 44
Joined: 19 Mar 2014 05:58

MicroSD card

#1 Post by serg1980 » 12 Sep 2020 15:45

Hello! How to get a list of files on a microsd card. I've tried using functions: Mmc_Fat_Dir and Mmc_Fat_ReadDir, but I still don't understand how to work with them.
Thank you in advance

Pelikan
Posts: 219
Joined: 22 Nov 2012 07:58

Re: MicroSD card

#2 Post by Pelikan » 13 Sep 2020 21:13

Hello Sergej,
what is your problem?


Mmc_Fat_Dir comes later, first recognizing and initializing the SD card. Is that possible? what is the memory size of the card? Which MC? The ME-Libs only make FAT16, so only suitable for small memories.
A long time ago I tried something with an SD card, attached

With regards
Peter
Attachments
Demo_SDIO.zip
(8.5 KiB) Downloaded 66 times

serg1980
Posts: 44
Joined: 19 Mar 2014 05:58

Re: MicroSD card

#3 Post by serg1980 » 14 Sep 2020 08:09

Hello Pelikan!
the memory card was initialized in SPI mode. The memory capacity is 2 GB. I need to get a list of files that are on this memory card and display them. Maybe you need to use the FAT32 library?

User avatar
stefan.filipovic
mikroElektronika team
Posts: 1135
Joined: 18 Dec 2018 10:30

Re: MicroSD card

#4 Post by stefan.filipovic » 14 Sep 2020 11:55

Hi,

Mmc_Fat_Dir routine displays the contents of the current directory via a user-defined medium (i.e. UART module, a file on the FAT16 file system). The function displays character by character.
Parameters - print: ^TProcedure - function pointer to a routine which will display contents of the current directory.

The routine should be defined as below.

Code: Select all

// Displaying routine
procedure PrintChar(ch : byte);
begin
  UART1_Write(ch);
end;
Now just call the following line from the main routine:

Code: Select all

Mmc_Fat_Dir(@PrintChar);
Kind regards,
Stefan Filipović

serg1980
Posts: 44
Joined: 19 Mar 2014 05:58

Re: MicroSD card

#5 Post by serg1980 » 14 Sep 2020 17:17

stefan.filipovic wrote:
14 Sep 2020 11:55
Hi,

Mmc_Fat_Dir routine displays the contents of the current directory via a user-defined medium (i.e. UART module, a file on the FAT16 file system). The function displays character by character.
Parameters - print: ^TProcedure - function pointer to a routine which will display contents of the current directory.

The routine should be defined as below.

Code: Select all

// Displaying routine
procedure PrintChar(ch : byte);
begin
  UART1_Write(ch);
end;
Now just call the following line from the main routine:

Code: Select all

Mmc_Fat_Dir(@PrintChar);
Kind regards,
This was my mistake
Attachments
111.png
111.png (13.15 KiB) Viewed 2286 times

serg1980
Posts: 44
Joined: 19 Mar 2014 05:58

Re: MicroSD card

#6 Post by serg1980 » 15 Sep 2020 08:38

HI!
How to use the Mmc_Fat_ReadDir function?
I tried to do as it is written in the help file, but the compiler gives an bug.

Code: Select all

if (1 = Mmc_Fat_ReadDir('DIR_A')) then
begin
...
end;
Incompatible types ("array" to "record") MMC_Fat16_Test.mpas

Then I tried to do it in a different way

Code: Select all

var dir_info: F16_DIR;
....
if (1 = Mmc_Fat_ReadDir(dir_info)) then
begin
...
end;
But still nothing is written to this variable

serg1980
Posts: 44
Joined: 19 Mar 2014 05:58

Re: MicroSD card

#7 Post by serg1980 » 15 Sep 2020 14:52

I liked the FAT32 library better. I was able to get a list of files on the memory card

Code: Select all

var Dir_Info: __DIR;
...
 SSD1306_Init(400000,1);
  SSD1306_Fill($00);
  SSD1306_Set_Font(@SSD1306_F5x7,6,7,32);
  initSPI();
 info:=FAT32_Init;
  if info  = 0 then SSD1306_Draw_String(0,0,0,'MSD_FAT32 Init OK')
               else SSD1306_Draw_String(0,0,0,'MSD_FAT32 Init Error');
  initFastSPI();
  Dir_Name:='\';
  FAT32_ChangeDir(@Dir_Name);
  info:=FAT32_FindFirst(@Dir_Info);
  if info = 1 then SSD1306_Draw_String(0,1,0, Dir_Info.NameExt);
  repeat
   info:=FAT32_FindNext(@Dir_Info);
   Inc(cn);
   if info = 1 then SSD1306_Draw_String(0,cn,0, Dir_Info.NameExt);
  until info <> 1;
  
Attention! Before using this library, the memory card must be formatted in FAT32 format

Post Reply

Return to “mikroPascal PRO for ARM General”