Page 1 of 1
FAT 16 Not Working
Posted: Sat Mar 10, 2012 5:33 pm
by rocket200
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!!!
Re: FAT 16 Not Working
Posted: Sat Mar 10, 2012 5:36 pm
by DavidA
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.
Re: FAT 16 Not Working
Posted: Sun Mar 11, 2012 12:57 am
by rocket200
I updated the Fat component, but now it's not compiling because of some errors:
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: expected declaration or statement at end of input
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
Posted: Mon Mar 12, 2012 3:37 pm
by rocket200
Anybody? Is there more information I can provide to help figure the problem out?
Re: FAT 16 Not Working
Posted: Mon Mar 12, 2012 5:31 pm
by Benj
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.
Re: FAT 16 Not Working
Posted: Mon Mar 12, 2012 9:42 pm
by rocket200
Benj wrote:Hello,
I have just tried compiling the FAT component C file from my installation and this is working correctly.
AVR_FAT16.c
Let me know how you get on.
Hi,
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

error: expected ')' before ';' token
C:\DOCUME~1\HENRYB~1\Desktop\Flowcode1.c

error: expected declaration or statement at end of input
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
Posted: Mon Mar 12, 2012 11:33 pm
by DavidA
Hello,
Does your Flowchart contain any C code?
Re: FAT 16 Not Working
Posted: Mon Mar 12, 2012 11:41 pm
by rocket200
DavidA wrote:Hello,
Does your Flowchart contain any C code?
My Flowchart does not contain any C code.
Re: FAT 16 Not Working
Posted: Tue Mar 13, 2012 12:10 pm
by DavidA
Hello,
Would it be possible for you to post your fcf file here
Re: FAT 16 Not Working
Posted: Tue Mar 13, 2012 1:47 pm
by rocket200
DavidA wrote:Hello,
Would it be possible for you to post your fcf file here
Sure! I also attached the compiled C code if that helps any.
Re: FAT 16 Not Working
Posted: Tue Mar 13, 2012 2:54 pm
by Benj
Hello,
Thanks for posting the files.
Here is a updated component c file that should allow the compilation to work correctly.
Re: FAT 16 Not Working
Posted: Tue Mar 13, 2012 6:40 pm
by rocket200
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!
Re: FAT 16 Not Working
Posted: Tue Mar 13, 2012 7:02 pm
by Benj
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.
Code: Select all
#define MX_FAT_TYPE 0//%l //0-FAT16(FAT) / 1-FAT32 / 2-FAT16&32
Change the number to suit the file system you require.
eg
Code: Select all
#define MX_FAT_TYPE 2//%l //0-FAT16(FAT) / 1-FAT32 / 2-FAT16&32
Will auto detect the file system on the card but will take up a bit more memory on the microcontroller.
Re: FAT 16 Not Working
Posted: Thu Mar 15, 2012 1:31 am
by rocket200
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.
Code: Select all
#define MX_FAT_TYPE 0//%l //0-FAT16(FAT) / 1-FAT32 / 2-FAT16&32
Change the number to suit the file system you require.
eg
Code: Select all
#define MX_FAT_TYPE 2//%l //0-FAT16(FAT) / 1-FAT32 / 2-FAT16&32
Will auto detect the file system on the card but will take up a bit more memory on the microcontroller.
Hello again,
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?
Re: FAT 16 Not Working
Posted: Thu Mar 15, 2012 11:16 am
by Benj
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?
Re: FAT 16 Not Working
Posted: Thu Mar 15, 2012 1:50 pm
by rocket200
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?
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.
Re: FAT 16 Not Working
Posted: Thu Mar 15, 2012 2:02 pm
by JohnCrow
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
Posted: Thu Mar 15, 2012 3:04 pm
by rocket200
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.
I'm having trouble finding where to insert the delays. Could you tell me where you put yours? Thanks!
Re: FAT 16 Not Working
Posted: Thu Mar 15, 2012 3:31 pm
by rocket200
rocket200 wrote: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.
I'm having trouble finding where to insert the delays. Could you tell me where you put yours? Thanks!
Never mind, found it. Looks like it was already at 10us. So, the problem must be something else.
Re: FAT 16 Not Working
Posted: Thu Mar 15, 2012 3:51 pm
by Benj
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.
Re: FAT 16 Not Working
Posted: Thu Mar 15, 2012 7:11 pm
by rocket200
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.
Re: FAT 16 Not Working
Posted: Fri Mar 16, 2012 1:06 pm
by Benj
Hello,
Have you tried a slower crystal or switching to the software SPI impementation?
Re: FAT 16 Not Working
Posted: Sat Mar 17, 2012 11:55 pm
by rocket200
Benj wrote:Hello,
Have you tried a slower crystal or switching to the software SPI impementation?
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!
Thanks for the help guys!