AnsweredAssumed Answered

Flash emulation problem when using debugger

Question asked by ionut.fasola on Nov 25, 2016
1.My code behaves in a strange way when using debugger. (CooCox IDE)(STM32F030C8)

If I step to each function , after stepping   EE_Init() function the code seems to be stucked in a loop  ;in disassembly view it executes the same instruction without going to the next one (ldr r3, [pc, #116] ).

Now if I put a breakpoint at another line after the  EE_Init() function and run the code from the beginning up to that breakpoint without stepping through each function , the code reaches that breakpoint and it seems to run normally.

It is strange for me because I have used Flash EEprom emulation before and I did not came across this.

The code is more complex but due to strange behaviour I eliminated from it until I found what seems to be error source.
01.int main(void)
02.{
03. 
04.    __enable_irq();
05.    u8 i=0;
06.    adc_config();
07. 
08.    FLASH_Unlock();          //Unlock the Flash Program Erase controller
09.    EE_Init();
10.    //FLASH_Lock();
11.#ifdef DEBUG072
12.    DAC_Setup();
13.#endif
14. 
15. 
16.    intern_ee_set_u16(UminThresholdAddress,16);
17.      u16 temp=0;
18.      temp=intern_ee_get_u16(UminThresholdAddress);
19. 
20.    intern_ee_set_u16(UminThresholdAddress,4);
21. 
22. 
23.      temp=intern_ee_get_u16(UminThresholdAddress);
24.      temp=0;
25.  while (1)
26.  {
27.      if(SW1Status==DISABLE)
28.          {
29.              SW2Status=3;
30.          }
31.      temp=intern_ee_get_u16(UminThresholdAddress);
32.      if (temp==4)
33.      {
34. 
35.          SW3Status=ENABLE;
36.      }
37.      else
38.      {
39.          SW3Status=DISABLE;
40.      }
41.      temp=0;
42.  }
43.}

Outcomes