[Icc-mot] fround problem / fp conversion

Edward Karpicz ekarpicz at freemail.lt
Wed Jan 23 03:20:48 PST 2008


Both get_pressure2() variants seem to work me :-(. Do you have

#include <math.h>

in your code?


Regarding your own fround:

signed long fround(float data_in)
{
signed long data_out;
if (data_in>0)
{
    data_out=(signed long)(data_in+0.5);
}
return data_out;
}

1) when data_in is negative or zero, data_out is undefined
2) if you included math.h, then it should complain  about redefining fround. 
fround should return float, not signed long. BTW is fround a standard C 
function?
3) without valid fround prototype you not only should get a warning about 
missing prototype, but also it's expected to hang. Functions returning longs 
and floats, such functions are pushing return value to the stack. Callee has 
to pull return value from stack. Without valid prototype, any function is 
assumed to be defined as int foo(int). It wouldn't hang if fround was 
returning int/short/char/void and signed variants of <=16bits wide return 
types.

Also, is include path pointing to V7 include folder?

Edward



----- Original Message ----- 
From: "Rene Streubel" <r.streubel at emtec-papertest.de>
To: <icc-mot at imagecraft.com>
Sent: Wednesday, January 23, 2008 12:19 PM
Subject: [Icc-mot] fround problem / fp conversion


I tried to reduce the function:
If the function have to round an unsigned value, so it is OK:

signed int get_pressure2(unsigned char p_ch)
{
return froundf(abs(-101.85));
}

But, if the function have to round a signed value, it crashes:

signed int get_pressure2(unsigned char p_ch)
{
return froundf(-101.85);
}

I checked my Program Memory. I had a mistake in my email. The correct 
settings in my project are:
Program Memory: 0x4000.0x7FFF:0xC000.0xEFFF
My complete program needs pages 20..23 Is there a problem with the memory 
mapping?

I wrote about my own fround function and that it crahes with the if 
statement inside.
There is the same thing. If it is signed in the if statement it crashes. 
Without the if statement it not crashes. I think there is a problem with the 
signed fp conversion / emulation.

Richard wrotes about the 7.03 Beta0 and that the compiler did not generate 
calls to "uint2fp" for unsigned to FP conversion. Maybe there is now a new 
bug with any conversion?

What should I do?

Rene



-----Original Message-----
From: icc-mot-bounces at imagecraft.com [mailto:icc-mot-bounces at imagecraft.com] 
On Behalf Of icc-mot-request at imagecraft.com
Sent: Tuesday, January 22, 2008 9:01 PM
To: icc-mot at imagecraft.com
Subject: Icc-mot Digest, Vol 41, Issue 4

Send Icc-mot mailing list submissions to
icc-mot at imagecraft.com

To subscribe or unsubscribe via the World Wide Web, visit
http://dragonsgate.net/mailman/listinfo/icc-mot
or, via email, send a message with subject or body 'help' to
icc-mot-request at imagecraft.com

You can reach the person managing the list at
icc-mot-owner at imagecraft.com

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Icc-mot digest..."


Today's Topics:

   1. Re: RE: Icc-mot Digest, Vol 41, Issue 2 (Edward Karpicz)


----------------------------------------------------------------------

Message: 1
Date: Tue, 22 Jan 2008 10:53:17 +0200
From: "Edward Karpicz" <ekarpicz at freemail.lt>
Subject: Re: [Icc-mot] RE: Icc-mot Digest, Vol 41, Issue 2
To: "Discussion List for ICC08/11/12/16 users. You do NOT need
tosubscribe toicc-announce if you are a member of this."
<icc-mot at imagecraft.com>
Message-ID: <000601c85cd4$3b6c6200$0400a8c0 at edvardo>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
reply-type=original

Rene,

I tried both, your get_pressure function (except aduconv is undefined) and
your own fround. And these seem being working. Did you try to reproduce this
problem in some simpler program? Maybe fround chokes on some special values?
What arguments you are passing to fround?

You say it was OK using V6 to call fround from interrupt. Using FP from
both, interrupts and main thread, or using preemptive RTOS and FP in
different tasks, you had to save/restore FP context. Using V7 you don't have
to save/restore FP context since V7 FP emulation doesn't use static
variables and is reentrant.

I don't know if it matters but I see a type in your settings:

Program Memory: 0x4000.0x7FFF:**0xC00**.0xEFFF

Edward


----- Original Message ----- 
From: "Rene Streubel" <r.streubel at emtec-papertest.de>
To: <icc-mot at imagecraft.com>
Sent: Monday, January 21, 2008 3:52 PM
Subject: [Icc-mot] RE: Icc-mot Digest, Vol 41, Issue 2


Problem with fround and/or fp conversion in ICC12 V7.03B

Hello!

