How to set up smartphones and PCs. Informational portal
  • home
  • news
  • How to connect SD card to microcontroller? (primitive way). The computer does not see the sd, minisd, microsd memory card

How to connect SD card to microcontroller? (primitive way). The computer does not see the sd, minisd, microsd memory card

Articles and Life Hacks

A common question, how to enable memory card on phone, interests many owners of mobile devices, on which there is very little free space for storing useful information. Sometimes users even have a need to copy the necessary files into it and free up the memory of their mobile phone.

Installing a memory card on the phone

1. In order to install a memory card on the device, you will need to find a connection slot for this part on the phone itself. As a rule, it is located on the side of the gadget panel.

2. Then the selected map is loaded here, which is suitable for the user in terms of volume.

3. It is necessary to check how firmly the part is fixed in the slot. If all is well, an expressive click will be heard. As a rule, nothing else needs to be done to detect the memory card by the telephone. However, there may be exceptions.

What to do if the memory card is not visible to the phone

Often, reading information from a working memory card, as opposed to an elementary one, becomes a real problem. That is why many users are wondering how to turn on the memory card on the phone, if it is not visible as a USB device and is not displayed at all on the device.

1. If such an add-on is installed on the mobile phone, then the difficulties can be solved by using a card reader. This device is a true universal adapter. His work is focused just on reading information from various memory cards.

2. Card readers are different: multi-format, built-in and single format. That is why, when choosing it, you should pay attention to the use of the memory card itself in the phone: Micro SD, Mini SD or SD.

3. To turn on the memory card, you first need to connect the card reader to the PC. On the phone, you must close all applications and folders.

Then the memory card is removed from the mobile phone and loaded into a special device. After the adapter is connected, the information will be displayed in a folder named "my computer". As a rule, after data manipulation, the card begins to interact perfectly with the phone itself. However, for safety reasons, it is still recommended to transfer data from a mobile device to a PC.

Among other tips, it is worth noting that many experts recommend purchasing the largest memory card in terms of volume.

Maybe the phone does not support a 12GB card

Types of flash cards. Is SD card supported by your card reader? Here I would like to dwell in more detail. ... Usually, upon purchase, a small adapter is included with them, so that this flash drive can be connected instead of an SD card ...

So maybe your phone can accept SD cards with a maximum capacity of 8 GB ... Look at the characteristics of your phone

Go to the website of the phone manufacturer, or an online store and see what cards it supports, and where did you get the 12 ??? usually they go 8, 16, 32)

Format card

How to enable SD card on Android?

Insert it

If you can't connect your Android tablet to your computer, try restarting it. This often happens when you insert or remove an SD card or connect and disconnect USB several times in a row.

Why does not the computer see the android phone, but sees the SD card ???

Possible problem: Set the connection mode on the phone as a carrier. Or access to the card is blocked, this can be changed in the settings. I can’t tell you more specifically, from android only to you.

Samsung a7 only charges when connected to Windows 8. How to connect it for file sharing? ... go to Settings-memory-remove the SD card, then connect to your computer as USB.

Help! Can't turn on and configure SD card !! Lenovo A390 version OC Android 4.0.4

Settings - Memory - Select removable memory.

We bought an SD card right away. the problem was not long in coming. NEITHER hyphenated apps nor explorer apps solve this problem. Model A328 Android 4.4.2.

What needs to be done so that on Android 4.4.2 kitkat the game cache is written to the sd card

Enable root and install games to SD.

Hello and on android 4.4.2 what program can you download so that it can be downloaded directly to sd ??? ... LG L7 transfer apps to SD card. File unpacking error. What folder is the application file downloaded to before installing on android?

Here is all the information about the cache. http://mobigama.net/kesh_na_android.html Everything is described in detail, as they say, you won't get lost)))

How to connect SD card to iPhone 5c

No way. Iphone do not accept external memory

