Event Logging in Embedded Systems

Typically, in an SBC operating with an RTOS, it would be an easy task to write data / event logs to external media such as SD cards. However, in embedded systems that use a microcontroller, for example, PICs have limited data / program memory. Although some chipsets have support for external media, which means that no, how can I enter the MCU?

The only plausible way I could think of is to write it in the MCU EEPROM, but is this possible? If this can be done, how would you write and read?

+7
source share
4 answers

Logging can be performed on any memory device, including SD cards (subject to the availability of appropriate peripheral equipment). If an external device is connected to the serial port, you can write data to it.

Typically, events are recorded only in exceptional cases. Writing to EEPROM or Flash (for newer devices) is relatively slow, consumes energy and uses finite resources (spaces and erasures).

For debugging, use the regular port (or the SWO port on the Cortex-M3).

+2
source

You can implement a logger that simply writes a byte to an array every time you want to log an event. The log list can then be retrieved and converted to a user-friendly event list. This approach has the advantage of being less intrusive for real-time applications.

I used this approach for an application where 100-200 events were generated in a 1-2 minute test session. This list was then downloaded via the serial port and analyzed using a small Python script.

+2
source

Depending on your data needs, you can either upgrade to an SPI flash or EEPROM I²C.

I2C EEPROMS is smaller in storage capacity, but its interface is available on most microcontrollers (if not, it is relatively easy to do this in software with conventional IO pins), and they are much slower (mainly due to the I2C bus which is limited to 1 MHz). It is easy to find them up to 1mb in capacity and with 8DIP packaging.

SPI flashes are faster, denser, and often cheaper, so if you need faster recording and, frankly, better technology, you should follow them .

+1
source

You can usually output data to UART and record or display it in a terminal emulator, such as TeraTerm (or HyperTerminal, if necessary).

If you implement a ring buffer and an ISR for UART filing, this will have minimal impact on system behavior at runtime unless you exceed port throughput for extended periods of time. It probably has a lower system impact and is more deterministic than writing to EEPROM or Flash, especially if the UART has FIFO or DMA capabilities, and although bandwidth can be limited, it has the advantage of almost unlimited capacity.

Your chip may have built-in debugging features that can be associated with a host debugger with arbitrary debugging output or the possibility of semi-hosting. This will have minimal impact at runtime.

+1
source

All Articles