HI All,
16 SD card is interface to msp430f5329 controller and able to read and write data using SPI and also FAT32 file system write is tested, able to created text file on SD card and data is able to write in text file single and no .of packets.
now my problem is re-open text file and writing is not happening, not understanding where am doing mistake.
am using FAT file system example from ti\MSP430Ware_3_50_00_04\examples\boards\MSP-EXP430F5529\MSP-EXP430F5529_UE_Demo_Software\Firmware\Source\FatFs example.
in F_write() function of ff.c added one condition, no.of packets to write greater than zero
if (disk_write(fp->fs->drv, wbuff, sect, (BYTE)cc) != RES_OK) ABORT(fp->fs, FR_DISK_ERR); if(bytes>0) sect +=1;
main program is :
WDTCTL = WDTPW + WDTCNTCL + WDTIS_3; // 512 ms for internal ref clock as clock source initGpio(); initClock(); initScia0(); initScia1(); initspiB1(); initTimerA0(); initlcd(); initkey(); #ifdef SD_Card P6OUT |= BIT3; //RS 485 Enable pin is high sci1_msg("SD card testing .....\n\r"); status=disk_status(); if(status == 0) //SD card inserted do{ status1=disk_initialize(); watchdogReset(); }while(status1!=0x00); sci1_msg("Diskinitialization success.....\n\r"); P6OUT &= ~BIT3; // checking FTA32 file system f_mount(0,&FatFs); //Data_write_into_SD_card(); if (f_open(&Fil, "newfile.txt", FA_WRITE | FA_CREATE_ALWAYS) == FR_OK) { // Create a file / f_write(&Fil, sof,512, &bw,1); f_write(&Fil,dataStore,512, &bw,1); f_close(&Fil); } // again writing data to SD card in same file, now writing 100 times if (f_open(&Fil, "newfile.txt",FA_OPEN_EXISTING |FA_WRITE) == FR_OK) { // Create a file / for(i=0;i<100;i++) { f_write(&Fil, "pvt",512, &bw,1); f_write(&Fil,dataStore,512, &bw,1); } //End of for loop f_close(&Fil); } #endif
every time 2nd time data only available on SD card, first time data is not available, thinking first time data is over writing to 2nd time data,
if i write single time, data is available on sd card.
thinking after sending f_close(&Fil); it is writing starting memory location means, In f_write() function Create a new cluster chain, may be is it creating issue?
kindly help me to solve the problem.