FAT32

General discussion on mikroBasic PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

FAT32

#1 Post by dmtulsa » 03 Dec 2014 17:17

Just a question. Can I use any SPI for the FAT32 lib

example

Code: Select all

  'SD card                                                                                                                       
  SPI1_Init_Advanced(_SPI_MASTER, _SPI_16_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_64, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE)

  SPI2_Init_Advanced(_SPI_MASTER, _SPI_16_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_64, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE )

  SPI3_Init_Advanced(_SPI_MASTER, _SPI_16_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_64, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE )

Example call

Code: Select all

                   SPI_Set_Active(@SPI1_Read, @SPI1_Write) ' Sets the SPI1 module active
                   InitFat32() 'call my mmc init routine and initfat32

                   or

                   SPI_Set_Active(@SPI2_Read, @SPI2_Write) ' Sets the SPI2 module active
                   InitFat32()

                   or

                   SPI_Set_Active(@SPI3_Read, @SPI3_Write) ' Sets the SPI3 module active
                   InitFat32()
Thank you
Doug
KD5NWK

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: FAT32

#2 Post by filip » 23 Dec 2014 11:47

Hi,

Basically, you can use any SPI that you want, you have posted correct code.
Just pay attention that the MMC card is connected to the proper SPI module.

Regards,
Filip.

dmtulsa
Posts: 114
Joined: 04 Jun 2010 14:08
Location: Tulsa,Ok
Contact:

Re: FAT32

#3 Post by dmtulsa » 05 Jan 2015 16:33

Okay thank you
Doug
KD5NWK

LEANDRO_FELIX
Posts: 11
Joined: 15 Apr 2011 00:33

Re: FAT32

#4 Post by LEANDRO_FELIX » 21 Mar 2017 05:52

Hello Team MikroElektronika!

I'm starting to deploy Fat32 in my program. I am in doubt about the statements below:

PROGRAM my_prog

const FAT32_MAX_FILES as byte = 4

dim fat32_fdesc as array[FAT32_MAX_FILES] of __FILE

Should these statements be placed at the beginning of the program?

As for dim fat32_fdes the array ... Is there any more clear example of how we should declare it in Basic?

To access the root directory should we use "\" or "\\"?

Is it recommended to use the FAT32_Close function to make the program work better? Not to leave multiple files open at the same time?

Sorry for so many questions, but I'm taking advantage of the post to strip all the questions I'm currently having. I used before the FAT system in my program and now I need to migrate to the FAT32 system.

I'm using Mikro Basic Pro for dsPIC30 / 33 and PIC24 v7.0.1

Mcu: PIC24EP512GP806

Thanks in advance for the answers.

Leandro Felix

LEANDRO_FELIX
Posts: 11
Joined: 15 Apr 2011 00:33

Re: FAT32

#5 Post by LEANDRO_FELIX » 21 Mar 2017 17:32

Any answers?

Leandro Felix

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: FAT32

#6 Post by lana.arsic » 21 Mar 2017 18:11

Hi Leandro,

If you want to change FAT32_MAX_FILES, you can do it in __Lib_FAT32_Defs.mbas file
(which is located in Uses folder in installation folder of FAT32 Library).

You don't need to use fat32_fdesc, you can work with file with functions from Fat32 library.

To access the root directory you can use "\" in mikroBasic.

You can open multiple files, but number should be less or equal to FAT32_MAX_FILES,
and yes you need to close the files at the end of code.

Kind regards,
Lana

LEANDRO_FELIX
Posts: 11
Joined: 15 Apr 2011 00:33

Re: FAT32

#7 Post by LEANDRO_FELIX » 21 Mar 2017 19:10

Thanks for the answers. I will continue to implement the code.

Leandro Felix

Post Reply

Return to “mikroBasic PRO for dsPIC30/33 and PIC24 General”