w_bwr
Member level 3
- Joined
- Feb 4, 2010
- Messages
- 66
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Karachi, Pakistan
- Activity points
- 1,810
I wrote a simple program to test the on board peripherals. here is the code, i excluded the unnecessary details.
Firmware gets stuck in Serial testing while writing to SD Card
Serial Monitor Output:
"
Analog Test Failed
Lock Acquired
WRToSD called
SD File closed
Lock Released
Serial Test Failed
Lock Acquired
W
"
it only print the "W" of "WRToSD called".
both WRToSD() and K_Serial_Print_Wait() are used at many other places and never showed any problems. It is only when serial testing is done, it gets stuck. I have other tests too e.g. CAN, back light, contrast, all go fine but the serial test.
What could be the problem??
Code:
int WRToSD(char cStrings[100])
{
if (SdCard.iSdStatus == SD_INITIALIZED)
{
K_Serial_Print_Wait("WRToSD called\r\n",15,200); // Writes to Serial monitor
SDFile = FS_FOpen(cFileName, "a"); //.bin "wb" AS
iLeng = strlen(cStrings);
nn = FS_FWrite(cStrings, 1, iLeng, SDFile);
FS_FClose(SDFile);
K_Serial_Print_Wait("SD File Closed\r\n",16,200);
if (iLeng != nn)
return 0;
return nn;
}
return -1;
}
void AnalogTestAuto(void)
{
// Test analog inputs
if (pass)
{
LCDPrintAt("Pass", 26,7);
sprintf(SDTextAuto,"Analog test passed\r\n");
K_Serial_Print_Wait(SDTextAuto, strlen(SDTextAuto),200);
K_Resource_Wait(ResourceSPIBus,0); // waits for the resource for indefinite time
K_Serial_Print_Wait("Lock Acquired\r\n",15,200);
WRToSD(SDTextAuto);
K_Resource_Release(SDTextAuto);
K_Serial_Print_Wait("Lock Released\r\n",15,200);
}
else
{
LCDPrintAt("Fail", 26,7);
sprintf(SDTextAuto,"Analog test failed\r\n");
K_Serial_Print_Wait(SDTextAuto, strlen(SDTextAuto),200);
K_Resource_Wait(ResourceSPIBus,0); // waits for the resource for indefinite time
K_Serial_Print_Wait("Lock Acquired\r\n",15,200);
WRToSD(SDTextAuto);
K_Resource_Release(SDTextAuto);
K_Serial_Print_Wait("Lock Released\r\n",15,200);
}
}
void SerialTestAuto(void)
{
// Do Serail testing
if (Pass)
{
LCDPrintAt("Pass", 26,7);
sprintf(SDTextAuto,"Serialtest passed\r\n");
K_Serial_Print_Wait(SDTextAuto, strlen(SDTextAuto),200);
K_Resource_Wait(ResourceSPIBus,0); // waits for the resource for indefinite time
K_Serial_Print_Wait("Lock Acquired\r\n",15,200);
WRToSD(SDTextAuto);
K_Resource_Release(SDTextAuto);
K_Serial_Print_Wait("Lock Released\r\n",15,200);
}
else
{
LCDPrintAt("Fail", 26,7);
sprintf(SDTextAuto,"Serial test failed\r\n");
K_Serial_Print_Wait(SDTextAuto, strlen(SDTextAuto),200);
K_Resource_Wait(ResourceSPIBus,0); // waits for the resource for indefinite time
K_Serial_Print_Wait("Lock Acquired\r\n",15,200);
WRToSD(SDTextAuto);
K_Resource_Release(SDTextAuto);
K_Serial_Print_Wait("Lock Released\r\n",15,200);
}
}
void TestAuto(void) // This function is called in a task.
{
AnalogTestAuto();
SerialTestAuto();
}
Firmware gets stuck in Serial testing while writing to SD Card
Serial Monitor Output:
"
Analog Test Failed
Lock Acquired
WRToSD called
SD File closed
Lock Released
Serial Test Failed
Lock Acquired
W
"
it only print the "W" of "WRToSD called".
both WRToSD() and K_Serial_Print_Wait() are used at many other places and never showed any problems. It is only when serial testing is done, it gets stuck. I have other tests too e.g. CAN, back light, contrast, all go fine but the serial test.
What could be the problem??