Fwrite function slowed on LPC11U24

02 Mar 2012

Good morning

I tried to use the fwrite() C function to produce a binary file on the local memory of mbed LPC11U24 board. The delay introduced by the fwrite function is quite impressive. Every code change (such as inserting the fflush() operation after an fwrite call) did not produce significant results. Note that the same code works perfectly on the LPC1768 mbed board. Please, does anyone have any helpful advice?

Best regards Vincenzo Genovese

02 Mar 2012

Hi Vincenzo,

vincenzo genovese wrote:

I tried to use the fwrite() C function to produce a binary file on the local memory of mbed LPC11U24 board. The delay introduced by the fwrite function is quite impressive. Note that the same code works perfectly on the LPC1768 mbed board. Please, does anyone have any helpful advice?

On the LPC11U24 mbed we are using a different C standard library implementation from the LPC1768 mbed.

On the LPC11U24 mbed we use microlib: optimized for memory space.

On the LPC1768 mbed we use the ARM C standard library: fully standard compliant and optimized for good performance.

We had to introduce this difference because on the LPC11U24 mbed we have only 1/16 of the flash and 1/4 of the RAM.

microlib is not buffering stdio operations and it is basically performing every file operation character, by character. This is why you are experiencing this problem.

I already implemented a workaround until this problem in microlib is fixed:

FILEHANDLE fh = local_file_open("test.dat", O_WRONLY);
LocalFileHandle lfh(fh);
lfh.write(buf, sizeof(buf));
lfh.close();

HTH, Emilio

02 Mar 2012

Hi Emilio.

Perfect. Thank you for the prompt reply. I tested your workaround and it works!

Best regards Vincenzo