How can I use the flash memory of the EFM32 to emulate single variable rewritable EEPROM memory through software?
EEPROM refers to Electrically Erasable Programmable Read-Only Memory and is a type of nonvolatile memory that is byte erasable. Hence, it is often used to store small amounts of data that must be saved when power is removed. The EFM32 MCUs do not include an embedded EEPROM module for byte erasable non-volatile storage, but all EFM32s do provide flash memory for non-volatile data storage.
The main difference between flash memory and EEPROM is the erasable unit size. Flash memory is block-erasable which means that bytes cannot be erased individually. Instead, a block consisting of several bytes need to be erased at the same time. Through software, however, it is possible to emulate individually erasable and rewritable byte memory using block-erasable flash memory.
To provide EEPROM functionality for the EFM32s in an application, there are at least two options available. The first is to include an external EEPROM module when designing the hardware layout of the application. The other is to use the on-chip flash memory and emulate EEPROM functionality through a software API.
There are different ways to implement an EEPROM Emulator using flash memory, but one idea is to allocate a certain number of pages of flash memory for the entire lifetime of the application. To see a software example detailing this along with flash limitations and implementation, read the complete application note here.
How can I read the reset cause register and monitor the supply voltage?
Battery powered devices eventually experience power loss unless the battery is replaced or recharged on a regular basis. It thus becomes essential in such devices to communicate that a power failure is imminent. Some equipment may also require the source voltage to be within a certain range to operate safely. Using the EFM32 Reset Management Unit and the Voltage Comparator, the reset cause register can be read and the supply voltage can be monitored.
The Reset Management Unit (RMU) of the EFM32 monitors the reset lines and ensures reliable operation by resetting the microcontroller if the supply voltage is insufficient or if certain events occur. The RMU also sets the reset cause register which can be used to determine the cause of the last reset at startup. The EFM32 software library contains functions to read and clear the reset cause register.
The voltage comparator (VCMP) helps monitor if the supply voltage reaches a critical level by comparing the supply voltage to an internal bandgap reference. The voltage comparator output can be read from the VCMPOUT bit in VCMP_STATUS.
How do I use the Low Energy UART (LEUART™) module on the EFM32 MCUs?
The EFM32 LEUART is a unique Low Energy UART that offers two-way communication on a very strict power budget - only a 32.768 kHz clock source is needed to allow UART communication up to 9600 baud/s. This means that the LEUART is able to run full UART communication even when the device is in deep sleep mode EM2.
Fig: LEUART two link full duplex connection
The advantage of the LEUART lies in its ability to operate in EM2, while most other modules are turned off for energy conservation. There is an option to enable low energy serial communication in combination with the DMA's ability to read and write from memory without CPU intervention. This offers wide functionality for system designers using the EFM32 in low energy applications.
A wide variety of interrupts are also available to support the low energy advantages of interrupt driven applications. These are available both during receive and transmit. All of these factors and more combine to enable simple and energy friendly communication.
I am unable to connect to an EFM32 device through an STK set to debug mode OUT.
This is a known issue within Simplicity Studio version 3.0, which should be fixed in a future release.
When you start SS, open the SiAgent Monitor view (cmd+3 and type siagent). You should see one siagent entry in the list. Right-click on it and select ‘Prefer for new sessions’. After that you can go detect the part and it should work fine. This forces a single siagent process to do all of the work. The issue is related to a J-Link limitation on Mac and Linux that only a single process can access the J-Link APIs. This workaround forces a single process to do general detection as well as detecting the part, flashing, debugging, etc.
Is it possible to enter a low power mode, such as EM1, immediately after an interrupt completes? In my program, it is undesirable or unnecessary to wait until the program returns to main before going into a low energy mode.
Yes, but this requires setting the Sleep On Exit flag within the SCB module before executing __WFI() or __WFE(). The following code will implement this feature:
The EFM32 TIMER module has many different functions including up/down count, input capture, or output compare. It can be clocked from several sources, both internal and external. The module comes with a 16-bit counter with multiple modes, input capture, output compare, and PWM.
Fig: TIMER Overview
Three different sources can contribute to the clock input for the counter: peripheral high frequency clock (HFPERCLK), compare/capture channel 1 input (TIMn_CC1 pin or PRS channel), or underflow/overflow from the lower numbered neighbor timer. The timer has 5 output events that can trigger an interrupt. Barring the buffer overflow, all events also trigger a PRS Signal and a DMA request:
Compare match, input capture or buffer overflow (one per Compare/Capture channel)
If an interrupt is generated, the interrupt flag can be read from the TIMERn_IF register and cleared by writing TIMERn_IFC.