Part Number: EK-TM4C1294XL
Hi All,
I'am using EK-TM4C1294XL launchpad . I'am interfacing an SD card with the MCU & I'am able to create new files and write data in them. Iam using SSI3 to connect to SD card module
However , some garbage data is also written with the correct data. In my final application I'll be storing ADC data however for testing purpose I'am simply storing integers upto 150 using a simple for loop
Also , When I store the data in a while(1) loop , the data is stored differently and when I store the data without the while(1) loop it is stored in a different manner. Attached are the test files both with& without while(1) loop.
kindly help me out .
Below is my main function
int main(void) {
FRESULT iFResult;
uint32_t a=0,b=0,c=0;
FPULazyStackingEnable();
g_ui32SysClock= SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
SysTickPeriodSet(g_ui32SysClock / 100);
SysTickEnable();
SysTickIntEnable();
IntMasterEnable();
while(1)
{
iFResult = f_mount(0, &g_sFatFs);
if(iFResult != FR_OK) {
//UARTprintf("f_mount error: %s\n", StringFromFResult(iFResult));
return(1);
}
else {
//UARTprintf("SD card mounted.\n");
}
iFResult = f_open(&fil, "test33.csv", FA_WRITE|FA_OPEN_ALWAYS);
if(iFResult != FR_OK) {
//UARTprintf("fresult: %s\n", StringFromFResult(iFResult));
}
else {
//UARTprintf("\n Opened SD card\n");
}
char fileHeaders[] = "sensor1,sensor2,sensor3,sensor4\r\n";
iFResult = f_write(&fil, fileHeaders, sizeof(fileHeaders), &countHeader);
char valueStr[150];
for(a=0;a<=149;a++)
{
//b=a;
//c=a;
usprintf(valueStr,"%d,%d,%d,%d\n",a,a,a,a);
// a= valueStr[a];
SysCtlDelay(300000);
iFResult = f_write(&fil, valueStr, sizeof(valueStr), (UINT *)&countRow);
SysCtlDelay(300000);
}
iFResult = f_close(&fil);
f_mount(0, NULL);
}
}