DirectoryBind works on Android since 2.3.3 and 4.0.x. ... Getting started Menu gt Settings gt Application manager gt scroll the page to the right gt SD memory card gt Put a tick on the selected program gt Press the button - To the SD memory card.

There are no slots for sd cards

I did this to my sister when she didn’t have enough memory, downloaded the "Cloud Mail.Ru" application from the play market (though she has a Samsung phone on android, but I think that for the iPhone this application should be I don’t know where you download them from, but it must be, an analogue of Dropbox, if anything, but in Dropbox 20 GB of memory is given and in mail.ru 100 GB) and threw all her photos and videos into this mail.ru cloud straight from the hundred, after they were completely downloaded into this cloud from the hundred, I deleted them And the memory is freed up, you can now put games and shoot videos and take pictures and you don't need a flash drive, you just need access to the Internet (preferably with good speed) to your wealth! and through this application, if there is an Internet, all this wealth is as if you have left in a hundred and at any time you can download from even a hundred even from a computer with access to your mail, and you can open and close access to anyone by creating and deleting links to these files, it would seem like a trifle but pleasantly convenient) so after that her friends tortured me with this, what and how, everyone liked it, if I do not explain very clearly, then ask someone older to familiarize themselves with what is what! unless of course I understood you correctly;)

How to connect sg card to android?: ...

Buy her

This article will show you how to format an SD card on Windows, Mac OS X, and Android. ... If your computer does not have a built-in SD card port, you can use an external USB reader.

It's sd and not sg, well, it doesn't matter which phone, the application transfer functions may be closed, or maybe you simply don't have a card in your phone

I'm trying to connect the tablet (Android 4.2) to the computer, it says: there was an error when connecting the SD card, what should I do?

Take out the SD card.

How to connect Android to computer. ... In addition to being able to work with all files that are on your device and SD card, DroidExplorer allows you to quickly remove unnecessary applications.

On the tablet (android) I can not connect the SD card. He does not "see" her

Settings - Memory, insert the card correctly and if there is nothing important on it, then I advise you to format it using the tablet, maybe that's why it doesn't see

Try to safely remove it, and after that do not immediately disconnect the USB cable, but wait until the Preparing SD card disappears. ... How to connect HTC to computer.

How to get into the sd card in android without any programs?

In older versions of Android, the function of installing programs on a memory card was absent. ... 2. Go to the Applications section. 3. Move to the SD card tab.

If there is no built-in conductor. then nothing

Connect to your computer as a flash drive

If there is no folder: my files then install the file manager

If f. the manager does not open the card, then download the normal f. men.
Android 2+ and 4+ are very different. You need to write what you have - a PDA, a tablet, etc.

Why won't SD card connect to android?

How to connect an android phone to a car radio via USB input? you need to read an external memory card.

If there is an input in the * YUSB * radio tape recorder, try to transfer your music to the flash drive. As it is possible the music in the phone is recorded in a different format of the built-in memory .. or, more simply, through the FM transmitter, the transmitter on the radio tape recorder switched on to the FM wave. this function is available in navigators. I don't know for your android

On SD card applications that we have already moved to the memory card. ... How to recover deleted files on Android. How to connect a USB flash drive to a tablet.

Why android FLY 238 writes: PC will not see SD card when connected via USB cable?

Install the appropriate drivers on your PC

Android Installing applications on the built-in flash drive with an SD connected. ... Since this volume is quite enough, I did not buy an SD card. Everything was fine until I needed to connect an SD to share files.

People, the android stopped seeing the sd card when connected to a computer, only the internal built-in memory is visible!

Try reformatting the card to FAT32.

Android Setting up Android Replacing the internal memory with an external SD card on Android tablets. ... How to get ROOT on Android. How to connect an Android device as a storage device.

How to install a ringtone on android 4.0.4 so that it does not fly off after connecting the SD card to the computer?

Transfer the ringtone to the internal memory via the root explorer (Or something like that), and put the ringtone from the internal memory.

