EFM32 funktioniert nur mit "breakpoint" richtig.

Gast #4283238
Lesenswert?

Abend.
Ich habe STK3400 (HappyGecko).
Mein Projekt ist recht simpel.
MIt dem MCU messer ich die Temperatur mit dem TMP006 infrarot Sensor 
(I2C).

Der Gecko schläft ca. 1s, wacht auf, misst, falls die Temperatur über 28 
Grad ist geht die LED an, sonst aus.
Leider funktioniert das ganze nur im Debug Mode, und nur, wenn ich bei 
"if(Temp>28)-Abfrage" oder drunter ein breakpoint setze.Nehme ich diesen 
Breakpoint weg, geht das Programm nicht.
Auch ohne debugger funktioniert es nicht. Komische Sache.

Für die Hilfe wäre ich dankbar;)
Hier ist der Code:
1
int main(void)
2
{
3

4

5
  CHIP_Init();
6
  CMU_OscillatorEnable(cmuOsc_HFRCO,1,0);
7
  CMU_ClockEnable(cmuClock_HFPER, true);
8
  CMU_ClockEnable(cmuClock_GPIO,1);
9
  CMU_ClockEnable(cmuClock_I2C0,1);
10
  CMU_ClockEnable(cmuClock_RTC, true);
11

12
  CMU_OscillatorEnable(cmuOsc_LFRCO, true, 0);
13
  CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFRCO);
14
  CMU_ClockEnable(cmuClock_LFA,true);
15
  CMU_ClockEnable(cmuClock_CORELE ,true);
16

17
  ///////I2C////////////////////////////
18
  GPIO_PinModeSet(gpioPortD, 7, gpioModeWiredAndPullUpFilter, 1);
19
  GPIO_PinModeSet(gpioPortD, 6, gpioModeWiredAndPullUpFilter, 1);
20
  I2C0->ROUTE = I2C_ROUTE_SDAPEN | I2C_ROUTE_SCLPEN | (1 << _I2C_ROUTE_LOCATION_SHIFT);
21
  GPIO_PinModeSet(gpioPortC, 8, gpioModePushPull , 1);
22
  GPIO_PinOutClear(gpioPortC,8);
23
  I2C_Init(I2C0,&I2INIT);
24
  ////////////////RTC config//////////////
25
  RTC_Init(&RTCINI);
26
  RTC_CompareSet(0, 30000);
27
  RTC_IntEnable(RTC_IFC_COMP0);
28
  RTC_Enable(true);
29
  GPIO_PinModeSet(5,5,gpioModePushPull,0);//test led
30
  GPIO_PinModeSet(0,2,gpioModeInput ,0);//RDY
31
  while (1)
32
  {
33
   NVIC_EnableIRQ(RTC_IRQn);
34
   powerup();// der Sensor wird aktiviert
35
   while(GPIO_PinInGet(0,2)==1){}// wait till data ready to read
36
   measureTemp();//Misst die Temperatur 
37

38
   if(Temp>28)
39
     {
40
      GPIO_PinOutSet(5,5);
41
        }else{
42
      GPIO_PinOutClear(5,5);
43
     }
44
     powerdown();// der Sensor geht in Stand By
45
  EMU_EnterEM2(1);
46
}
47
}
48
///RTC Interrupt
49
void RTC_IRQHandler(void) {
50
    RTC_IntClear(RTC_IFC_COMP0);
51
    RTC_CompareSet(0, 30000);
52
    RTC_IntEnable(RTC_IFC_COMP0);
53

54
}
#4283272
Lesenswert?

Der Debugger deaktiviert den EM2 (MCU geht in nur EM1). Das macht 
manchmal Probleme, wenn die Clocks nicht korrekt für EM2 aufgesetzt 
sind.

Eventuell gibt es auch Timing Probleme bei Powerup oder -down. Für die 
Diagnose bräucht man aber einen Schaltplan und den Rest des Source Code.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren