AnsweredAssumed Answered

Floating-point size Cortex-M0 vs ATMega328

Question asked by Fco. Javier Rodriguez G on Jul 30, 2018
Latest reply on Sep 21, 2018 by Fco. Javier Rodriguez G

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!

Outcomes