Part Number: TMS320F280049
Tool/software: Code Composer Studio
Hi Team,
I am new to CCS, while running the code shown below I got the results for my variable R_rtd and Cabin_Temp came wrong after calculation. What might be gone wrong here. All I see a not so complex calculation.
int32 r1 = 0x00000000; int32 r2 = 0x00000000; float32 Cabin_Temp; // Cabin Temperature float32 R_rtd; // Resistance of RTD
This is the declaration part and following is the calculation part
r1 = SpiaRegs.SPIRXBUF;
r1 = SpiaRegs.SPIRXBUF;
r1 = r1<<8;
r2 = SpiaRegs.SPIRXBUF;
r1 = r1|r2>>8;
R_rtd = (r1*1080)/(4194304*16); // RTD resistance, R_rtd = (r1*R_ref)/(2^22*Gain)
Cabin_Temp = ((R_rtd/100)-1)/(0.00385); // Cabin temperature, Cabin_temp = ((R_rtd/RO)-1)/alpha
I am expecting an answer R_rtd close to 100 and Cabin_Temp close 0.2, instead it is showing random negative values.
Please help me out
Best Regards,
Vineeth N