Dear Sir
K60 microcontroller has inbuit FPU, So it support floating point instuction by hard ware itself rather than softcode
I am using KDS for K60 and i using sqrtf() function in .list file it shows software root function. as below
**** | b_out = sqrtf(a); | ||
82 | .loc 1 82 0 discriminator 1 | ||
83 0036 40F20003 | movw | r3, #:lower16:a | |
84 003a C0F20003 | movt | r3, #:upper16:a | |
85 003e D3ED007A | flds | s15, [r3] | |
86 0042 B0EE670A | fcpys | s0, s15 | |
87 0046 FFF7FEFF | bl | sqrtf | |
88 004a F0EE407A | fcpys | s15, s0 | |
89 004e 40F20003 | movw | r3, #:lower16:b_out | |
90 0052 C0F20003 | movt | r3, #:upper16:b_out | |
91 0056 C3ED007A | fsts | s15, [r3] | |
83:../Sources/main.c **** | timecount = timecount+1.2; |
1.can somebody say how to invoke floting instuction ?
2. is possible to do square root by excecuting sqrt hardware instruction? if yes then how.
In the compiler settings, make sure you have these options set:
Erich
Hi
As i was using KDS but because all this problem again i started to use CW10.6 with GCC compiler instead of freescale compiler
In this case float multiplication is generting Instruction like only with "f" only with GCC compiler.
.loc 1 134 0
flds s15, [r5, #0]
fmuls s14, s15, s17
fcpys s0, s16
fmacs s0, s15, s14
movw r2, #:lower16:.LANCHOR1
movt r2, #:upper16:.LANCHOR1
fsts s0, [r2, #0]
but in freescale compiler , it was generating with starting of "V" like vmov.F32
so the above instruction instruction with starting of "f" like fcpys is correct ????
but still it is generating instruction both fsqrt and also branch of sqrt like follow
138:../Sources/main.c **** | dummy_float = sqrtf(dummy_float); | ||
181 | .loc 1 138 0 | ||
182 0078 F1EEC00A | fsqrts | s1, s0 | |
183 007c F4EE600A | fcmps | s1, s1 | |
184 0080 F1EE10FA | fmstat | ||
185 0084 03D0 | beq | .L4 | |
186 0086 FFF7FEFF | bl | sqrtf | |
187 | .LVL14: | ||
188 008a F0EE400A | fcpys | s1, s0 | |
189 | .L4: | ||
190 008e 40F20003 | movw | r3, #:lower16:.LANCHOR1 | |
191 0092 C0F20003 | movt | r3, #:upper16:.LANCHOR1 | |
192 0096 C3ED000A | fsts | s1, [r3, #0] |
so in above instruction sqrt is executing with FPU or it is software execution.
Please Help
There are option of setting FPU type whether hard or soft in KDS but if i set "Toolchaing default" then it is taking as software and generating branch and software code without any FPU instrucation and not giving any error
but I set as
mfloat-abi=hard
mfpu=fpv4-sp-d16
from project setting then while running it is giving Hard fault and haging at
PE_ISR(Cpu_Interrupt)
{
/* This code can be changed using the CPU component property "Build Options / Unhandled int code" */
PE_DEBUGHALT();
}
but same thing i tried in CW10/6 it is working and it generate FSQRTS instruction.
Please help to sort out issue of KDS.
Thanks and regards
Bipin
It looks like you have not enabled the floating point unit?
Add this code to your application
void vPortEnableVFP(void) {
/* The FPU enable bits are in the CPACR. */
__asm volatile (
" ldr.w r0, =0xE000ED88 \n" /* CAPCR, 0xE000ED88 */
" ldr r1, [r0] \n" /* read CAPR */
" orr r1, r1, #(0xf<<20) \n" /* enable CP10 and CP11 coprocessors */
" str r1, [r0] \n" /* store to new value back */
: /* no output */
: /* no input */
: "r0","r1" /* clobber */
);
}
and call it in main() as the first thing.
Erich