Skip to content

markfirmware/zig-vector-table

Repository files navigation

CIGitpod Ready-to-Code

It starts at the vector table which specifies the initial stack and the reset entry point. main.zig/[1]Section 2.3.4 Vector table, p37)

export var vector_table linksection(".vector_table") = packed struct {
    initial_sp: u32 = model.stack_bottom,
    reset: EntryPoint = reset,

The reset function prepares memory (copies initial data from flash to ram and sets other data to 0.) It then prepares the uart and timer and displays the up-time every second. main.zig

fn reset() callconv(.C) noreturn {
    @import("generated/generated_linker_files/generated_prepare_memory.zig").prepareMemory();
    Uart.prepare();
    Timers[0].prepare();
    Terminal.clearScreen();
    Terminal.move(1, 1);
    log("https://github.com/markfirmware/zig-vector-table is running on a microbit!", .{});
    var t = TimeKeeper.ofMilliseconds(1000);
    var i: u32 = 0;
    while (true) {
        Uart.update();
        if (t.isFinishedThenReset()) {
            i += 1;
            Terminal.move(2, 1);
            log("up and running for {} seconds!", .{i});

The system is comprised of 256KB of flash and 16KB of ram memories: system_model.zig/[2]Memory Organization, p21

References

[1] Cortex-M0 Devices Generic User Guide

[2] nRF51822 Product Specification

[3] nRF51 Series Reference Manual