Setting - memory - connect an SD card although it should be mounted automatically In the same. ... Since Android 2.2, the installation of applications on the SD card is included in the standard functions.

Internal sd card on android is disabled. What to do? (how to enable it) If it does not show the on sd card

Because the android is not friends with the flash drive, so go to the settings and then to the memory and there will be an external flash drive on it, press it and it will say disable or enable, etc.

By connecting an android to a computer using the standard method, you definitely lose the ability to work with files on an SD card ... Below we give just a few examples of connecting android to a computer using third-party applications

For don’t figs use the flash drive here and there, otherwise the oga starts to lag like this

How to remove applications from SD (Android) if the card is connected to a computer?

Acronis disk director 11

The card icon and notification sd-card can be removed and just below in gray letters you can safely remove the sd-card or when you click in the settings-memory-connect the SD-card. Android version 4.2.9 and ...

It is better to remove installed applications from the device, otherwise tails remain in any case

Is it possible somehow to throw a cache of games on a phone (Android) without an SD card

So, if you just connect the phone to the computer - in theory, the internal flash drive will be visible, and throw the cache there

My SD card does not connect to my android flash drive How can I connect it? It is inserted into the phone. ... settings-memory-connect SD card.

I do not have an SD card (flash drive) connected to my android How to connect it? It is inserted into the phone.

Check m. B. there the sewn on the side moved.

Starting from the version of the operating system Android 2.2 and higher, you have the opportunity to transfer applications to an SD memory card ... 2. Connect your phone via a USB cable to a computer, run MiniTool Partition Wizard 11 MB and ...

Extracted SD card on android. How to get it back?

Make wipe dates in recovery
P.S. All data will be deleted.

If you have a full-size SD card, for example, from a camera, you will not be able to connect it to the tablet. And in Apple devices there is no memory card slot at all. On tablets with Android and Windows, the microSD card slot is located on one of the sides, and ...

When downloading the game, an SD card is required ... the game will delete the phone memory?

How to distinguish a Chinese iPhone from an original one? M?

Chinese will break very quickly!

Doesn't see Sd card on android. I am glad to welcome you, dear users of the site! ... The first and most common reason that the sd card does not work may be that it burned out.

Price primarily, build quality, functionality, types and updates of software and other gadgets

Installation of programs on the internal memory of the tablet is carried out by default. To put the application on the built-in memory card, you just need to perform the standard installation. It will take a little longer to send it to external media. One simple setup session will clean up the device's file system, installing each new application to the SD card.

Option 1: specifying the installation address

During installation, some programs ask the user where they will be accommodated. It is not difficult to indicate the address of the installation. Choose a removable memory card, and you're done. But this applies only to some applications, such a minority.

Option 2: set the installation path in advance

The application must support the app2sd patch if the Android OS version on the tablet is earlier than 2.2. There will be no such items in the settings. For all new versions, such an algorithm for solving the problem is suitable.

Go to "Settings", find the item "Memory". Click on it and the memory settings menu will open. Here you can also find out about the amount of free memory on your device, how much space on the tablet in general, how much internal memory is occupied. Some people insert an SD card into a card reader, and find out the data about the flash drive on the computer, not knowing that it can be done on the tablet.

Find the "Default Burn Disc" section, which offers several sources for installing applications. Choose "SD card" from among them. Click on this item, and you will see a circle opposite it. Now the installation of applications to the memory card on the tablet occurs by default.

Option 3: Using third-party programs

Most likely this method will help you. But he demands. You can find out whether or not there is a root right on the tablet by. We download special applications, like FolderMount or GL to SD, which will help you transfer game and program data to an SD memory card. See video instructions below:

Option 3

Install a program on your tablet PC that will provide an option to select the installation address. Before the direct installation of the application, a dialog box will appear in which you specify the installation address.

This is the most convenient option among those offered. Because a forced installation "by default" is not desirable in all cases. Utilities such as InstallManager, MagicUneracer will help organize an economical and efficient filling of the tablet's memory. By the way, these same programs also perform uninstallation of programs with all auxiliary files.

