IT lexicon › Hardware › mcause

mcause

Hardware På svenska → Updated: 2026-11-04

The RISC-V register that explains why the core has just landed in the trap handler.

The top bit says whether it was an interrupt (1) or a synchronous exception (0); the rest is a code. Among exceptions, 2 means illegal instruction, 5 and 7 are load and store access faults, and 8, 9 and 11 are an ecall from U-, S- and M-mode respectively. Among interrupts, 3, 7 and 11 are machine-mode software, timer and external interrupts — the ones delivered by the CLINT and PLIC.

A direct-mode trap handler nearly always opens by reading mcause and switching on it. After a crash, together with mepc and mtval, it is the first clue — roughly what the CFSR is on Cortex-M, without the dozen flags to decode.

← Back to the lexicon