I converted a project from ICC V6 to V7 and have now the following problems.
I use a HCS12DP512. In V6 all works well.
Now the programm crashes (hang up) during the use of the "fround" function.
for example:

#define p_runden 16
#define psi_to_mbar 68.948
#define ad_lsb  4.8828125

signed int get_pressure(unsigned char p_ch)
{
    unsigned int i,i_temp;
    i_temp=0;
    for (i=0 ;i<p_runden ;i++)
    {
        i_temp+=aduconv(p_ch);
    }
    return
fround(psi_to_mbar*15.0*((ad_lsb*(double)i_temp/p_runden)-500.0)/4000.0);
}

If i dont use fround in the last line, the program works well, but if i use
fround, it crashes.
[return (psi_to_mbar*15.0*((ad_lsb*(double)i_temp/p_runden)-500.0)/4000.0);]

In V6 it works.

This function also is called from the "TimerOverflowInterrupt" If i call the
function outside the interrupt it works well. But in V6 it also worked in
the TOF.

What is new in the V7 "fround" function? Takes it more time then in V6? What
can i do? I have also problems in other routines, if i use the
fround-function.

My target device settings are:

Program Memory: 0x4000.0x7FFF:0xC00.0xEFFF
Data Memory: 0x800.0x3600
Stack Pointer: 0x3E00
ExpandedMemory enabled Addr: 0x80000.0xFEFFF
Make Paged Functions Default is enabled
Linear S2 Record Type
CPU Type HCS12
Printf Version: float


____________________________________________________________________________

I try my own fround function and found another problem:

This function did not work: The program crashes and is hang up!
signed long fround(float data_in)
{
signed long data_out;
if (data_in>0)
{
    data_out=(signed long)(data_in+0.5);
}
return data_out;
}
Without the "if" statement it works well and does not crash!
signed long fround(float data_in)
{
signed long data_out;

{
    data_out=(signed long)(data_in+0.5);
}
return data_out;
}

Please help,
Otherwise I cant use the new ICC12V7.

Regards

Rene




--------------------------------------------------
René Streubel
Research & Development Emtec Electronic GmbH / Germany
E-mail: r.streubel at emtec-papertest.de






-----Original Message-----
From: icc-mot-bounces at imagecraft.com [mailto:icc-mot-bounces at imagecraft.com]
On Behalf Of icc-mot-request at imagecraft.com
Sent: Wednesday, January 16, 2008 10:01 PM
To: icc-mot at imagecraft.com
Subject: Icc-mot Digest, Vol 41, Issue 2

Send Icc-mot mailing list submissions to
icc-mot at imagecraft.com

To subscribe or unsubscribe via the World Wide Web, visit
http://dragonsgate.net/mailman/listinfo/icc-mot
or, via email, send a message with subject or body 'help' to
icc-mot-request at imagecraft.com

You can reach the person managing the list at
icc-mot-owner at imagecraft.com

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Icc-mot digest..."


Today's Topics:

   1. ICC12 7.03B BETA0 (Richard Man)


----------------------------------------------------------------------

Message: 1
Date: Tue, 15 Jan 2008 18:59:02 -0800
From: Richard Man <richard at imagecraft.com>
Subject: [Icc-mot] ICC12 7.03B BETA0
To: icc-mot at imagecraft.com
Message-ID: <200801160313.m0G3DxVQ055832 at dragonsgate2.imagecraft.com>
Content-Type: text/plain; charset="us-ascii"; format=flowed

Just a minor update to fix missing unsigned to FP conversion code:
http://www.imagecraft.com/pub/iccv712_v703b_beta0.exe

V7.03B - Jan 20th, 2008
   Compiler
     - 7.03A did not generate calls to "uint2fp" for unsigned to FP
       conversion
   Header Files
     - the DP512 header file was incorrect.


// richard <http://www.imagecraft.com/>
<http://www.dragonsgate.net/mailman/listinfo> On-line orders,
support, and listservers available on web site.
[ For technical support on ImageCraft products, please include all
previous replies in your msgs. ]



------------------------------

_______________________________________________
Icc-mot mailing list
Icc-mot at imagecraft.com
http://dragonsgate.net/mailman/listinfo/icc-mot


End of Icc-mot Digest, Vol 41, Issue 2
**************************************



_______________________________________________
Icc-mot mailing list
Icc-mot at imagecraft.com
http://dragonsgate.net/mailman/listinfo/icc-mot




------------------------------

_______________________________________________
Icc-mot mailing list
Icc-mot at imagecraft.com
http://dragonsgate.net/mailman/listinfo/icc-mot


End of Icc-mot Digest, Vol 41, Issue 4
**************************************



_______________________________________________
Icc-mot mailing list
Icc-mot at imagecraft.com
http://dragonsgate.net/mailman/listinfo/icc-mot




More information about the Icc-mot mailing list