Building Better Medical Devices by Solving Embedded Data Challenges
After the Alarm, Can Your Medical Device Tell the Whole Story?
An infusion pump reports an operational interruption. Moments later, it loses power. When the device restarts, a service engineer finds an alarm code. To investigate, the engineer needs to know which operating mode was active, which configuration was loaded, and whether the last sensor readings were valid. If those details live in separate logs or disappear during a restart, reconstructing the event can take longer than reproducing the fault.
A useful diagnostic history starts with the questions someone will need to answer after an event. For a pump, that could mean preserving four pieces of context together.
What to record | What it helps explain |
|---|---|
Event code, boot identifier, and event sequence | What happened and where it fits in the device’s history |
Operating state and relevant sensor readings, with quality flags | What the device observed and whether those readings were usable |
Configuration revision and firmware build | Which settings and software were active when the event occurred |
Timestamp and clock validity | Whether the event can be correlated with other records by wall-clock time |
The application assigns measured speed and load to configuredCapture these fields when the event is detected. If a background task reads the current state a few milliseconds later, the device may already have changed modes. The resulting record could describe the state after the event. A fixed-size snapshot passed to a logging task preserves the association and gives the engineering team a clear place to specify what happens when the queue fills. Collect only the diagnostic fields the product requirements justify.
An MCU like STM32H573I-DK provides a development target for prototyping this design on STM32H5. ITTIA DB Lite, the microcontroller database in the ITTIA DB Platform, provides transactional storage for the event and its associated context. The firmware defines what belongs in the snapshot and when to capture it. The database groups the corresponding records in one transaction.
Make the event and its context survive together
Suppose the firmware stores an event header and a separate sensor snapshot. If power drops between the two writes, a service tool could find the alarm and have no way to tell which readings went with it. A transaction gives both writes a shared commit point. The verification objective is concrete. After restart and recovery, a lookup by event ID should find either both records or neither, depending on whether the transaction committed.
Save the event and its context with the ITTIA DB Lite table API
The C example below shows the application-side logging function for an STM32CubeH5 project built with ITTIA DB Lite. Define two tables with the same composite primary key:
CREATE TABLE event_header (
boot_id UINT32 NOT NULL,
event_sequence UINT32 NOT NULL,
event_code UINT32 NOT NULL,
config_revision UINT32 NOT NULL,
firmware_build UINT32 NOT NULL,
timestamp_ms UINT64 NOT NULL,
clock_valid BOOLEAN NOT NULL,
PRIMARY KEY (boot_id, event_sequence)
);
CREATE TABLE event_snapshot (
boot_id UINT32 NOT NULL,
event_sequence UINT32 NOT NULL,
operating_state UINT32 NOT NULL,
motor_current_ma SINT32 NOT NULL,
current_valid BOOLEAN NOT NULL,
PRIMARY KEY (boot_id, event_sequence)
);Generate the table API with ittiadb codegen medical_event --schema-file=medical_event_schema.sql. Add medical_event_database.h, medical_event_database.impl.h, and medical_event_database.c to the project, and compile the generated C source with the application. The generated header provides the row types and insert_event_header() and insert_event_snapshot() functions used below.
Before logging, initialize ITTIA DB Lite and the target storage medium, call open_medical_event_database() with the platform's persistent-storage configuration, and obtain a task-local connection with db_connect(). Reopen existing storage after reset rather than overwriting it. A single background logging task passes that connection, without an active transaction, and an immutable snapshot captured when the event was detected:
#include "medical_event_database.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
typedef struct {
uint32_t boot_id; /* Unique across retained boots */
uint32_t sequence; /* Unique within this boot */
uint32_t event_code;
uint32_t operating_state;
uint32_t config_revision;
uint32_t firmware_build;
uint64_t timestamp_ms;
bool clock_valid;
int32_t motor_current_ma;
bool current_valid;
} DeviceEvent;
typedef enum {
EVENT_SAVED,
EVENT_WRITE_FAILED,
EVENT_COMMIT_UNCONFIRMED,
EVENT_RECOVERY_REQUIRED
} EventResult;
EventResult persist_device_event(db_t db, const DeviceEvent *event)
{
if (event == NULL)
return EVENT_WRITE_FAILED;
event_header_row_t header = {
.boot_id = event->boot_id,
.event_sequence = event->sequence,
.event_code = event->event_code,
.config_revision = event->config_revision,
.firmware_build = event->firmware_build,
.timestamp_ms = event->timestamp_ms,
.clock_valid = event->clock_valid
};
event_snapshot_row_t snapshot = {
.boot_id = event->boot_id,
.event_sequence = event->sequence,
.operating_state = event->operating_state,
.motor_current_ma = event->motor_current_ma,
.current_valid = event->current_valid
};
/* This function owns the transaction; reject an already active one. */
if (DB_FAIL == db_begin_tx(db, DB_TX_READ_WRITE))
return EVENT_WRITE_FAILED;
/* Generated table inserts join this transaction. Duplicate keys fail
* instead of replacing a previously recorded event. */
dbstatus_t status = insert_event_header(db, &header);
if (DB_SUCCESS(status))
status = insert_event_snapshot(db, &snapshot);
if (DB_FAILED(status)) {
if (DB_FAIL == db_abort_tx(db, DB_DEFAULT_COMPLETION))
return EVENT_RECOVERY_REQUIRED;
return EVENT_WRITE_FAILED;
}
if (DB_FAIL == db_commit_tx(db, DB_DEFAULT_COMPLETION))
return EVENT_COMMIT_UNCONFIRMED;
return EVENT_SAVED;
}Build the evidence behind certifiability
Certifiability starts with a claim the engineering team can test. For example, after recovery from an interruption during an event transaction, the service interface shall never return an event header without its matching snapshot. That requirement gives testers an observable outcome and gives reviewers a direct link between the storage design and its verification evidence.
IEC 62304 provides a framework for medical-device software lifecycle processes. ISO 14971 defines a process for identifying hazards, evaluating risks, implementing controls, and monitoring their effectiveness. If the device’s risk analysis identifies event integrity as relevant to a risk control, the manufacturer can trace that control to a software requirement, the database integration design, and verification results from the target.
Verification scenario | Evidence to capture |
|---|---|
Cut power between the header and snapshot writes | Recovery logs and a query showing the incomplete transaction is absent |
Cut power around commit | Results across repeated trials showing either a complete record or no record, with no duplicate event key after recovery |
Fill storage or saturate the logging queue | The configured failure response, how record loss is surfaced, and measured impact on control timing |
Change the firmware or invalidate the clock | Evidence that older records retain their original firmware and configuration identifiers, and that invalid wall-clock time is flagged |
For the ITTIA DB Platform, the certifiability value is a transactional storage component with behavior the device team can define, exercise, and document. Record the ITTIA DB Lite version, firmware build, STM32H5 target, storage medium, and relevant configuration with the test results. That ties each result to a reproducible device build. The manufacturer owns the risk analysis, integration verification, and conformity assessment for the complete device.
Bring your event schema and recovery requirements to ITTIA
Request an STM32H5 evaluation or meet with an embedded data specialist to discuss how ITTIA DB Lite can support your diagnostic history and verification plan.