Regards
Giovanni
Update:
I tried to change the struct from float to integer and the code works correctly, variables are at different address in the stack, so the error only appears when using floats.
Regards
Giovanni
Hi Giovanni,
Very sorry for the delay.
Do you have a project example showing the behavior you can share with us ?
the MCU v10.5 has been released last month.
******************************
CodeWarrior for Microcontrollers v10.5 is the last version.
It integrates the development tools for the :
ColdFire®, ColdFire+, DSC, Kinetis, Qorivva, PX, RS08, S08 and S12Z architectures
into a single product based on the Eclipse open development platform.
This version is running on Host platforms
Microsoft® Windows XP 32/64-bit (Business)
Windows Vista 32/64-bit (Business and Home Premium)
Windows 7 32/64-bit (Professional and Home Premium)
Windows 8 32/64-bit (Professional)
You can download an evaluation on the web site:
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=CW-MCU10
I recommend you to sign the news letter for the product.
Via the web site:
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=CW-MCU10
Click on Subscribe
Regards
Pascal
Hi Pascal,
thanks for the answer, I updated CodeWarrior and build a project to show up the bug, I used the Hello word demo project with the main.c that is attached here
This code produce an output like the following, as you can see parameters before calling the function are not zero but inside the function are zero.
If I use a float as a parameters the bug seems to not happen, now to make it work I use a pointer to the struct.
Many thanks for your help
Giovanni
A.X:16838.000000
A.Y:5758.000000
A.Z:10113.000000
B.X:17515.000000
B.Y:31051.000000
B.Z:5627.000000
InnerA.X:0.000000
InnerA.Y:0.000000
InnerA.Z:0.000000
InnerB.X:0.000000
InnerB.Y:0.000000
InnerB.Z:0.000000
/*
* File: hello_world.c
* Purpose: Main process
*
*/
#include "common.h"
typedef struct
{
float X;
float Y;
float Z;
} T_3DCoordFloat;
T_3DCoordFloat Vectors_Sum(T_3DCoordFloat A, T_3DCoordFloat B)
{
/*
printf("InnerA.X:%f\n", A.X);
printf("InnerA.Y:%f\n", A.Y);
printf("InnerA.Z:%f\n", A.Z);
printf("InnerB.X:%f\n", B.X);
printf("InnerB.Y:%f\n", B.Y);
printf("InnerB.Z:%f\n", B.Z);
*/
A.X += B.X;
A.Y += B.Y;
A.Z += B.Z;
return A;
}
/********************************************************************/
void main (void)
{
char ch;
T_3DCoordFloat A;
T_3DCoordFloat B;
printf("\nHello World!!\n");
asm("LDR R0, =0xE000ED88"); //; CPACR is located at address 0xE000ED88
asm("LDR R1, [R0]"); //; Read CPACR
asm("ORR R1, R1, #(0xF << 20)"); //; Set bits 20-23 to enable CP10 and CP11 coprocessors
asm("STR R1, [R0]"); //Write back the modified value to the CPACR
while(1)
{
A.X = rand();
A.Y = rand();
A.Z = rand();
B.X = rand();
B.Y = rand();
B.Z = rand();
printf("A.X:%f\n", A.X);
printf("A.Y:%f\n", A.Y);
printf("A.Z:%f\n", A.Z);
printf("B.X:%f\n", B.X);
printf("B.Y:%f\n", B.Y);
printf("B.Z:%f\n", B.Z);
A = Vectors_Sum(A, B);
printf("Result.X:%f\n", A.X);
printf("Result.Y:%f\n", A.Y);
printf("Result.Z:%f\n", A.Z);
}
}
/********************************************************************/
Hi Giovanni,
Sorry for the delay.
If you think there is a bug in the build tool chain, I recommend you to report the problem under Service Request system.
We need to know exactly the tool version used, the interface, board, etc ...
Regards
Pascal