FAT Initialise is not possible

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

FAT Initialise is not possible

Post by stefan.erni »

I wrote a small program for the FAT Initialise. The program try to Initialise the FAT (CARD). If it's ok the 5mmLED is turned off. On the clockpin I put an another led, so I can see if the software gives clocks....
The result is always clocking and never ok. The main clock is 8Mega, I tryed all clock-divider 512,320,256,192,128,64,32 but it did not help.
I controled with the osciloscope
The signal on Pin MOSI is ok.
The signal on Pin SCK is ok.
The signal on Pin Chipselect is ok.
But on the Pin MISO It's always 3.3Volt.
Attachments
Fat_init1.PNG
(29.98 KiB) Downloaded 2713 times

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: FAT Initialise is not possible

Post by Benj »

Hello,

Please can you attach your Flowcode project file and we will investigate. A schematic or drawing of your circuit to the card might also help.

Note that the pin out for SD and micro SD is not the same.
sd-card-pinout[1].png
(58.5 KiB) Downloaded 7223 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: FAT Initialise is not possible

Post by stefan.erni »

Hi Ben

The Harware is from Olimex:
https://www.olimex.com/Products/Duino/P ... e-hardware
There is a schema in pdf.
Hardware1.PNG
Board info
(242.04 KiB) Downloaded 7202 times
I put a RS232 to USB Adapter. With this adapter it's possible to connect a PIC32 to USB and read error-code with a terminalprogram. The card ist sending always FF
https://www.olimex.com/Products/Modules ... e-hardware.

I tried sd Card from different manufacturer.

regards

Stefan
Attachments
Fat_erni1-send.fcfx
(18.07 KiB) Downloaded 313 times
PIC32-PINGUINO-MICRO-REV-B.pdf
(29.12 KiB) Downloaded 343 times

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: FAT Initialise is not possible

Post by Benj »

Hello Stefan,

Are you using the updated PIC32 definition files available from here.
http://www.matrixtsl.com/mmforums/viewt ... 63&t=18182

It could be something to do with this?

In the Flowcode generated C file (Build -> View C...) near the bottom of the file at the start of the main function do you have the AD1PCFG line of code?

Code: Select all

