Issue with floats in VF6xx_A5

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Issue with floats in VF6xx_A5

跳至解决方案
2,674 次查看
n00b1024
Contributor III

Hello,

I'm debugging code written for the Freescale VF6xx_A5, using IAR's EWARM 6.50, and am having an issue with floating point numbers. When I try to assign a non-zero value to a float, the float is automatically assigned a value of zero. For example, test and dac_vref in the code below are set to zero when the debugger steps through those lines.

  double test = 30;

  float dac_vref = 3.3; //3.3 V reference

I've tried messing around with the library configuration options both when writing the program inside and outside MQX 4.0.2, but enabling the full library (vs "normal") options hasn't helped.

Thanks.

标签 (2)
标记 (1)
1 解答
2,191 次查看
juangutierrez
NXP Employee
NXP Employee

Which JTAG are you using?

Maybe is a problem with the JTAG. I mean maybe FPU is fine but can not be inspected with JTAG you are using.

Can you check if the value is really zeroed without inspecting the value. I mean you can try something like

if (test > 0)

    printf("test is not zero\n");

just to check if the value is really zero in the program or is a problem with JTAG or other thing

在原帖中查看解决方案

0 项奖励
回复
11 回复数
2,191 次查看
n00b1024
Contributor III

Cool, thanks!

I've had this problem writing straight to the stack (IAR Systems\Embedded Workbench 6.5\arm\examples\Freescale\VF6xx\TWR-VF600\src\projects\getting_started) as well as with example projects in MQX 4.0.2. Recently, I've been working without MQX. It doesn't seem to make a difference either way.


All of the FPU registers are showing up as 0.0, and they're all initialized to that value when the program gets to main. In the image below (no MQX), I've just finished stepping through the following three lines inside main (osc_freq being a global variable):

  double test = 3.5;

  osc_freq = 7.8125;

  float testing = 3.45;

registers_bare_metal.png

0 项奖励
回复
2,192 次查看
juangutierrez
NXP Employee
NXP Employee

Which JTAG are you using?

Maybe is a problem with the JTAG. I mean maybe FPU is fine but can not be inspected with JTAG you are using.

Can you check if the value is really zeroed without inspecting the value. I mean you can try something like

if (test > 0)

    printf("test is not zero\n");

just to check if the value is really zero in the program or is a problem with JTAG or other thing

0 项奖励
回复
2,191 次查看
n00b1024
Contributor III

Thanks for all your help, Juan! The problem was the (rather old) JTAG.

2,191 次查看
altia_mikey
Contributor III

Hi noob1024,

Sent you a PM, but on the off-chance some-one else sees this thread.

I'm running into the same issue as you.  All FPU registers are showing as "0" (zero) in the FPU registers in IAR EW.

I'm using IAR EW 6.70.x and a yellow IAR branded J-link.

What did you end up doing to solve your issue?  Buy a new debugger probe?  Upgrade your probes' FW?  What probe are / were you using?

Thanks!

Mike

0 项奖励
回复
2,191 次查看
n00b1024
Contributor III

Hi Mike,

Sorry for not getting back to you earlier -- I was out of the office yesterday. I was using a J-link v6 (from 2007) with IAR EWARM 6.50, which was causing the problem. If I use a JTAGjet-Trace-4M, I don't have the problem with the floats.

Do you have the FPU enabled in the project options?

0 项奖励
回复
2,191 次查看
n00b1024
Contributor III

Update: program is debugging correctly in simulator -- I only have the problem with floats getting set to zero when running on the hardware.

0 项奖励
回复
2,191 次查看
juangutierrez
NXP Employee
NXP Employee

I modified a sample in DS-5 and I was able to see the assignation to zero was as expected.

I can see that this values are stored in the VFP unit in double precision registers.

$D8 registers for double test variable and

$D9[31..0] half registers for the float dac_vref

Could you check were this variables are stored in your test? Are they allocated from the VFP unit?

2,191 次查看
juangutierrez
NXP Employee
NXP Employee

I can see this compilation options in my project

-O0 --cpu=Cortex-A5.neon --fpu=vfpv4 --vectorize -g --c99 --split_sections

I guess the one that enables the fpu (floating point unit) to use vfp (vector floating-point unit version 4).

Make sure this option is there.

Not sure if the rest are needed but you can try them too,

0 项奖励
回复
2,190 次查看
juangutierrez
NXP Employee
NXP Employee

I tested in IAR with GettingStarted examples that come with the IAR installation and I was able to see the proper assignation of the variables.

Check the figures attached, where it is seen the values are properly assigned from the FPU.

In this case from $d8 and $S18

Also make sure that in the general options the VFPv4 + NEON are selected as the FPU (which are the default options in the GettingStarted project)

Look at the sample project at IAR Systems\Embedded Workbench 6.5\arm\examples\Freescale\VF6xx\TWR-VF600\src\projects\getting_started.

I just added these two variables and a printf (to avoid optimization throws away these variables) and then inspect them in FPU module.

0 项奖励
回复
2,190 次查看
n00b1024
Contributor III

Hi Juan,

Thanks for the advice. I tried the command-line code, but ran into a compiler error because I'd previously defined the FPU as VFPv4 + NEON and the device as Freescale VF6xx_A5 (as was shown by the image you sent), inside the General Options -> Target of the Project Options.

Using those options, I still see dac_vref and test being assigned to FPU registers ($S16 and $D8) with values of 0.0. However, the interesting thing is that if I declare a float as a global variable, then its value gets stored in OCRAM. I can assign that float a non-zero decimal value either outside a function or inside a function, and the float value will be properly assigned to the variable. However, if I try to declare a float as a local variable, then value is stored inside an FPU register (e.g. S16) and is automatically set to 0.0. I've been checking the values of variables using Watch, have compiler optimization set to none, and have no linker optimization options selected, so I don't think that optimization is deleting those debugging variables.

0 项奖励
回复
2,190 次查看
juangutierrez
NXP Employee
NXP Employee

Hum, that is weird.

The compile option --fpu=vfpv4 I think only applies for DS5 not for IAR. With DS5 I modified an MQX sample but in IAR was not an MQX sample.

Not sure if this can make a difference. In both cases I did not see the issue.

I will try to test it in an MQX sample with IAR and let you know.

Do you see all the $S and $D registers in the FPU as zeros, or only those that were assigned to these variables?

Could you try modifying the IAR Systems\Embedded Workbench 6.5\arm\examples\Freescale\VF6xx\TWR-VF600\src\projects\getting_started NOT MQX sample to see if you can see the problem there.

Do you know which revision are you working with? I tested with a rev 1.0?

0 项奖励
回复