strange codesize with gcc on LPC812 / Cortex-M0

13 Jun 2016

I have a small project with a LPC812 and exported it to LPCXpresso. There I added the wakeup lib from Eric O. and the code size nearly doubled. I found the relevant code line:

        //Load the timer
        //LPC_WKT->COUNT = (uint32_t)((float)ms * cycles_per_ms);
        LPC_WKT->COUNT = ms * cycles_per_ms;

when I completely remove the multiplication line, the code size (text segment) is 6904 bytes. cycles_per_ms defined as float (original code) results in 11048 bytes. removing the float mul and defining cycles_per_ms as uint32_t gives 11312 bytes. Defining cycles_per_ms as int gives 8888 bytes.

How can the difference be that big between 32 bit signed / unsigned multiplication? And why costs the unsigned int even more than the float multiplication?

13 Jun 2016

ok, got it: the wakeup code contains also a calibrate function which calculates the cycles_per_ms and uses float math. So this function also pulls in the floating point lib. When I do not call the calibrate function, the code is also <7000 bytes and that works for me.