Skip to content
UPEEC

Bare-Metal Programming

Program the microcontroller directly, without an operating system — a super-loop plus interrupts.

Intermediate
Comments 0

A typical bare-metal program:

int main(void) {
    clock_init();
    gpio_init();
    uart_init(115200);
    while (1) {                 // the "super loop"
        read_sensors();
        update_outputs();
        handle_commands();
    }
}

Everything is under your control: startup code, clock setup and register configuration. Simple and predictable, but long tasks in the loop delay everything else — that's when interrupts or an RTOS help.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.