short FAT32_Dev_Read_Sector();

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
john.broderick
Posts: 51
Joined: 31 Dec 2012 21:54

short FAT32_Dev_Read_Sector();

#1 Post by john.broderick » 01 Oct 2021 16:14

Hi again,

Hoping this is an easy question for some.

I am trying to use the FAT32 library for the first time.

Jump to my last post!

SDCARD = FAT32_Init(); returns a 0 which means it must be working.

I am trying to read the boot sector using FAT32_Dev_Read_Sector(0,dataBuffer[x]);
The system hangs if I add the [x] in a for loop.
i.e. It will not move past this function.

If I remove the [x] it moves forward but then my 512 byte buffer is all zeros.

Does anyone have any tips please?

I was really happy finding the FAT32 'read sector' now I just need it to work lol.

Pic32 MZ
16 Gig SD Card formatted with Win10 32k per cluster (Standard)

Thank you in advance,
John B
Last edited by john.broderick on 07 Oct 2021 14:10, edited 1 time in total.

radug
Posts: 117
Joined: 29 Mar 2012 10:21

Re: short FAT32_Dev_Read_Sector();

#2 Post by radug » 02 Oct 2021 07:57

Hi there,

I think you should try :

FAT32_Dev_Read_Sector(0, &dataBuffer[x]);

since the function is defined like this (buf is a pointer not a value):

short FAT32_Dev_Read_Sector(unsigned long s, char *buf);

PS dataBuffer is the pointer and is the same as &dataBuffer[0]

john.broderick
Posts: 51
Joined: 31 Dec 2012 21:54

Re: short FAT32_Dev_Read_Sector();

#3 Post by john.broderick » 04 Oct 2021 15:49

Thank you for your time radug.

I have tried it and all I get is the address of the databuffer.
If I look at 512 bytes at that address, I get the address 512 times or get the address + x 512 times.
The 512 bytes of the buffer are all zeros.

I believe the fat16 was similar except it worked fine.

"unsigned int Mmc_Read_Sector(unsigned long sector, char *dbuff);" //from the help file

i.e.

for (x=0; x<512; x++){
Mmc_Read_Sector(Boot_Sector,dataBuffer[x]); //Boot sector = 0
Write_Number(x,xpos,ypos,White);
} // etc etc it will give me 512 characters from boot sector.


The dbuff did not need to be a pointer and works fine as a char[512]

radug
Posts: 117
Joined: 29 Mar 2012 10:21

Re: short FAT32_Dev_Read_Sector();

#4 Post by radug » 04 Oct 2021 18:17

Sorry but I'm confused ...
In your example, is dataBuffer an array of 512 pointers to buffers of 512 chars each (512 x 512 bytes) ????
If yes, then it is correct (but you should also increment the sector number, I guess).

As far as I can understand from the documentation, Mmc_Read_Sector reads 512 bytes to the given address at a time.
The function reads one sector (512 bytes) from MMC card.

john.broderick
Posts: 51
Joined: 31 Dec 2012 21:54

Re: short FAT32_Dev_Read_Sector();

#5 Post by john.broderick » 05 Oct 2021 13:30

Sorry to confuse you radug.


Jump to bottom post of mine.
Last edited by john.broderick on 07 Oct 2021 14:08, edited 1 time in total.

john.broderick
Posts: 51
Joined: 31 Dec 2012 21:54

Re: short FAT32_Dev_Read_Sector();

#6 Post by john.broderick » 07 Oct 2021 14:08

OMG

Whilst testing my own initialisation on a 2Gig SD card today, 07/10/21, I thought I would try a 2Gig card formatted to FAT32 since the boot process is the same for small cards.
Of course it worked.

I then tried the FAT32_Dev_Read_Sector(0,dataBuffer); with zero init.
It worked.
So the so called FAT32 LIBRARY is a gimmick and only designed to work on small cards, not 16 or 32Gig.

One may as well stick to FAT16 if using small cards.

Very disillusioned.

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

Re: short FAT32_Dev_Read_Sector();

#7 Post by filip » 11 Oct 2021 09:09

Hi,

The FAT32 library works on various 2,4,8,16 or 32 GB cards, can you tell me if you have tried to change the cluster size when formatting it ?

Regards,
Filip.

Post Reply

Return to “mikroC PRO for PIC32 General”