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
short FAT32_Dev_Read_Sector();
-
- Posts: 51
- Joined: 31 Dec 2012 21:54
short FAT32_Dev_Read_Sector();
Last edited by john.broderick on 07 Oct 2021 14:10, edited 1 time in total.
Re: short FAT32_Dev_Read_Sector();
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]
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]
-
- Posts: 51
- Joined: 31 Dec 2012 21:54
Re: short FAT32_Dev_Read_Sector();
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]
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]
Re: short FAT32_Dev_Read_Sector();
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.
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.
-
- Posts: 51
- Joined: 31 Dec 2012 21:54
Re: short FAT32_Dev_Read_Sector();
Sorry to confuse you radug.
Jump to bottom post of mine.
Jump to bottom post of mine.
Last edited by john.broderick on 07 Oct 2021 14:08, edited 1 time in total.
-
- Posts: 51
- Joined: 31 Dec 2012 21:54
Re: short FAT32_Dev_Read_Sector();
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.
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.
Re: short FAT32_Dev_Read_Sector();
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.
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.