FAT 16 Not Working
Moderator: Benj
FAT 16 Not Working
Hello,
I am using flowcode v4 for AVR to program. I'm using an atmega328p for the chip. What I have been trying to do is interface a FAT 16 formatted sd card with my avr. So far have have had no luck. The sd card seems to be setup correctly because I tried it with an arduino and it seems to recognize it. All my flowcode program does is try to initiate the FAT 16 card with the FAT component. It then turns an led on if it has initiated properly. So far it is not initiating. Any ideas on what is causing this to not work?
Also there are a couple warnings I'm getting from flowcode:
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c: In function 'FCD_FAT160_Create_File':
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:503: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:504: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:505: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:506: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:511: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:512: warning: large integer implicitly truncated to unsigned type
Thanks!!!
I am using flowcode v4 for AVR to program. I'm using an atmega328p for the chip. What I have been trying to do is interface a FAT 16 formatted sd card with my avr. So far have have had no luck. The sd card seems to be setup correctly because I tried it with an arduino and it seems to recognize it. All my flowcode program does is try to initiate the FAT 16 card with the FAT component. It then turns an led on if it has initiated properly. So far it is not initiating. Any ideas on what is causing this to not work?
Also there are a couple warnings I'm getting from flowcode:
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c: In function 'FCD_FAT160_Create_File':
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:503: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:504: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:505: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:506: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:511: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:512: warning: large integer implicitly truncated to unsigned type
Thanks!!!
- DavidA
- Matrix Staff
- Posts: 1076
- Joined: Fri Apr 23, 2010 2:18 pm
- Location: Matrix Multimedia Ltd
- Has thanked: 58 times
- Been thanked: 258 times
- Contact:
Re: FAT 16 Not Working
Hello,
I dont know if you are using the latest Fat component as lots of fixes went into an updated component which is available here:
http://www.matrixmultimedia.com/mmforum ... =29&t=7461
Scroll down for the PIC and AVR versions of the component.
I dont know if you are using the latest Fat component as lots of fixes went into an updated component which is available here:
http://www.matrixmultimedia.com/mmforum ... =29&t=7461
Scroll down for the PIC and AVR versions of the component.
Re: FAT 16 Not Working
I updated the Fat component, but now it's not compiling because of some errors:DavidA wrote:Hello,
I dont know if you are using the latest Fat component as lots of fixes went into an updated component which is available here:
http://www.matrixmultimedia.com/mmforum ... =29&t=7461
Scroll down for the PIC and AVR versions of the component.
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c: In function 'FCD_FAT160_Create_File':
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:509: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:510: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:511: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:512: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:517: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:518: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c: In function 'FCD_FAT160_MX_Init_Card':
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:845: error: expected ')' before ';' token
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c
Error returned from [avr-gcc.exe]
Return code = 1
Flowcode was unable to compile the flowchart's C code due to the following errors:
If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.
FINISHED
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: FAT 16 Not Working
Hello,
I have just tried compiling the FAT component C file from my installation and this is working correctly.
Let me know how you get on.
I have just tried compiling the FAT component C file from my installation and this is working correctly.
Let me know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: FAT 16 Not Working
Hi,Benj wrote:Hello,
I have just tried compiling the FAT component C file from my installation and this is working correctly.
Let me know how you get on.
Still getting those weird errors:
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c: In function 'FCD_FAT160_Create_File':
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:663: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:664: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:665: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:666: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:671: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c:672: warning: large integer implicitly truncated to unsigned type
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c: In function 'FCD_FAT160_MX_Init_Card':
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c
Error returned from [avr-gcc.exe]
Return code = 1
Flowcode was unable to compile the flowchart's C code due to the following errors:
If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.
FINISHED
Re: FAT 16 Not Working
Sure! I also attached the compiled C code if that helps any.DavidA wrote:Hello,
Would it be possible for you to post your fcf file here
- Attachments
-
- SD Project.c
- (51.17 KiB) Downloaded 273 times
-
- SD Project.fcf_avr
- (4 KiB) Downloaded 281 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: FAT 16 Not Working
Hello,
Thanks for posting the files.
Here is a updated component c file that should allow the compilation to work correctly.
Thanks for posting the files.
Here is a updated component c file that should allow the compilation to work correctly.
- Attachments
-
- AVR_FAT16.c
- (51.99 KiB) Downloaded 275 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: FAT 16 Not Working
Benj wrote:Hello,
Thanks for posting the files.
Here is a updated component c file that should allow the compilation to work correctly.
That worked! I saw that there was some code in the component c code file that was for FAT32. Does that mean that this component is capable of connecting to a card formatted to FAT32?
Thank you very much!
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: FAT 16 Not Working
Hello,
Yes FAT32 should be supported in this C file.
To use it you need to find this line in the C file or use component customisation on the defines section and find the line.
Change the number to suit the file system you require.
eg
Will auto detect the file system on the card but will take up a bit more memory on the microcontroller.
Yes FAT32 should be supported in this C file.
To use it you need to find this line in the C file or use component customisation on the defines section and find the line.
Code: Select all
#define MX_FAT_TYPE 0//%l //0-FAT16(FAT) / 1-FAT32 / 2-FAT16&32eg
Code: Select all
#define MX_FAT_TYPE 2//%l //0-FAT16(FAT) / 1-FAT32 / 2-FAT16&32Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: FAT 16 Not Working
Hello again,Benj wrote:Hello,
Yes FAT32 should be supported in this C file.
To use it you need to find this line in the C file or use component customisation on the defines section and find the line.
Change the number to suit the file system you require.Code: Select all
#define MX_FAT_TYPE 0//%l //0-FAT16(FAT) / 1-FAT32 / 2-FAT16&32
egWill auto detect the file system on the card but will take up a bit more memory on the microcontroller.Code: Select all
#define MX_FAT_TYPE 2//%l //0-FAT16(FAT) / 1-FAT32 / 2-FAT16&32
I tried your new FAT16 component you gave me and it compiles just fine. But, for some reason when I run the Init_FAT it always returns a 255. Any idea what that means?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: FAT 16 Not Working
Hello,
Here is a list of the error codes from the component help file.
Return Codes
0xFF - No Card Error
0xFE - No Response Error
0xFD - No Ack Error
0xFC - Timeout Error
0xFB - Reserved Error
0xFA - Bad Sector Error
0xEF - File Not Found Error
0xEE - Root Full Error
0xED - Sector Bytes Error
0x03 - File Empty
0x02 - File Type
0x01 - End Of File
0x00 - Ok
255 is 0xFF so no card detected.
Are you sure you have the hardware connected up correctly. Are you using E-blocks or your own hardware?
Here is a list of the error codes from the component help file.
Return Codes
0xFF - No Card Error
0xFE - No Response Error
0xFD - No Ack Error
0xFC - Timeout Error
0xFB - Reserved Error
0xFA - Bad Sector Error
0xEF - File Not Found Error
0xEE - Root Full Error
0xED - Sector Bytes Error
0x03 - File Empty
0x02 - File Type
0x01 - End Of File
0x00 - Ok
255 is 0xFF so no card detected.
Are you sure you have the hardware connected up correctly. Are you using E-blocks or your own hardware?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: FAT 16 Not Working
That's odd. I'm pretty sure the hardware is setup correctly. I tested the SD card setup with my arduino and it seems to recognize it. Yes, I am using my own hardware. I also tested another card, same problem--returns 255.Benj wrote:Hello,
Here is a list of the error codes from the component help file.
Return Codes
0xFF - No Card Error
0xFE - No Response Error
0xFD - No Ack Error
0xFC - Timeout Error
0xFB - Reserved Error
0xFA - Bad Sector Error
0xEF - File Not Found Error
0xEE - Root Full Error
0xED - Sector Bytes Error
0x03 - File Empty
0x02 - File Type
0x01 - End Of File
0x00 - Ok
255 is 0xFF so no card detected.
Are you sure you have the hardware connected up correctly. Are you using E-blocks or your own hardware?
- JohnCrow
- Valued Contributor

- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
Re: FAT 16 Not Working
Hi
Not sure if this will help but I had a problem with the card reader quite some time ago.
(The component has been updated since then though)
I found a Sandisk 2GB class 2 card worked fine but a Panasionic 2GB class 4 was not recognised. i.e retval gave 255
We eventually got it to work by changing a delay in the card reader component C code.
http://www.matrixmultimedia.com/mmforum ... ard#p23382
This was with PIC Flowcode.
Not sure if this will help but I had a problem with the card reader quite some time ago.
(The component has been updated since then though)
I found a Sandisk 2GB class 2 card worked fine but a Panasionic 2GB class 4 was not recognised. i.e retval gave 255
We eventually got it to work by changing a delay in the card reader component C code.
http://www.matrixmultimedia.com/mmforum ... ard#p23382
This was with PIC Flowcode.
1 in 10 people understand binary, the other one doesn't !
Re: FAT 16 Not Working
I'm having trouble finding where to insert the delays. Could you tell me where you put yours? Thanks!JohnCrow wrote:Hi
Not sure if this will help but I had a problem with the card reader quite some time ago.
(The component has been updated since then though)
I found a Sandisk 2GB class 2 card worked fine but a Panasionic 2GB class 4 was not recognised. i.e retval gave 255
We eventually got it to work by changing a delay in the card reader component C code.
http://www.matrixmultimedia.com/mmforum ... ard#p23382
This was with PIC Flowcode.
Re: FAT 16 Not Working
Never mind, found it. Looks like it was already at 10us. So, the problem must be something else.rocket200 wrote:I'm having trouble finding where to insert the delays. Could you tell me where you put yours? Thanks!JohnCrow wrote:Hi
Not sure if this will help but I had a problem with the card reader quite some time ago.
(The component has been updated since then though)
I found a Sandisk 2GB class 2 card worked fine but a Panasionic 2GB class 4 was not recognised. i.e retval gave 255
We eventually got it to work by changing a delay in the card reader component C code.
http://www.matrixmultimedia.com/mmforum ... ard#p23382
This was with PIC Flowcode.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: FAT 16 Not Working
Hello,
AVRs generally run a bit faster then PICs so it might be worth taking the delay up to 20 or 30 to see if that helps any. Also some older cards might run quite slowly anyway so worth a shot. Another option maybe to try a slower crystal as this will slow down the SPI hardware clock. Also worth a quick shot to see if it helps.
AVRs generally run a bit faster then PICs so it might be worth taking the delay up to 20 or 30 to see if that helps any. Also some older cards might run quite slowly anyway so worth a shot. Another option maybe to try a slower crystal as this will slow down the SPI hardware clock. Also worth a quick shot to see if it helps.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: FAT 16 Not Working
Benj wrote:Hello,
AVRs generally run a bit faster then PICs so it might be worth taking the delay up to 20 or 30 to see if that helps any. Also some older cards might run quite slowly anyway so worth a shot. Another option maybe to try a slower crystal as this will slow down the SPI hardware clock. Also worth a quick shot to see if it helps.
Tried changing the delay to 20, 30, 100, and 1000. Still returning 255.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: FAT 16 Not Working
Hello,
Have you tried a slower crystal or switching to the software SPI impementation?
Have you tried a slower crystal or switching to the software SPI impementation?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: FAT 16 Not Working
Finally figured it out! It works!!! Here is what was causing it to not work; I was using the internal oscillator. I figured it would be fine running off the internal, but it turns out I needed to use a crystal. Once I hooked one up it worked like a charm!Benj wrote:Hello,
Have you tried a slower crystal or switching to the software SPI impementation?
Thanks for the help guys!