Part Number:TMS320F28388D
请教一个问题,我现在使用了SPI驱动SD卡存储数据,驱动程序是改的28377的驱动代码,但现在存在该代码只能存储一次的问题,请问我需要怎么设置才能让代码连续存储?谢谢!
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "SD.h"
#include "sdio_sd.h"
#include "ff.h"
#include <stdio.h>
#include "spi.c"
#include "SDsupport.h"
FATFS fs; /* Work area (file system object) for logical drive */
FIL fsrc; /* file objects */
FRESULT res = FR_OK;
uint16_t br;
char path[512] = "0:";
char textFileBuffer[] = "2838828377 \r\n";
//
// Main
//
void main(void)
{
FRESULT h;
char m[]="0:/test.txt";
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pullups
//
Device_initGPIO();
//
// Initialize the SPI
//
initSPI();
//
// SDcard insertion detect Functions
//
sd_card_insertion();
//
// SDcard SPI Initialization Functions
//
sd_initialization();
res = f_unlink(m); //删锟斤拷SD锟斤拷锟斤拷同锟斤拷锟侥硷拷
h = f_mount(0, &fs);
if(h != FR_OK) asm(" ESTOP0"); //锟侥硷拷注锟斤拷失锟杰o拷锟斤拷锟斤拷锟斤拷停
res = f_open(&fsrc, m, FA_CREATE_ALWAYS | FA_WRITE); //FA_CREATE_NEW | FA_WRITE);
while(1)
{
// FRESULT res = FR_OK;
if(res == FR_OK)
{
/* Write buffer to file */
res = f_write(&fsrc, textFileBuffer, sizeof(textFileBuffer), &br);
/* close file */
f_close(&fsrc);
}
// asm(" ESTOP0");
} //Loop forever
}
//
// End of File
//
Green Deng:
你好,关于SD卡的应用,我们这边没有做过相关使用经验,建议你将问题直接发布到英文E2E论坛,会有工程师协助你解决SD卡读写的问题:e2e.ti.com/…/c2000-microcontrollers-forum