FAT32 library for MMC/SD cards
Re: FAT32 library for MMC/SD cards
When the Hardware stuck the message "Logando" is displayed in the display
so the problem occurs after status=FAT32_Exists(posi.nomearquivo);
and before FAT32_Close(fhandle);
I am sending the complete code.
Best regards.
Edmundo
so the problem occurs after status=FAT32_Exists(posi.nomearquivo);
and before FAT32_Close(fhandle);
I am sending the complete code.
Best regards.
Edmundo
- Attachments
-
- Logger.rar
- (27.42 KiB) Downloaded 604 times
Re: FAT32 library for MMC/SD cards
Are you sure the card is formatted for 1024 bytes per sector? If so, are you sure the Fat32 library can handle this well? Normally cards have 512 bytes per sector, and that is also the spec in the mmc library.ebeinecke wrote:My buffer size is 1024 (FAT32 formatted in 1024 bytes per sector) ...
Of course your own buffer can be bigger (I assume, the documentation is not very detailed regarding this type of issues).
Extra questions/comments:
A.
I do see also some alarming code parts in the (commented out, I know, but still...) code:
Code: Select all
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Logando");
d=0;
status=FAT32_Exists(posi.nomearquivo);
if (status==0) { //se o arquivo nao existe grava coodernadas
strcat(buf,posi.lat1);
strcat(buf,posi.lon1);
strcat(buf,posi.date1);
strcat(buf,posi.hora1);
/*//fhandle = FAT32_Open(posi.nomearquivo, FILE_WRITE);
//FAT32_Write(fhandle, posi.lat1, 16);
FAT32_Dev_Write_Sector(swapStartSc+d, posi.lat1); <---------------------------
//FAT32_Write(fhandle, posi.lon1, 17);
d++;
FAT32_Dev_Write_Sector(swapStartSc+d, posi.lon1); <----------------------------
d++;
B. Where is the implementation of FAT32_Dev_Write_Sector and FAT32_Dev_Read_Sector? Are they in the standard "Fat32_Driver" unit?
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Re: FAT32 library for MMC/SD cards
Hi,
The possibility exists now to use the Fat32 library of mE together with the USB MSD host library (see http://www.mikroe.com/forum/viewtopic.p ... 50#p197339), making it possible to access files on a USB memory stick:
Adapted the hardware driver for the Fat32 library of MikroElektronika to be able to handle the USB stick software, see http://www.rosseeld.be/DRO/PIC/__Lib_FAT32_Driver.mpas.
The possibility exists now to use the Fat32 library of mE together with the USB MSD host library (see http://www.mikroe.com/forum/viewtopic.p ... 50#p197339), making it possible to access files on a USB memory stick:
Adapted the hardware driver for the Fat32 library of MikroElektronika to be able to handle the USB stick software, see http://www.rosseeld.be/DRO/PIC/__Lib_FAT32_Driver.mpas.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Re: FAT32 library for MMC/SD cards
Excellent! There have been many requests for FAT on a stick.
If you know what you're doing, you're not learning anything.
-
- Posts: 38
- Joined: 31 May 2012 07:05
Re: FAT32 library for MMC/SD cards
Hi.
When "long file names" will be supported? Any idea about it?
I tried Dany's FAT32_1 library, but it doesn't support dsPIC33 series.
I am working on mikroMMB for dsPIC and it has dsPIC33FJ256GP710A microcontroller. I am using mikroBasic.
When "long file names" will be supported? Any idea about it?
I tried Dany's FAT32_1 library, but it doesn't support dsPIC33 series.
I am working on mikroMMB for dsPIC and it has dsPIC33FJ256GP710A microcontroller. I am using mikroBasic.
Re: FAT32 library for MMC/SD cards
Hi, I see that a lot of libraries can be used by both PIC24 and PIC30/33, see e.g. the Fat32 library as example (http://www.libstock.com/projects/view/108/fat32-library). Perhaps you can try switch on the P33 Pic's in the package manager for the Fat32_1 and/or Fat32_2 libraries and try to install and use them?serkansatuk wrote:Hi.
When "long file names" will be supported? Any idea about it?
I tried Dany's FAT32_1 library, but it doesn't support dsPIC33 series.
I am working on mikroMMB for dsPIC and it has dsPIC33FJ256GP710A microcontroller. I am using mikroBasic.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
-
- Posts: 38
- Joined: 31 May 2012 07:05
Re: FAT32 library for MMC/SD cards
Hi Dany.Dany wrote: Hi, I see that a lot of libraries can be used by both PIC24 and PIC30/33, see e.g. the Fat32 library as example (http://www.libstock.com/projects/view/108/fat32-library). Perhaps you can try switch on the P33 Pic's in the package manager for the Fat32_1 and/or Fat32_2 libraries and try to install and use them?
I tried your library. I'm using mikroBasic.
I added "FAT32_1.mcl" and "StrngUtils.mcl" inside project files.
I wrote the following code before main program.
Code: Select all
sub function FAT32_Dev_Read_Sector(dim sc as longword, dim buf as ^byte) as short
if (Mmc_Read_Sector(sc, buf) <> 0) then
result = -1
else
result = 0
end if
end sub
sub function FAT32_Dev_Write_Sector(dim sc as longword, dim buf as ^byte) as short
if (Mmc_Write_Sector(sc, buf) <> 0) then
result = -1
else
result = 0
end if
end sub
I wrote "Fat32_Init()" in main. when i compile project it gave me an error like this.
"0 360 Unresolved extern 'Mul_16x16_U' Fat32_1.mpas"
"0 360 Unresolved extern 'Mul_32x32_U' Fat32_1.mpas"
Re: FAT32 library for MMC/SD cards
1. the FAT32_Dev_Read_Sector and FAT32_Dev_Write_Sector should return boolean values (true=255, false = 0)serkansatuk wrote:Hi Dany.Dany wrote: Hi, I see that a lot of libraries can be used by both PIC24 and PIC30/33, see e.g. the Fat32 library as example (http://www.libstock.com/projects/view/108/fat32-library). Perhaps you can try switch on the P33 Pic's in the package manager for the Fat32_1 and/or Fat32_2 libraries and try to install and use them?
I tried your library. I'm using mikroBasic.
I added "FAT32_1.mcl" and "StrngUtils.mcl" inside project files.
I wrote the following code before main program.Code: Select all
sub function FAT32_Dev_Read_Sector(dim sc as longword, dim buf as ^byte) as short if (Mmc_Read_Sector(sc, buf) <> 0) then result = -1 else result = 0 end if end sub sub function FAT32_Dev_Write_Sector(dim sc as longword, dim buf as ^byte) as short if (Mmc_Write_Sector(sc, buf) <> 0) then result = -1 else result = 0 end if end sub
I wrote "Fat32_Init()" in main. when i compile project it gave me an error like this.
"0 360 Unresolved extern 'Mul_16x16_U' Fat32_1.mpas"
"0 360 Unresolved extern 'Mul_32x32_U' Fat32_1.mpas"
2. I will have a look into the unresolved errors.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Re: FAT32 library for MMC/SD cards
Hi,
About the unresolved externals:
To be sure the 2 .mcl files attached.
About the unresolved externals:
The routines 'Mul_16x16_U' and 'Mul_32x32_U' are P18 routines, not P24 dsPic30/33 routines. Are you sure you have the correct Fat32_1.mcl file (the one for mB for PIC24)?I wrote "Fat32_Init()" in main. when i compile project it gave me an error like this.
"0 360 Unresolved extern 'Mul_16x16_U' Fat32_1.mpas"
"0 360 Unresolved extern 'Mul_32x32_U' Fat32_1.mpas"
To be sure the 2 .mcl files attached.
- Attachments
-
- Fat32.zip
- (158.7 KiB) Downloaded 389 times
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
-
- Posts: 38
- Joined: 31 May 2012 07:05
Re: FAT32 library for MMC/SD cards
thanks for your interest.Dany wrote:Hi,
About the unresolved externals:The routines 'Mul_16x16_U' and 'Mul_32x32_U' are P18 routines, not P24 dsPic30/33 routines. Are you sure you have the correct Fat32_1.mcl file (the one for mB for PIC24)?I wrote "Fat32_Init()" in main. when i compile project it gave me an error like this.
"0 360 Unresolved extern 'Mul_16x16_U' Fat32_1.mpas"
"0 360 Unresolved extern 'Mul_32x32_U' Fat32_1.mpas"
To be sure the 2 .mcl files attached.
I will try again and write the results.
-
- Posts: 38
- Joined: 31 May 2012 07:05
Re: FAT32 library for MMC/SD cards
Hi Dany.
I created a new project with dsPIC33FJ256GP710A with your files attached to previous message.
the program has failed in two projects.
I created a new project with dsPIC33FJ256GP710A with your files attached to previous message.
the program has failed in two projects.
Code: Select all
program MyProject
dim Mmc_Chip_Select as sbit at LATG9_bit
dim Mmc_Chip_Select_Direction as sbit at TRISG9_bit
dim Mmc_Card_Detect as sbit at LATB14_bit ' for detecting microSD card presence
dim Mmc_Card_Detect_Direction as sbit at TRISB14_bit
sub function FAT32_Dev_Read_Sector(dim _Sector as longword, dim byref Buffer as byte[512]) as boolean
if (Mmc_Read_Sector(_Sector, Buffer) <> 0) then
result = true
else
result = false
end if
end sub
sub function FAT32_Dev_Write_Sector(dim _Sector as longword, dim byref Buffer as byte[512]) as boolean
if (Mmc_Write_Sector(_Sector, Buffer) <> 0) then
result = true
else
result = false
end if
end sub
main:
' Main program
Fat32_Init()
end.
Code: Select all
program MyProject
dim Mmc_Chip_Select as sbit at LATG9_bit
dim Mmc_Chip_Select_Direction as sbit at TRISG9_bit
dim Mmc_Card_Detect as sbit at LATB14_bit ' for detecting microSD card presence
dim Mmc_Card_Detect_Direction as sbit at TRISB14_bit
dim DirItem as TFileVar
sub function FAT32_Dev_Read_Sector(dim _Sector as longword, dim byref Buffer as byte[512]) as boolean
if (Mmc_Read_Sector(_Sector, Buffer) <> 0) then
result = true
else
result = false
end if
end sub
sub function FAT32_Dev_Write_Sector(dim _Sector as longword, dim byref Buffer as byte[512]) as boolean
if (Mmc_Write_Sector(_Sector, Buffer) <> 0) then
result = true
else
result = false
end if
end sub
main:
' Main program
Fat32_Init(DirItem)
end.
Re: FAT32 library for MMC/SD cards
Hi, I can reproduce the problems.
Unfortunately I have no solution for this, apparently the mB and mP compilers differ somehow in the generation/usage of .mcl files. I do not know why...
The "StrngUtils", "Fat32_1" and "Fat32_2" .mcl files are all generated with the mP v5.7.0 for PIC compiler and link together flawlessly using mP.
However, linking goes wrong with mB v5.7.0 for PIC compiler when using .mcl files generated with the mP v.5.7.0 for PIC compiler.
I have no idea why, perhaps mE should have a look to this issue.
I am very sorry that I gave you idle hope...
I think I will have to remove all my mB related packages in LibStock. I am not able to test them anyway...
Unfortunately I have no solution for this, apparently the mB and mP compilers differ somehow in the generation/usage of .mcl files. I do not know why...
The "StrngUtils", "Fat32_1" and "Fat32_2" .mcl files are all generated with the mP v5.7.0 for PIC compiler and link together flawlessly using mP.
However, linking goes wrong with mB v5.7.0 for PIC compiler when using .mcl files generated with the mP v.5.7.0 for PIC compiler.
I have no idea why, perhaps mE should have a look to this issue.
I am very sorry that I gave you idle hope...
I think I will have to remove all my mB related packages in LibStock. I am not able to test them anyway...
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Re: FAT32 library for MMC/SD cards
Maybe I shouldn't butt into this, since it's none of my business, but I would think that it would be smart for mE to supply all compilers for all languages and platforms to Dany, considering the enormous value of his contributions. Then he can test these variants.
If you know what you're doing, you're not learning anything.
Re: FAT32 library for MMC/SD cards
+1LGR wrote:Maybe I shouldn't butt into this, since it's none of my business, but I would think that it would be smart for mE to supply all compilers for all languages and platforms to Dany, considering the enormous value of his contributions. Then he can test these variants.
Serge T.
Learning is an endeless process but it must start somewhere!
Learning is an endeless process but it must start somewhere!