First Steps at FAT32

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
Yves32
Posts: 49
Joined: 05 Aug 2013 15:53

First Steps at FAT32

#1 Post by Yves32 » 10 Jun 2018 20:09

Hello! I am first trying to get the MicroSD card initialized, and have something done.
I think FAT32_Dir() can return the directory structure. Is there a Help file for FAT32?
Calling this function just send the flow of the program to unknown destination, since the following
lines of codes are not executed.
I have made this minimal code to try getting started.
The only example I have is from LibStock Fat32. This example is too much over my head.
I would like first to show on the TFT screen data retrieved from the SD card about the directories.
Later, I will focus on reading files.
EasyPIC Fusion v7
PIC32MX460F512L
Basic for PIC32

program MicroSD_Project
dim Str_Value as String [30]
dim InitFat, TestVar, InitMmc,InitDir as word
dim Mmc_Chip_Select as sbit at LATB12_bit
Mmc_Chip_Select_Direction as sbit at TRISD12_bit
TFT_DataPort as char at LATE
TFT_RST as sbit at LATD7_bit
TFT_BLED as sbit at LATD2_bit
TFT_RS as sbit at LATD9_bit
TFT_CS as sbit at LATD10_bit
TFT_RD as sbit at LATD5_bit
TFT_WR as sbit at LATD4_bit
TFT_DataPort_Direction as char at TRISE
TFT_RST_Direction as sbit at TRISD7_bit
TFT_BLED_Direction as sbit at TRISD2_bit
TFT_RS_Direction as sbit at TRISD9_bit
TFT_CS_Direction as sbit at TRISD10_bit
TFT_RD_Direction as sbit at TRISD5_bit
TFT_WR_Direction as sbit at TRISD4_bit
sub procedure Show_Var_Word(dim byref VarName as String[30],dim byref Var_Value as word,dim Write_Line as byte)
WordToStr(Var_Value,Str_Value)
TFT_Write_Text(VarName,30,Write_Line*15)
TFT_Write_Text(Str_Value,200,Write_Line*15)
end sub
main:
AD1PCFG = 0xFFFF ' Configure AN pins as digital I/O
JTAGEN_bit = 0 ' Disable JTAG TFT_BLED_Direction = 0
TFT_Init_ILI9341_8bit(320, 240) 'Initialized the TFT display
TFT_Fill_Screen(CL_YELLOW) 'Erase screen
'Initialize SPI
SPI2_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 128,_SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE)
InitMmc=Mmc_Init()
Show_Var_Word("Mmc Init Return",InitMmc,3) 'Displays 0 if init succeed at line 3
InitFat=FAT32_Init()
Show_Var_Word("FAT32 Init Return",InitFat,4) 'Displays 0 if init succeed at line 4
'
'I need to find how to fetch data from Init_Dir() : ???????????
'InitDir=FAT32_Dir() '----> does not work
'Show_Var_Word("FAT32 Init Return",InitDir,5) ' "should" display result at line 5
End.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: First Steps at FAT32

#2 Post by filip » 15 Jun 2018 08:50

Hi,

Yes, there is a Help for the FAT32 library, it is located in the FAT32 library installation folder.
You can see in the example how the FAT32_Dir is used, it should not be difficult.

Regards,
Filip.

Yves32
Posts: 49
Joined: 05 Aug 2013 15:53

Re: First Steps at FAT32

#3 Post by Yves32 » 17 Jun 2018 19:45

Many Thanks, Filip
I went again into the FAT32 library package. All I can find is "Fat32_Dir()". I may not be at the right place.
It is what is provided with the library: a list of function.
Well, I went again examining the example again and again. At compilation I have tons of "not declared" and "unresolved" etc... In this example, there is more to learn about UART. The programming style is most professional what means that I don't understand much.
So, let not be discouraged.
I have quite specific requirements. I made my own FAT using Only few functions, after initialization:
Mmc_Read and Mmc Write. I make my files (with a PC and PureBasic) onto the uSD. All the same format and size. (I have thousands of them)
I use a marker (6 bytes) just at the beginning of my waves. Then folllows my own ID system.
A first program scans the uSD to find such markers. They are all at the beginning of a sector.
My file have a standard format (all have 2240 sectors, I don't use the file names).
I use a first program to make the allocation file which is written on the same uSD.
All works well.
The second program uses the files and this simple FAT.
I hope all I use will be still working well with PIC32Z ( I need speed)
I will be using timer interrupts for sequential reading at a fixed rate.
I don't know if the communication (SPI) will be faster with the is new MCU.
I post this because there must be many ME users who like to learn as little as possible then do much with it! Of course this FAT system is not general and versatile but it is all I need.
I welcome users of ME who are fans of programming but with modest capabilities for power coding.
Again thanks.

Post Reply

Return to “mikroBasic PRO for PIC32 General”