int main()
{
AD1PCFG = 0xFFFF;

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: FAT Initialise is not possible

Post by stefan.erni »

Hi Benj

Yes. I'm using FC7.1.1 and I can see the AD1PCFG = 0xFFFF;

But I found a problem. The output B13 is not working. If I tested without the Card insert, the pin was low(chip is selected) but with the Card, it was always high. So I tried to use this pin as a normal output and set it flashing h/l .But no change on the pin, always low. I think Pin13 is not and output in my software.

regards

Stefan

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: FAT Initialise is not possible

Post by stefan.erni »

Hi Benj

For a test I solder a wire from B13 to GND to give a "hard" CS and then..... the card is working!

But why the B13 is not following FC?

regards

Stefan

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: FAT Initialise is not possible

Post by Benj »

Hi Stefan,

Thanks for letting us know. I'm looking into reasons why B13 would not be functioning as a digital output now.

B13 shares this functionality.

ADC Input - We have already checked this is off by default and setting the AD1PCFG register to 0xFFFF
PMA10 - Parrallel Master Port Address - Looks like this is off by default
TDI - JTAG Test Data Input

In your config settings the setting for "Background Debugger Enable" is currently undefined. Maybe try switching this to disabled and see it that helps at all.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: FAT Initialise is not possible

Post by stefan.erni »

Hi Benj

I did the
Background Debugger Enable to disabled... did not help

It's looks like I can not use the Pin with TDI,TDO,'TCK

And the B13 is the JTAG Test Data Input.
But how can I do to turn off the JTAG function?

regards

Stefan

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: FAT Initialise is not possible

Post by stefan.erni »

Hi Benj

I wrote a code in the begin

DDPCON=0;

and now it' working

Thank Your for the help to found the reason.

regards Stefan

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: FAT Initialise is not possible

Post by Benj »

Hi Stefan,

Fantastic news, well done and thanks for letting us know. I'll add this code to the appropriate chip definition files so it hopefully won't catch anyone else out in the future.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: FAT Initialise is not possible

Post by stefan.erni »

Hi Ben

I have some more small things about PIC32MX440F256H.

The clock divider, from the SD-Card, is not working correct.
The fastes clock I can measure with the osciloscope is on the "dived by 6"
If I use the "dived by 4" and "dived by 2" ist 10 time slower as "dived by 6".

And this strange PIC has just 1 SPI Port and Microchip call it SPI2.But FC give a "channel1" (it does not work)
Only in softwaremode.

regards

Stefan

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: FAT Initialise is not possible

Post by Benj »

Thanks Stefan,

I will investigate and see if I can fix this.

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: FAT Initialise is not possible

Post by Benj »

Right some progress,

I have found some more bugs related to the SPI and hopefully these are now fixed too. I have added a spacer SPI channel to the definition file so that Channel 2 is now available yet Channel 1 is not.

To apply the fixes you need the following files.

The updated chip definition file lives in the "Flowcode 7/FCD/PIC32" folder.
32MX440F256H.fcdx
(39.56 KiB) Downloaded 275 times
And the updated CAL file lives in the "Flowcode 7/CAL/PIC32BIT" folder.
PIC32BIT_CAL_SPI.c
(14.77 KiB) Downloaded 302 times
Finally the updated CAL component lives in the "Flowcode 7/components" folder.
cal_spi.fcpx
(10.25 KiB) Downloaded 245 times
After you have copied the files restart Flowcode and SPI channel 2 should then be available in the Channel drop down.

Let me know how you get on.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: FAT Initialise is not possible

Post by stefan.erni »

Hi Ben

Thank you for the time.


I tried the software SPI also. But the problem of the divider is still the same.
(the "dived by 4" and "dived by 2" ist 10 time slower as "dived by 6".)

The hardware CH2 is now working and has a much faster speed. So I use this setup.
For Initial Prescalar of the sd-card there are a lot of possible divider.
Is it a big problem to have the same divider for the highspeed? or just add the /2 /6 /8.
But anyway, I think , the card is now fast enough for my Project.

initial_transfer.PNG
(18.92 KiB) Downloaded 7109 times
hispeed_transfer.PNG
(16.67 KiB) Downloaded 7109 times

and a small Thing in the Project option I think it's not 48000000 it's 80000000 for the max speed.
project_option.PNG
(10.5 KiB) Downloaded 7109 times
regards
Stefan

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: FAT Initialise is not possible

Post by Benj »

Hello Stefan,

Thanks for letting me know how you've got on.
I tried the software SPI also. But the problem of the divider is still the same.
(the "dived by 4" and "dived by 2" ist 10 time slower as "dived by 6".)
Thanks I will investigate the software mode. I did make some minor changes but it sounds like it has not fixed the issue.
For Initial Prescalar of the sd-card there are a lot of possible divider.
Is it a big problem to have the same divider for the highspeed? or just add the /2 /6 /8.
Yes the "High Speed" should be the same list as the "Initial Speed" settings. I will investigate why this is not working.
and a small Thing in the Project option I think it's not 48000000 it's 80000000 for the max speed.
You should be able to type in the 80000000 value directly into the clock speed setting. The list is just some common clock speeds but you can type in any value. If the number you type in is too large for the target then Flowcode will warn you about it and set the clock speed to what it thinks should be the max speed.

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: FAT Initialise is not possible

Post by Benj »

Yes the "High Speed" should be the same list as the "Initial Speed" settings. I will investigate why this is not working.
Found and fixed the issue. Simply copy the attached file into your "Flowcode 7/Components" folder and restart Flowcode and the high speed prescaler issue should be fixed.
FAT.fcpx
(67.16 KiB) Downloaded 260 times
Thanks I will investigate the software mode. I did make some minor changes but it sounds like it has not fixed the issue.
This should also be fixed in the attached file. This lives in the "Flowcode 7/CAL/PIC32BIT" folder. You are right in that /6 would have been the fastest prescaler option for the software channel. Now /2 is the fastest and this will correspond with the /6 speed you were getting before. The hardware channels are always going to be much faster so best to use these if they are available especially for something like FAT where you are shifting a lot of data.
PIC32BIT_CAL_SPI.c
(14.76 KiB) Downloaded 276 times

Post Reply