Help for the fat component on dsPIC

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Help for the fat component on dsPIC

Post by Mikat »

Hi.

I am trying to get fat component working at the PIC30f6012A, but I can't get it workig.
I have 2 cards Canon 32Meg and Kingston 512Meg, the fat init fine with both cards and opens the root folder, but then I got rootfull error (0xEE) if try to create file and file not found error (0xEF) if I try to open existing test.txt file...
I try to slower spi speed, but it doesn't help...
Card are formatted at FAT file format..
And fat uses hw SPI.


Mika

User avatar
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: Help for the fat component on dsPIC

Post by Benj »

Hello Mika,

What version of Flowcode are you running and are you using E-blocks or other hardware?

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Help for the fat component on dsPIC

Post by Mikat »

Hi.

The version of flowcode dsPIC is 4.4.13.69, and the hw is my own, spi at spi1 and cs at portD0, the level shifting is done at 680/1k resistor divider, and signal looks nice...
The fat init nicely every time after I lowered the handshaking spi speed (the chip is running at 100MHz :) )...


Mika

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Help for the fat component on dsPIC

Post by Mikat »

Ok.

As usually, the problem was between the keyboard and the seat :P .
I tested the slower spi speed yesterday, but then I notice thet there was old pwm component, which drives the 20KHz pwm at the cs pin, after I fixed that, I didn't remember that I play with the spi speed setting, and the fullspeed spi was really full speed, it was 25MHz... So after I reduce the spi speed to Fcy/4 things works ok...

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Help for the fat component on dsPIC

Post by Mikat »

Well the things isn't always so easy :? .
Now the data transmission works, but the open folder macro reset the pic quite often...
Any ideas?

Mika

User avatar
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: Help for the fat component on dsPIC

Post by Benj »

Hello,

Hm the PIC actually resetting is probably a bad sign. I wonder if there is something corrupting or overflowing the stack. Are you using interrupts in your program? If so then is there a lot of code being processed as part of the interrupt service routine?

We have optimised the FAT code a lot for v5 by getting rid of the byte to long mechanism and replacing with a direct address mechanism for bytes in longs. However I have not come across any problems with the open folder macro on either the new code or the old.

I will try and get some time to test this on a dsPIC system and see if I can replicate any of the problems you are having.

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Help for the fat component on dsPIC

Post by Mikat »

Hi.

The stack overflow I was thinking too..
Yes I have the interrupt, remember it now when you ask. First I think that is quite simple interrupt, but it does have the spi communication, so it goes at least few level down at macros...
I'll test tomorrow without the interrupt.
The interrupt is quite "must", its for the touchscreen communication...

Mika

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Help for the fat component on dsPIC

Post by Mikat »

HI.

Little update.
The reset occurs even if the fat code is just behind the init lcd, so there is nothing else running than lcd and fat...
But only the Canon 32 Meg resets the pic, not the Kingston 512 Meg.. But the Kingston don't work ok, neither the fat or fat 32, the append in the file won't write in the file, actually following thing just makes the file disappear. Open folder "root" -> Open folder "temp" -> Open file "temp.txt" -> append string to file....
The Kingston card seems to have default cluster size 8kb...
The Canon has cluster size 512b and it work fine except the resets...

Mika

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Help for the fat component on dsPIC

Post by Mikat »

Again little update, it seems that its delete file function, which causes the reset..
I have function which seeks the "test.txt" file, if it exist delete file and then create new "test.txt", and if there is no file, all goes well, but if there is file, program will delete it and then the pic resets.. When the program starts again, the file is deleted, and all goes fine...


Mika

User avatar
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: Help for the fat component on dsPIC

Post by Benj »

Hello,

The FAT component will only support modern cards with a sector size of 512bytes. Anything other then this is not strictly a modern SD card according to the current SD standard. So this is maybe why the Kingston device is not working for you.

Cluster Size is the number of sectors per fat entry. This is normally 32 (16384bytes) but the component should support other multiples too. You can analyse every aspect about the cards you are using by downloading a demo piece of software called winhex. The Demo version will do everything you need to be able to check the cards and the data etc.

I will have an investigation with the delete function and see if I can find out why it is causing the reset. I must admit its a function I rarely use.

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Help for the fat component on dsPIC

Post by Mikat »

Sorry I mixed the sector size, and allocation unit size, thing don't always translate right just in head, sometimes I should use dictionary...
Bot card have sector size 512b...
Does it matter what is the allocation unit size at formatting the card?

Mika

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: Help for the fat component on dsPIC

Post by Mikat »

Still can't write to Kingston card...
And another problem (is it just me who always finds another problem?), I can't write the eeprom more than one time/location...
I try to avoid to use the delete file function, and write eeprom number of the file, and each start increment that count by one..
BUT when I program the eeprom,I can write it one time/location, but not again..
Even if I put 2 write eeprom macros, and delay between them, the eeprom has result of first write..
Or try the loop which increment the value in eeprom, the value is the first write value..
And even if I program the program memory again, but leave the eeprom intact, I can't write it again, only when I write the program and eeprom memory again, I can write the location once..
I mean that I can write every location (accept the 0, but just once/location...)


Mika

beambase
Posts: 94
Joined: Wed Jul 29, 2009 5:15 pm
Has thanked: 6 times
Been thanked: 8 times
Contact:

Re: Help for the fat component on dsPIC

Post by beambase »

I am having the same problem on a 30F6012A. Any solution yet?

Post Reply