Direct Hardware Access in C
March 20, 2023 (baremetal,C,articles,interrupts,timer)
This article was also posed to Medium.
The C programming language provides a thin hardware abstraction that allows us to create low-level systems programs. However, there are still many hardware features that aren’t exposed by the programming language. How do we access hardware while programming in C?
This article covers some tricks used to write low-level code in C and build a simple bare-metal run-time environment. The target hardware is a RISC-V RV32I in machine mode. The RISC-V is a simple architecture well suited to understanding low-level programming, and a small 32-bit core is ideal for applications that benefit from bare-metal programming.
A Baremetal Introduction using C++. Interrupt Handling.
May 06, 2021 (baremetal,C++,interrupts)
What are the basics of interrupt handing in RISC-V? Can we utilize modern C++ to simplify the interrupt handling?
A Baremetal Introduction using C++. Machine Mode Timer.
May 05, 2021 (baremetal,C++,timer)
This is the sixth post in a
series,
about the RISC-V machine mode timer and timing keeping using the C++
std::chrono
library.
A Baremetal Introduction using C++. System Registers.
May 03, 2021 (baremetal,C++,csr)
What are system registers in RISC-V? How can we access them with modern C++?
System registers require special instructions to access, so unlike memory mapped registers (MMIO) we can’t just cast a pointer to memory to get access them in C++.
A Baremetal Introduction using C++. Startup.
May 03, 2021 (baremetal,C++,startup)
In the last post, we set up the development environment. This post is about how the RISC-V core executes our program.
How do we go from reset to entering the main()
function in C++ in
RISC-V? Startup code is generally not something you need to worry about,
however, it is of interest when bringing up a device from scratch.
A Baremetal Introduction using C++. Development Environment
April 30, 2021 (baremetal,C++,toolchain)
For this series of posts, my platform is a SiFive HiFive1 Rev B development board. It’s equipped with a 320MHz RV32IMAC (FE310 core). For software build and debug the choice is Platform IO, an IDE integrated into VS Code.
A Baremetal Introduction using C++. Overview.
April 30, 2021 (baremetal,C++)
As described in Part1, a simple C++ application to blink an LED, what does this look like with no operating system?
A Baremetal Introduction using C++. Introduction.
April 30, 2021 (baremetal,C++)
This is a series of posts where I’d like to combine those topics for embedded systems programming. RISC-V and C++ have been evolving rapidly, and you will see modern C++ is a great way to explore RISC-V and develop embedded systems.