If the app is not installed on an SD card

Open the "Applications" item in "Settings". In the list of applications, select the one that you would like to transfer to the removable card. Click on the app icon and a menu will open. See if it has a "Transfer" option. If so, click on the option button and select a memory card. This procedure does not require the installation of additional software, you can do it yourself.

Almost every Android device now supports memory cards (microSD). However, sometimes there are problems associated with its detection in the device. There may be several reasons for the occurrence of such a problem, and certain manipulations are required to solve them. Next, we will look at methods of correcting such an error.

Before proceeding with the instructions below, we recommend that you do the following:

  • Reboot your device. Perhaps the problem that has arisen is an isolated case, and the next time you start the device, it will simply disappear and the flash drive will work correctly.
  • Reconnect. Sometimes the removable storage medium is not displayed because the contacts are loose or clogged. Pull it out and insert it back, then check if the detection is correct.
  • Maximum volume. Some mobile devices, especially old ones, support memory cards only of certain sizes. We advise you to familiarize yourself with this characteristic on the official website of the manufacturer or in the instructions in order to make sure that an SD card with that much memory functions normally with your device.
  • Check on other devices. It may well be that the flash drive is damaged or broken. Insert it into another smartphone or tablet, laptop or computer to make sure it works. If it is not readable on any equipment, you should replace it with a new one.

In addition to such detection problems, an error occurs notifying that the flash drive has been damaged. For a detailed guide on how to fix it, read our material at the link below.

If the previous tips have not yielded any results and the storage medium is still not detected by your smartphone or tablet, pay attention to the steps below. We've arranged them in order of difficulty so that you can implement each one in order without much effort.

Method 1: Delete cache data

The device collects temporary data every day. They not only take up physical space in memory, but can also cause various malfunctions in the operation of the device. First of all, we recommend erasing the cache through the menu Recovery... In it you should select the item "Wipe Cache Partition", wait for the procedure to complete and restart the phone.

Detailed instructions on how to switch to Recovery mode in the Android operating system and how else you can delete the cache can be found in the following articles.

Method 2: Check for memory card errors

As part of this method, follow a series of simple steps:


If scanning for errors did not help, then you need to take more drastic measures.

Method 3: Formatting the media

To complete this method, you will also need to connect your SD card to your computer or laptop using adapters or special adapters.

Please note that this procedure will erase all information from the removable media, therefore, before starting, we advise you to save important data in any other convenient place.

If you have any difficulties with formatting, we recommend that you read our other article at the link below. There you will find seven ways to solve this problem, and you can easily fix it.

Most often, deleting data from a card helps in cases where it has ceased to be detected after connecting to other equipment. You just need to follow the instructions above, then immediately insert the media into your smartphone or tablet and check its performance.

Method 4: create a clean volume

Sometimes, due to the fact that the card has a hidden section, its memory is not enough to save information from a smartphone. Among other things, this creates detection problems. To eliminate them, you need to connect the card to a PC and follow these steps:

  1. Through the menu "Start" go to "Control Panel".
  2. Select a category here "Administration".
  3. Among the list of all components, find and double-click on "Computer Management".
  4. In the window that opens, you should select "Disk Management".
  5. Here, check the number of the disk that is your flash drive, and also pay attention to the total amount of memory. Write down or remember this information as it will come in handy later.
  6. Key combination Win + R run the snap "Run"... Enter cmd in the line and click on "OK".
  7. In the window that opens, enter the command diskpart and click Enter.
  8. Grant permission to run the utility.
  9. You are now on to the disk partitioning program. She has identical Command line view. Here you need to enter list disk and click on again Enter.
  10. Check out the list of disks, find your USB flash drive there, then enter select disk 1, where 1 - the disc number of the required medium.
  11. All that remains is to clear all data and partitions. This procedure is performed using the clean command.
  12. Wait for the process to complete and you can close the window.

