AnsweredAssumed Answered

stm32f103rbt6 - loss the value of variable

Question asked by karol.karol on Sep 18, 2016
Hi,
I have a strange problem. If I write code like this:

#include "stm32f10x.h"
 
float test;
 
int main(void) {
 while (1) {
  test=test+0.01;
 }
}

and display variable test in STM Studio I see that this var go to value about 2,500 and after that sets to 0 and again in loop. If I write that code:

#include "stm32f10x.h"
 
int test = 0;
 
int main(void) {
test = 0;
 while (1) {
  
 }
}

and try change a var by STM Studio to for example 2, I see the value 2 about 0,5s, after that it sets to 0. It is strange for me and I dont understand it. Where is the problem? I use CooCox.

Outcomes