Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 6 months ago.
LPC1768 not update variables
Hi community! I have this code:
include the mbed library with this snippet
int Type; int DutyCycle; float Factor; float Frequency; float Amplitude; int main() { Dbg.printf("Type: %d",&Type); Dbg.printf("Duty cycle: %d",&DutyCycle); Dbg.printf("Factor: %.2f",&Factor); Dbg.printf("Frequency: %.2f",&Frequency); Dbg.printf("Amplitude: %.2f\n",&Amplitude); Type = 0; DutyCycle = 0; Factor = 0.0; Frequency = 0.0; Amplitude = 0.0; Dbg.printf("Type: %d",&Type); Dbg.printf("Duty cycle: %d",&DutyCycle); Dbg.printf("Factor: %.2f",&Factor); Dbg.printf("Frequency: %.2f",&Frequency); Dbg.printf("Amplitude: %.2f\n",&Amplitude); ...
When I launch the firmware and TeraTerm for diagnose the values aren't zero but the int values are at the maximum integer value why?
I have tried to initialized variables on declaration but the result is the same
posted by Davide Luongo 14 May 2015Hi Davide, Remove the '&' from the variable names The '&' would tell the Compiler to print out the ADDRESS of the variable not the contents of the address that is the data that you wish to retreive. This is true for all C compilers
Regards Martin
posted by Martin Simpson 14 May 2015