Now we have achieved that the SD-card is completely clean: all information, open and hidden sections have been removed from it. A new volume must be created in the phone for normal operation. This is done like this:

  1. Repeat the first four steps from the previous instructions to return to the Disk Management menu again.
  2. Select the required removable media, right-click on the mark with its memory and select "Create new volume".
  3. This will open the Simple Volume Creation Wizard. To start working with it, click on "Further".
  4. You do not need to specify the size of the volume, let it take up all the free space, so the flash drive will work better with a mobile device. So just go to the next step.
  5. Assign any free letter to the volume and press "Further".
  6. Formatting should be done if the default format is not FAT32... Then select this file system, leave the cluster size "Default" and move on.
  7. Upon completion of the procedure, you will be presented with information about the selected parameters. Check them out and quit.
  8. Now on the menu "Disk Management" you see a new volume that takes up all of the logical space on the memory card. This means that the process was completed successfully.

All that remains is to remove the USB flash drive from your PC or laptop and insert it into your mobile device.

We displayed a picture on the display from an sd card, but some points were missed in it, the first was the connection of the card itself, the second was only a part of the library's functions was considered Petit FatFs, let's dwell on these points in more detail.

Communication with the card is possible through one of two interfaces, SPI or SD.



I must say that the SD interface can work in one-bit and four-bit modes.

The SPI card connection diagram is standard and looks like this, the unused card pins need to be pulled up to the power supply using a 10K resistor.


But in amateur designs, pull-up resistors are often neglected, simplifying the wiring diagram.

It should be noted that when connected via SPI, the card is very demanding on the supply voltage and a small drop in the supply voltage leads to the inoperability of the card, this has been verified by personal experience, there is nothing to say about the SD interface, I have not tried it yet. I wrote all this to the fact that on the power supply, it is imperative to install capacitors... As for the choke, it must be rated for a current of up to 100mA, but it is not necessary to install it.

In the diagrams shown above, it can be seen that the card needs 3.3 volts for operation, respectively, the voltage in the data transmission lines should not go beyond the range of 0 - 3.3 volts, and then the question arises, what to do if the MK is powered by 5 volts?
The answer is simple, you need to match the data transmission lines, and this can be done using a conventional resistive divider.


The diagram shows that the MISO line does not need to be coordinated the way data is transmitted along this line. from card to MK.
In fact, few people connect the card directly to the MK, it is much more convenient to connect the connector for the card to the MK or buy a shield with a connector and all the necessary strapping.

With the connection figured out, let's now look at how to use the library Petit FatFs which is designed for 8-bit microcontrollers with small memory size.

The library consists of 5 files:
integer.h- a header file that describes the main data types.

diskio.h- a header file in which prototypes of low-level functions for working with a disk and the status codes that they return are declared.

diskio.c- low-level functions must be implemented in this file, initially there are "stubs" there.

pffсonf.h- configuration file.

pff.h- a header file in which prototypes of functions for interacting with the disk file system are declared.

pff.c- the file contains implementations of functions for interacting with the disk file system.

It can be seen that in order for the library to work, it is necessary to implement low-level functions. But if we are talking about AVR or PIC, for them the site can download an example of working with the library, in which there is a file mmc, it already implements low-level functions. It is also necessary to set the library configuration in the pff.h file and write the functions necessary for the SPI to work.

Petit FatFs functions.

FRESULT pf_mount (FATFS *)- the function mounts / unmounts the disk. This function must be called before starting to work with the disk, if you call the function with a null pointer, the disk is unmounted. The function can be called at any time.

Parameters
FATFS * fs- a pointer to an object of FATFS type, a description of this structure can be found in the pff.h file. We just need to declare a variable of this type.

Return values:
FR_OK (0)
FR_NOT_READY- the device cannot be initialized
FR_DISK_ERR- an error occurred while reading from the disk
FR_NO_FILESYSTEM- the disk does not have the correct FAT partition

