Five EmbedDev logo Five EmbedDev

An Embedded RISC-V Blog

RISC-V CSR Access

November 18, 2020 (registers,code,baremetal,quickref)

For baremetal programming I’ll often need to access CSRs, e.g. mstatus.mie for critical sections, mcause in interrupts handlers, etc. Defining function wrappers for accessing these registers creates easier to understand code, however writing these wrappers is pretty tedious.