Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Firmware hangup problem, #RTOS, #SD, #Serial

Status
Not open for further replies.

w_bwr

Member level 3
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.

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??
 

There were 5 tasks running, i stopped all the task except the one with the desired function. Firmware doesn't freeze on anywhere now. Then i re-opened all tasks one by one and found the one which one was causing problems.
This task does nothing, was included for future use. But Disabling this solves the problem. What could be the reason for that?

The task code:
Code:
void DispTask(void)
{
K_Task_Wait(1000);               // wait for 1000 OS ticks

for (;;)
{
K_Task_Wait(100);  
}
}
 

The issue was that i mistakenly declared larger data buffer as local in a SerialTestAuto() function. That caused the firmware to crash. I, now, declared them as global and everything is fine now.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top