FAT32_Dir() How to save results to a file or display on TFT

General discussion on mikroC PRO for ARM.
Post Reply
Author
Message
Brett_S
Posts: 16
Joined: 01 Jul 2012 05:50

FAT32_Dir() How to save results to a file or display on TFT

#1 Post by Brett_S » 01 Mar 2015 11:53

Hi,

I have an application where I wish to use the FAT32 Library. One of the tasks I wish to perform is display the directory contents on screen.

The FAT32 Library help file description says "Displays contents of the current directory via user-defined medium (i.e. UART module, a file on FAT32 file system). The function displays character by character".

Exactly how is the definition of the medium achieved? The FAT32_Dir() function only returns success or failure, so where does the directory list go?

The example provided with the FAT32 Library is simply
err = FAT32_Dir();
UART_Write(CR);

How does the data get into the UART buffer?

I am using mikroC PRO for ARM ver 4.5 and the EasyMX PRO v7 Development board.

Thanks for your assistance

Regards

Brett

User avatar
darko.minic
Posts: 747
Joined: 01 Dec 2014 11:10

Re: FAT32_Dir() How to save results to a file or display on

#2 Post by darko.minic » 02 Mar 2015 16:36

Hello,

I tried FAT32 example with my EasyMx Pro v7 with STM32F207, and I was able to read contents of directory via USART terminal.
If I understand correctly you didn't managed to successfully read contents of directory via USART terminal?

Regards,
Darko

Brett_S
Posts: 16
Joined: 01 Jul 2012 05:50

Re: FAT32_Dir() How to save results to a file or display on

#3 Post by Brett_S » 03 Mar 2015 07:37

Hi Darko,

Thank you for your reply.

I was able to get the example to work.

My problem is that I wish to place the data in a file on the FAT32 file system NOT send it to the USART.

The Help File installed with the FAT32 Library says that the FAT32_Dir() function can be configured to place the results of the function (directory contents) in a file on the FAT32 file system, however there is no explanation as to how this is achieved.

How do I define the medium to which the FAT32_Dir() function will display its results?
By what form of magic does the FAT32_Dir() function place the result in the USART buffer?

Thanks again

Brett

User avatar
darko.minic
Posts: 747
Joined: 01 Dec 2014 11:10

Re: FAT32_Dir() How to save results to a file or display on

#4 Post by darko.minic » 03 Mar 2015 10:11

Hi Brett,

I can recommend you to search our Libstock Website to see whether some user posted project which may help you.
There is plenty projects related to FAT32 library, please refer following link:
http://www.libstock.com/

Regards,
Darko

Brett_S
Posts: 16
Joined: 01 Jul 2012 05:50

Re: FAT32_Dir() How to save results to a file or display on

#5 Post by Brett_S » 04 Mar 2015 13:39

I'm sorry Darko, I don't find your response satisfactory.

I have asked a reasonable question with regard to the function of your product. The documentation on the FAT32_Dir function clearly states that it can be configures, however offers no explanation as to how. I would like to know how this is achieved.

To tell me to search libstock to see if "some user" has an example is highly unprofessional.

If you do not know how to answer my question please escalate my request to someone who does.

Brett

User avatar
darko.minic
Posts: 747
Joined: 01 Dec 2014 11:10

Re: FAT32_Dir() How to save results to a file or display on

#6 Post by darko.minic » 05 Mar 2015 13:28

Hi Brett,

I mentioned Libstock because you can there find examples which can help you to understand how FAT32_Dir() function works.

I wrote some simple example how to displays contents of the current directory with FAT32_Dir() via UART:

Code: Select all

UART1_Init(115200);
Delay_100ms();
  
UART1_Write_Text("Test");

SPI3_Init_Advanced(_SPI_FPCLK_DIV64, _SPI_MASTER | _SPI_8_BIT |
                       _SPI_CLK_IDLE_LOW | _SPI_FIRST_CLK_EDGE_TRANSITION |
                       _SPI_MSB_FIRST | _SPI_SS_DISABLE | _SPI_SSM_ENABLE | _SPI_SSI_1,
                       &_GPIO_MODULE_SPI3_PC10_11_12);