FATFS fs; // declare an object of FATFS type // mount the disk if (pf_mount (& fs) == FR_OK) (// the disk is mounted, we work with it // unmount the disk pf_mount (NULL);) else (// failed to mount the disk )

FRESULT pf_open (const char * path)- the function opens an existing file. After the file is open, you can work with it, that is, read from it and write to it. You can work with an open file until another file is opened. The function can be called at any time.

Parameters
const char * path- pointer to a string indicating the path to the file. The path must be specified completely relative to the root directory, separating directories with a slash.

Return values:
FR_OK (0)- is returned if the function is completed successfully
FR_NO_FILE- File not found
FR_DISK_ERR- disk error
FR_NOT_ENABLED- the disk was not mounted

FATFS fs; // declare an object of FATFS type // mount the disk if (pf_mount (& fs) == FR_OK) (// open the file in the root directory if (pf_open ("hello.txt") == FR_OK) (// do something) // open the file in the new folder if (pf_open ("new / hello.txt") == FR_OK) (// do something) // dismantle the disk pf_mount (NULL);) else (// failed to mount disk)

FRESULT pf_read (void * buff, WORD btr, WORD * br)- the function reads the specified number of bytes from the file and saves them to the buffer. If the number of bytes read is less than specified, then the end of file has been reached.
#define _USE_READ 1

Parameters:
void * buff- pointer to the buffer in which the read data is stored
WORD btr- the number of bytes to read
WORD * br- a pointer to a variable that stores the number of bytes read.

Return values:
FR_OK (0)- is returned if the function is completed successfully
FR_DISK_ERR- disk error
FR_NOT_OPENED- the file was not opened
FR_NOT_ENABLED- the disk was not mounted

FATFS fs; // declare an object of type FATFS BYTE buff; // buffer for reading the file WORD br; // counter of bytes read // mount the disk if (pf_mount (& fs) == FR_OK) (// open the file in the root directory if (pf_open ("hello.txt") == FR_OK) (// read 10 bytes from it pf_read (buff, 10, & br); if (br! = 10) (// if br is not equal to 10 // then we have reached the end of the file)))

FRESULT pf_write (const void * buff, WORD btw, WORD * bw)- the function allows you to write data to an open file. In order for the function to work in the pffconf.h file, write
#define _USE_WRITE 1

Parameters:
void * buff- a pointer to the buffer that we want to write, a zero value finalizes the write
WORD btw- the number of bytes that we want to write
WORD * bw- a pointer to a variable storing the number of bytes that could be written. By analyzing this variable, you can find out whether the end of the file has been reached.

Return values:
FR_OK (0)- is returned if the function is completed successfully
FR_DISK_ERR- disk error
FR_NOT_OPENED- the file was not opened
FR_NOT_ENABLED- the disk was not mounted

Due to the fact that the library is designed for microcontrollers with a small memory size, this function has a number of limitations:

  • you cannot create new files, and you can write only to existing ones
  • file size cannot be increased
  • the timestamp cannot be updated
  • write operation can be started / stopped only at the sector boundary
  • a read-only file attribute cannot deny writing

In order to understand the penultimate point, you need to know that the memory of the card is divided into blocks (sectors) of 512 bytes and recording can only be started from the beginning of a sector... Thus, if we want to write 1000 bytes, then the first sector will be written completely, and only 488 bytes will be written to the second, and the remaining 24 bytes will be filled with zeros.

To write to an open file, do the following:

  • set the pointer to the sector border, if set not to the border, then the pointer will be rounded to the lower sector border
  • call the write function the required number of times
  • finalize the entry by calling a function with a null pointer

In order to give an example of how the recording function works, one more function needs to be considered.

