FAT16 Library Routine issue

Post your requests and ideas on the future development of mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
b4rzan
Posts: 60
Joined: 12 Nov 2011 21:39

FAT16 Library Routine issue

#1 Post by b4rzan » 19 Feb 2013 21:22

Hi All,

I am trying to use the FAT16 library functions on the mikroc dspic 8.1 using the dsPIC30f4013 but I am facing an issue and that is as follows,

*I can Initialize the Mmc_Init() with no problems
*Also the Mmc_Fat_Init() works as well

However when I try using the other FAT16 routines such as the Mmc_Fat_QuickFormat(),
Mmc_Fat_Assign(), etc... the microcontroller stops responding! as if there is no sd card in the slot. As soon as I remove these FAT16 routines in the code the program works!

I am using a 256MB SD card, my dsPIC is running on 12MHz. I have also tried other SD cards but I still experience the same issue. The SD card is also formatted as FAT using the windows format tool and the file allocation size was set to Default. However when I formatted the SD card, windows tool only had these options FAT or FAT32, there was no FAT16! I dont know if that could be the problem. Please kindly comment you're thoughts if you know what is causing this. Thank you all

below is my code:
#include"dsLCD.h"
#include"dsLCD.c"
sbit Mmc_Chip_Select at LATF0_bit; // for writing to output pin always use latch
sbit Mmc_Chip_Select_Direction at TRISF0_bit;

char filename[] = "MYFILE55TXT";
unsigned char txt[] = "This is the added data...";
unsigned short character;
unsigned long file_size,i;
char x,f;



void main()
{
ADPCFG=0xffff;
TRISD=0x00;
LATD=0;
Start();
Clear();
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_64,
_SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE);

while(Mmc_Init()!=0); // init SD card Bus

Cursor(0,0);
PrintString("Init Done",9);
Delay_ms(5000);
Clear();
// Reinitialize the SPI module at higher speed (change primary prescaler).
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_4,_SPI_SS_DISABLE,
_SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE);


while(Mmc_Fat_Init()!=0); //Init Fat fs

Cursor(0,0);
PrintString("Fat Init",8);
Delay_ms(5000);

//Create the file (if it doesn’t exist)
Mmc_Fat_Assign(&filename,0x80); //<== problem occurs whenever FAT16 functions are called.
Clear();
Cursor(0,0);
PrintString("File Created",1);
Delay_ms(5000);
Clear();

while(1);
}

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 Wish List”