Delay_100ms();

while(FAT32_Init() != 0)
  ;
  
UART_Write_Text("Init OK");
UART_Write(CR);

FAT32_Dir();
UART_Write(CR);
If you want for example to displays contents of the current directory on TFT, you should adjust following lines of code in __Lib_FAT32_Driver_STM32.c:

Code: Select all

////////////////////////////////////////////////////////////////////////////////
//
//  Dev_PutChar() is used by FAT32_Dir function for printing the contents
//  of the current folder, which is done 1 character at the time.
//
//  User may change this function to reroute that on some other device,
//  GLCD, TFT, Flash, EEPROM, or Ethernet module, to name a few.
//
//  It must return Returns OK on success and ERROR on failure.
//
////////////////////////////////////////////////////////////////////////////////
int8 FAT32_Put_Char(char ch)
{
    UART_Write(ch);
    return OK;
}
Regards,
Darko

DennisMclean
Posts: 2
Joined: 12 Apr 2011 09:25

Re: FAT32_Dir() How to save results to a file or display on

#7 Post by DennisMclean » 19 Jun 2015 18:36

Brett_S: Did you get the FAT32_Dir to work on the TFT?
I can help you with a solution if you still needd one.
Dennis

Yousaf_Esolz
Posts: 4
Joined: 02 Jul 2019 08:23

Re: FAT32_Dir() How to save results to a file or display on

#8 Post by Yousaf_Esolz » 22 Aug 2019 11:22

Hi DennisMclean,
Can you tell me, how you used that FAT32_Dir() for displaying the directory contents.
I need all the directory contents to be displayed on UART5.
I tried

Code: Select all

UART5_Write(FAT32_Dir());
Also I tried

Code: Select all

FAT32_Dir();
UART5_Write(CR);
But nothing happened.
Will be waiting for the response.

Yousaf

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

Re: FAT32_Dir() How to save results to a file or display on

#9 Post by stefan.filipovic » 23 Aug 2019 11:20

Hi Yousaf,

You can try it in this way:

Code: Select all

UART_Set_Active(&UART5_Read, &UART5_Write, &UART5_Data_Ready, &UART5_Tx_Idle);
FAT32_Dir();
UART_Write(CR);
Kind regards,
Stefan Filipović

Richie
Posts: 50
Joined: 21 Feb 2010 19:41

Re: FAT32_Dir() How to save results to a file or display on

#10 Post by Richie » 24 Nov 2019 18:57

How do I read the directory and store it (as a text file) on the card ?

Thanks

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

Re: FAT32_Dir() How to save results to a file or display on

#11 Post by stefan.filipovic » 25 Nov 2019 16:56

Hi,

Please refer to Darko's post above.

Kind regards,
Stefan Filipović

Richie
Posts: 50
Joined: 21 Feb 2010 19:41

Re: FAT32_Dir() How to save results to a file or display on

#12 Post by Richie » 03 Dec 2019 16:45

filename = "TESTFILE.txt"
FAT32_Open(@filename, FILE_WRITE_F32)
FAT32_Dir()
FAT32_Put_Char(SD_data)
FAT32_Write(0, @SD_data, 1)
FAT32_Close(0)

The above does not work.

How do you test that the Dir command has finished ?

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

Re: FAT32_Dir() How to save results to a file or display on

#13 Post by stefan.filipovic » 04 Dec 2019 11:16

Hi Richie,

Have you adjusted the FAT32_Put_Char function in __Lib_FAT32_Driver_STM32.c file as Darko described?
How do you test that the Dir command has finished ?
It will return 0 when writing on the user-defined medium was successful.

Kind regards,
Stefan Filipović

ali abbasi
Posts: 1
Joined: 04 Oct 2017 21:26

Re: FAT32_Dir() How to save results to a file or display on TFT

#14 Post by ali abbasi » 30 Aug 2021 13:22

Hello everyone

How to display the directory of a microSD on a TFT LCD with FT810 module?

Kind regards,

Post Reply

Return to “mikroC PRO for ARM General”