Had to add some data logging in a hurry to diagnose an issue.
A function is passed a pointer to data that is then used to assemble a readable string that's then stored on a SD card
the RTOS task that does this has a 8K stack and typically runs at 10% loading up to 80% (Crude observations of the debug options window)
The first version of the code version cause a Hardfault exception at the sprintf instruction.
I do not use the micro Lib and have included retarget.c in the project
unit8_t baBuf[100]; /******************************* * Create the Data ********************************/ sprintf((char *)&baBuf[0],"%08d,%08d,%02d,%02d,%02d,%02d,%02d,%02d,%04d,%04d\r\n", psLIN->lMillsecTimePerDay, psLIN->lDataId, psLIN->bData1,psLIN->bData2,psLIN->bData3,psLIN->bData4, psLIN->bData5,psLIN->bData6,psLIN->wData1,psLIN->wData2);
The second version of the code works as expected
unit8_t baBuf[100]; /******************************* * Create the Data ********************************/ sprintf((char *)&baBuf[0],"%08d,",psLIN->lMillsecTimePerDay); wDataLength = strlen((const char *)&baBuf[0]); sprintf((char *)&baBuf[wDataLength],"%08d,%02d,%02d,%02d,%02d,%02d,%02d,%04d,%04d\r\n", psLIN->lDataId, psLIN->bData1,psLIN->bData2,psLIN->bData3,psLIN->bData4, psLIN->bData5,psLIN->bData6,psLIN->wData1,psLIN->wData2);
Any one have an view on why the first version of the code should be failing ? or is it a case of Please read the manual
thanks Dan