Problems with using math.h on coldfire m52235

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems with using math.h on coldfire m52235

3,910 Views
HAL
Contributor I
Hi,
We are using Codewarrior 6.3 to program a Coldfire mcf52235 for a students project and are experiencing problems using math functions. Although including "math.h", the compiler cant find the functions like "sin", "round" etc. (e.g. Undefined: "sin")
This is the both the case compiling with UART-Debug or Console Debug.
Looking into the "math.h" (and any files used in it) we don't find no function declarations whatsoever.
 
Can anybody tell us, if we forgot anything for using math functions, or if theres another math-file for downloading in case we are just having a weird math-file ?
Also, we read somewhere to adjust the project to using floatingpoint when creating it, does it have to do anything with using math-functions? However we see no such options when generating a new project.
 
Thank you very much in advance,
HAL & team
Labels (1)
0 Kudos
Reply
6 Replies

758 Views
Nouchi
Senior Contributor II
Hi,

Your problem looks like mine, when I upgraded CW 6.2 to 6.3, I hope that thread will be helpful for you.
http://forums.freescale.com/freescale/board/message?board.id=CWCOMM&message.id=2183&view=by_date_asc...

Actually, you have to rebuild your libraries with some options to enable floating point support, and to link the right libraries files.


Emmanuel

Message Edited by Alban on 2007-01-16 01:18 PM

0 Kudos
Reply

758 Views
HAL
Contributor I
Thanks for the link to the thread.
After changing the Libraries, at least I can compile using math functions. However, using those libraries requires me to increase the User-segment.
After this, the program does not work. I cant figure out if its the libraries or the increasing of the segment, which causes that...
0 Kudos
Reply

758 Views
Nouchi
Senior Contributor II
your program doesn't work or crash?
your problem, could be a stack overflow, so try to increase stack space, or an exception like div by 0, or a exception not serviced
try to set breakpoint in the asm_exception_handler and determine which exception cause the crash.
I can't give you THE solution, but only few clues.

Emmanuel
0 Kudos
Reply

758 Views
HAL
Contributor I
Hm, I tried to change back the libraries to the Reduced ones (C_TRK_4i_CF_SZ_MSL.a) and it still does not work. Maybe I am doing a wrong job in including the libraries ? I added them in the "Files" section, compiled them, and checked the link-order. Is there anything else I should do, so the library is actually used and added to the project?
0 Kudos
Reply

758 Views
HAL
Contributor I
now I tried the following: I took one of the Coldfire example projects in the freescale installation folder (minimal code which should be error-free), renamed the library files, so it would automatically use the non-reduced libraries, increased the segment size because the compiler told me to, and it does not work.
 
Is it correct if I want to increase the user segment, i can just increase the length in the lcf file for the SRAM ? It says:
 
MEMORY {
 vector_ram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000500
 user       (RWX) : ORIGIN = 0x20000500, LENGTH = 0x00007B00
 ipsbar     (RWX) : ORIGIN = 0x40000000, LENGTH = 0x0
}
and I made a "0x00008000" instead of the 7B00...
 
Somhow I have the feeling, math hates me, although I never used to hate it in school :smileywink:
0 Kudos
Reply

758 Views
Nouchi
Senior Contributor II
Hi,

No, you can't do that, because your lcf file says that you have 1280 bytes (vector_ram section) reserved for exception table relocation, and the user ram is 0x8000 - 0x0500 so 0x7B00 (5223x family got 32kbytes sram), and you said to the linker that you have 34048 bytes.
SRAM amount is shared between heap, stack and user datas, so you have to play in the lcf file with stack size and heap size defintions (___SP_SIZE, ___SP_END, ___HEAP_START, ___HEAP_END, etc...) my lcf file looks like this for a MCF5213 (same family 256Kb flash, 32kb SRAM)

Code:
MEMORY
{
 boot  (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00004000   /* bootloader location */
 flash (RX)  : ORIGIN = 0x00004000, LENGTH = 0x0003BFD8   /* user flash */ 
 appId (RX)  : ORIGIN = 0x0003FFC0, LENGTH = 0x00000040   /* application identication */

 vram (RWX)  : ORIGIN = 0x20000000, LENGTH = 0x00000400   /* exception table relocation */
 sram (RWX)  : ORIGIN = 0x20000400, LENGTH = 0x00007C00   /* user ram */

 ipsbar  (RWX) : ORIGIN = 0x40000000, LENGTH = 0x0
}

SECTIONS
{
 .ipsbar  : {} > ipsbar
   
 .vectors :
 {
  vectors.s (.text)
  . = ALIGN (0x10);
 } > flash
   
    .text :
    {
        *(.text)
  .= ALIGN(0x10);
        *(.rodata)
  .= ALIGN(0x10);
        ___DATA_ROM    = .;
        __S_romp       = .;
    } >> flash

 .app_id :
 {
  *(.appident)
 } > appId

    .data : AT(ADDR(.text)+SIZEOF(.text))
 {
  ___DATA_RAM    = .;

        *(.exception)
  .              = ALIGN(0x10);
  __exception_table_start__ = .;
     EXCEPTION
  __exception_table_end__   = .;

  ___sinit__    = .;
     STATICINIT

        *(.data)
  .             = ALIGN (0x10);
  ___DATA_END   = .;

  __START_SDATA = .;
        *(.sdata)
  .             = ALIGN (0x10);
  __END_SDATA   = .;

  __SDA_BASE    = .;
  .             = ALIGN(0x10);
 } > sram

 .bss :
 {
  . = ALIGN(0x10);
  __START_SBSS = .;
  *(.sbss)
  *(SCOMMON)
  __END_SBSS   = .;

  . = ALIGN(0x10);
  __START_BSS  = .;
  *(.bss)
  *(COMMON)
  __END_BSS    = .;
        ___BSS_START = __START_SBSS;
        ___BSS_END   = __END_BSS;
        . = ALIGN(0x10);

 } >> sram


 ___FLASH  = ADDR(.vectors);
 ___FLASH_SIZE = 0x0003E000;
 ___SRAM   = ADDR(sram);
 ___SRAM_SIZE = 0x00007C00;

 ___VECTOR_RAM = ADDR(vram);
 ___IPSBAR  = ADDR(.ipsbar);

    ___SP_SIZE      = 0x400;
 ___HEAP_START = .;
 ___HEAP_END  = ___SRAM + ___SRAM_SIZE - ___SP_SIZE;
 ___SP_END  = ___HEAP_END;
 ___SP_INIT  = ___SP_END + ___SP_SIZE;

   ___heap_addr  = ___HEAP_START;
 ___heap_size  = ___HEAP_END - ___HEAP_START ;
 __SP_INIT   = ___SP_INIT;

}



I link fp_coldfire.a, C_4i_CF_Runtime.a and C_4i_CF_MSL.a libraries (tuned with floating point support). And don't forget this document is very useful : C:\Program Files\Freescale\CodeWarrior for ColdFire V6.3\Help\PDF\ColdFire_Build_Tools_Reference.pdf

regards,
Emmanuel
0 Kudos
Reply