Hi,
I'm writing an Arduino port for the LPC1114 chip (towards a systematically porting method for any microcontroller) and so far so good, until I discovered a (n extremely) code size increase when using floating point arithmetic (FPA). When Arduino UNO uses FPA the size code is barely increased; however in my Cortex-M0 the increasing is about 7 KB!
There must be something I'm overseeing in the LPCXpresso toolchain, so any hint is welcomed.
In both cases, LPCXpresso IDE and Wiring, the code is (roughly):
int main(void)
{
init();
pinMode( LED_BUILTIN, OUTPUT );
digitalWrite( LED_BUILTIN, LOW );
Serial.begin( 115200, SERIAL_8N1 );
while( 1 )
{
int adcVal = analogRead( A0 );
Serial.println( (adcVal * 3.3) / 1023 );
delay( 100 );
}
}
ARDUINO: Sketch uses 3670 bytes from 32256
LPCXPRESSO: 13972 bytes out of 32KB (with -Os and NewLibNano(nohost) enabled)
Any comments are welcomed!
In the first place, I would suggest that you try using MCUXpresso IDE - which replaced the old LPCXpresso IDE product about 18 months ago. The current version is v10.2.1. More information along with product download links are available from : https://www.nxp.com/mcuxpresso/ide
With regards to your problem, IIRC, the version of Newlib/NewlibNano provided (as part of the ARM GCC tools) in some version of LPCXpresso IDE did have some code size issues with its floating point support code of the sort that you are seeing. And I think that ARM resolved these in later versions of the GCC tools.
If you continue to see issues with the latest tools, please do a clean of your project, then use the Export option on the Quickstart Panel - and post the example ZIP file here for us to look at.
Regards,
MCUXpresso IDE Support
My mistake: I'm using MCUXpresso 10.2.1, and I don't know why I wrote LPCXpresso.
Other thing I didn't mention is that the port I'm writing is being compiled with C++ 11, with newlibnano(no host). I think I forget to set the floating point library: FPv?-XX. I will try it ASAP.