This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I use some complier intrinsics in my code and they work well. I would also like to use the __f32toui16r intrinsic, but it is giving me an error. A simplified version of my code is:
float a = 1.99;
int16_t b = __f32toui16r(a);
I get this message:
INTERNAL ERROR: Illegal use of intrinsic:
__f32toui16r
This may be a serious problem. Please contact customer support with a
description of this problem and a sample of the source files that caused this
INTERNAL ERROR message to appear.
>> Compilation failure
Cannot continue compilation - ABORTING!
Hi Lee,
Are you trying this on the C-compiler(fpu32 support) or the CLA-C compiler? Also what version of the code gen tools are you using?
I've got the same problem and receive the same error message. I am using C compiler and fpu32 support. The compiler version is the latest. v6.1.1 . The help file states that the input variable must be a double. I have tried both float and double variables. But no difference. Does anybody know the remedy?
Regards
I met same issue and get exactly same error message on fpu32 compiler.
My code is as follow :
static U16 doubleToUByte(register double dValue)
{
// Saturate to max unsigned byte value
dValue = __fmin(dValue, 255.0);
return __f32toui16r(dValue);
}
Do you have any idea to solve this error ?
Best regards,
Ok,
I tried this out in two ways with CGT 6.2.0 and I am getting the correct assembly both times. You will see the C code interlisted with the assembly
;----------------------------------------------------------------------
; 101 | float a = 1.99;
;----------------------------------------------------------------------
MOV *-SP[8],#47186 ; [CPU_] |101|
MOV *-SP[7],#16382 ; [CPU_] |101|
.dwpsn file "../Main.c",line 103,column 17,is_stmt
;----------------------------------------------------------------------
; 103 | unsigned int b = __f32toui16r(a);
;----------------------------------------------------------------------
MOV32 R0H,*-SP[8] ; [CPU_] |103|
F32TOUI16R R0H,R0H ; [CPU_] |103|
NOP ; [CPU_]
NOP ; [CPU_]
MOV32 ACC,R0H ; [CPU_] |103|
MOV *-SP[9],AL ; [CPU_] |103|
Second, I tried calling your function:
;----------------------------------------------------------------------
; 104 | unsigned short c = doubleToUByte(a);
;----------------------------------------------------------------------
MOV32 R0H,*-SP[8] ; [CPU_] |104|
LCR #_doubleToUByte ; [CPU_] |104|
; call occurs [#_doubleToUByte] ; [] |104|
MOV *-SP[10],AL ; [CPU_] |104|
;----------------------------------------------------------------------
; 86 | static unsigned short doubleToUByte(register double dValue)
;----------------------------------------------------------------------
;***************************************************************
;* FNAME: _doubleToUByte FR SIZE: 0 *
;* *
;* FUNCTION ENVIRONMENT *
;* *
;* FUNCTION PROPERTIES *
;* 0 Parameter, 0 Auto, 0 SOE *
;***************************************************************
_doubleToUByte:
;----------------------------------------------------------------------
; 88 | // Saturate to max unsigned byte value
;----------------------------------------------------------------------
;----------------------------------------------------------------------
; 89 | dValue = __fmin(dValue, 255.0);
;----------------------------------------------------------------------
MINF32 R0H,#17279 ; [CPU_] |89|
;----------------------------------------------------------------------
; 90 | return __f32toui16r(dValue);
;----------------------------------------------------------------------
F32TOUI16R R0H,R0H ; [CPU_] |90|
NOP ; [CPU_]
NOP ; [CPU_]
MOV32 ACC,R0H ; [CPU_] |90|
LRETR ; [CPU_]
I am unable to recreate the problem. Do you have optimization turned on?