I am using MCUXpresso to develop C++ firmware on an LPC54018 (OM40003UL) development board.
Can anyone tell me why the basic code I have written below is able to successfully open and create a log file in a specified directory when I run it in debug mode, but does not create the log when I build and run the released version after flashing it using the GUI Flash Tool? Perhaps I need a configuration change?
fp = fopen("TempData.txt","w+");
fprintf(fp, "%8lu %10f\n", g_DataNum, tempAve);
if (g_DataNum == LOG_TIME_IN_MIN * 60) fclose(fp);
Solved! Go to Solution.
I think, check the setup of both the debug and release version.
Where are the fopen/fprintf/fclose functions routed to, the onboard SD interface or semihosting (PC) ?
Semihosting is usually only enabled for the debug build, for good reasons.
This article will help you understand how semihosting works
https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/What-is-Semihosting/m-p/475390
This should help you understand why it is not a good idea to use printf in release code.
I am using fprintf's to print temperature data to a log file that can be evaluated after running a released version of the firmware. I've worked with other firmware that did this. Please advise.
I found some SDK examples for an SD card I can use with my development board. I can get what I need from them. Thank you for directing me guys.
Yes, that would be the suggested way.
For a non-semihosting solution, you would need a permanent storage (SD card) and a file system (usually FatFS).
FatFS usually comes with it's own versions of file io functions.
I think, check the setup of both the debug and release version.
Where are the fopen/fprintf/fclose functions routed to, the onboard SD interface or semihosting (PC) ?
Semihosting is usually only enabled for the debug build, for good reasons.