You copied the Doc URL to your clipboard.

Writing to the System Handler Control and State Register

Article ID: 103487961

Published date: 13 Feb 2018

Last updated: -

Applies to: Cortex-M3, Cortex-M4, Cortex-M7

Question

How should I write to the System Handler Control and State Register?

Answer

Be careful not to corrupt the state of the System Handler Control and State Register (SHCSR). Although all of the defined bits are writable, the most common reason for writing to this register is to enable the faults defined in bits[18:16]. Other uses, involving writes to the 'state' bits in the lower Halfword, include a System handler converting itself from one type to another.

It is good practice to perform read-modify-write accesses to write to the SHCSR. If only one code routine will perform such writes, then you can use a simple read-modify-write. If there is more than one routine that might write to the SHCSR, then you should use some form of mutex to prevent the possibility of interleaved read-modify-write operations resulting from an exception arriving between the read and the write portions of one read-modify-write.

If only the Enable bits[18:16] are being written, a Halfword write to the upper Halfword can be used.

Related information

N/A

Was this page helpful? Yes No