We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
The following code, simple as it is, fails to work. I suspect it's a brain short on my part, and willingly accept the public humiliation. Perhaps it's an actual problem that I am just now uncovering. I am new to the toolset, so all bets are off. The tool is a bit on the dated side. Perhaps there is an update that I'm missing.
TIA for any help.
John
IDE-Version: µVision V4.72.10.0 Copyright (C) 2013 ARM Ltd and ARM Germany GmbH. All rights reserved.
Tool Version Numbers: Toolchain: MDK-ARM Standard Cortex-M only Version: 4.72.1.0 Toolchain Path: C:\Keil\ARM\ARMCC\bin\ C Compiler: Armcc.Exe V5.03.0.76 Assembler: Armasm.Exe V5.03.0.76 Linker/Locator: ArmLink.Exe V5.03.0.76 Librarian: ArmAr.Exe V5.03.0.76 Hex Converter: FromElf.Exe V5.03.0.76 CPU DLL: SARMCM3.DLL V4.72.1.0 Dialog DLL: DARMP1.DLL V1.22.0.11 Target DLL: UL2CM3.DLL V1.150.11.0 Dialog DLL: TARMP1.DLL V1.22.0.11
float gain; float fTemp; uint32_t lTemp; uint16_t temp; // On entry, gain is 27.893 fTemp = gain * 1000.0; // gain - preserve three decimal places // fTemp now 27893.0 lTemp = (uint32_t)fTemp; // lTemp now 0x6C5F (27743, while I expect 27893) temp = lTemp & 0xFFFF; // temp now 27743 // WTH?