FRESULT pf_lseek (DWORD offset)- sets a read / write pointer in an open file. You can set the pointer as an absolute or relative offset; for an absolute offset, you need to pass a number to the function
pf_lseek (5000);
for relative, pass the value of the pointer to the current position fs.fptr and the displacement value
pf_lseek (fs.fptr + 3000);
In order for the function to work in the pffconf.h file, write
#define _USE_LSEEK 1

Parameters:
DWORD offset- the number of bytes by which the pointer should be shifted.

Return values:
FR_OK (0)- is returned if the function is completed successfully
FR_DISK_ERR- disk error
FR_NOT_OPENED- the file was not opened

You can write data to a file as follows.
FATFS fs; // declare an object of type FATFS BYTE buff; // buffer for reading the file WORD br; // counter of bytes read // mount the disk if (pf_mount (& fs) == FR_OK) (// open the file in the root directory if (pf_open ("hello.txt") == FR_OK) (// set the pointer to the first sector pf_lseek (0); // write pf_write (buff, 10, & br); // finalize the write pf_write (0, 0, & br);))

I also leave here a piece of really working code that uses all the above functions.
#define F_CPU 8000000UL #define buff_size 10 #include #include #include "diskio.h" #include "pff.h" #include "spi.h" FATFS fs; // declare an object of type FATFS BYTE read_buff; // buffer for reading the file BYTE write_buff = "hello word"; /// / buffer for writing to file UINT br; // counter of bytes read int main (void) (// mount the disk if (pf_mount (& fs) == FR_OK) (// open the file in the new folder if (pf_open ("new / hello.txt") == FR_OK) (// set the write pointer pf_lseek (0); // write pf_write (write_buff, buff_size, & br); // finalize the write pf_write (0, 0, & br); // set the read pointer pf_lseek (0); // read that what we wrote pf_read (read_buff, buff_size, & br); if (br! = buff_size) (// if br is not equal to buff_size // then we have reached the end of the file)) // dismount the disk pf_mount (NULL);) while (1) ())

FRESULT pf_opendir (DIR * dp, const char * path)- the function opens an existing directory and creates a pointer to an object of the DIR type, which will be used to get a list of files in the open directory.
In order for the function to work in the pffconf.h file, write
#define _USE_DIR 1

Parameters:
DIR * dp- a pointer to a variable of the DIR type.

const char * path- pointer to a string that contains the path to the directory, directories are separated by a slash

Return values:
FR_OK (0)- is returned if the function is completed successfully
FR_NO_PATH- could not find a path
FR_NOT_READY- failed to initialize disk
FR_DISK_ERR- disk error
FR_NOT_ENABLED- the disk was not mounted

// declare FATFS variables fs; DIR dir; // mount the disk pf_mount (& fs); // open the directory pf_opendir (& dir, "MY_FOLDER");

FRESULT pf_readdir (DIR * dp, FILINFO * fno)- the function allows you to read the contents of a directory. To do this, open the directory with the pf_opendir () function and call pf_readdir (). Each time it is called, the function will return the name of the object (folder / file) located in the specified directory. When it loops through all the objects, it returns the null string in the fno.fname array element.
In order for the function to work in the pffconf.h file, write
#define _USE_DIR 1

Parameters:
DIR * dp- a pointer to a variable of the DIR type, which must be previously declared

FILINFO * fno- a pointer to a variable of the FILINFO type, which must be previously declared.

Return values:
FR_OK- successful completion of the function
FR_DISK_ERR- disk error
FR_NOT_OPENED- directory is not open

FATFS fs; FRESULT res; FILINFO fno; DIR dir; // mount the disk pf_mount (& fs); // open the directory res = pf_opendir (& dir, MY_FOLDER); // read the contents of the directory for (;;) (res = pf_readdir (& dir, & fno); // check if there were any errors while reading // and if there are more files in the specified directory if ((res! = FR_OK) || ( fno.fname == 0)) (break;) // display in a convenient way fno.fname usart_sendStr (fno.name); usart_sendStr (/ r);)

Well, in the end, I'll leave a working draft here.

Top related articles