Galwa07
Galwa07

Reputation: 1

interrupt every x seconds EFM32G (C)

I working with EFM microcontroller (Silicon Labs) I need to make a beep every x seconds, when the device in EM3 mode. I tried so many ways without success.

Please try to help me with code example (I'm HW man, not a SW haha)

Thanks, Gal.

Upvotes: 0

Views: 95

Answers (1)

Refer to page 8 on the datasheet (thanks to @user694733)

EM3 mode description:

still full CPU and RAM retention, as well as Power-on Reset, Pin reset and Brown-out Detection, with a consumption of only 0.6 μA. The low-power ACMP, asynchronous external interrupt, PCNT, and I2C can wake-up the device.

So these are your options. One of these things can wake up the microcontroller. All of them are external inputs. So the microcontroller cannot wake itself up in this mode. This makes sense because all clocks are stopped.

If you had an outside clock connected to the PCNT you could use that to wake it up.

If you want the microcontroller to wake itself up, then you need EM2 mode or less:

In EM2 the high frequency oscillator is turned off, but with the 32.768 kHz oscillator running, selected low energy peripherals (LCD, RTC, LETIMER, PCNT, LEUART, I2C, WDOG and ACMP) are still available

In EM2 mode the microcontroller may wake itself up using the RTC (real-time clock), LETIMER (low-energy timer), WDOG (watchdog timer) or PCNT (pulse counter, which can be set to count pulses of the 32.768kHz clock).

The datasheet recommends using the Real-Time Clock or Low Energy Timer (RTC or LETIMER) modules.


... however, if we pay attention, we see the datasheet mentions something called the ULFRCO, Ultra-Low-Frequency RC Oscillator, which runs at approximately 1000 Hz. By searching for the keyword ULFRCO, we see that it does still run in EM3 mode, and it can be used as input for the WDOG. On page 89 we see this listed as a feature of EM3 mode.

So, you may configure the WDOG to reset the system after a few seconds. When the microcontroller resets due to watchdog timeout, it wakes up. You should not be afraid of using a system reset. The RMU_RSTCAUSE allows you to see that the system was reset because of the watchdog timer (not because it was first turned on or the reset pin was used). Memory contents are probably still there, but all peripherals are reset. As long as you can deal with peripherals being reset, you can probably make this work. You might even be able to use a little bit of assembly programming to jump back to exactly the point where the program left off.

Upvotes: 2

Related Questions