How Do I Access SFRs?

The compiler ships with header files (see Device Header Files) that define variables that are mapped over memory-mapped SFRs. Since these are C variables, they can be used like any other variable and no new syntax is required to access these registers.

Bits within SFRs can also be directly accessed via structures. Within the structure are bit-field members that allow access to individual elements in the register. Individual single-bit variables are also defined that are mapped over the bits in the SFR, but these should only be used in legacy projects. (see Using SFRs From C Code).

The name assigned to the variable is usually the same as the name specified in the device data sheet. See How Do I Find The Names Used To Represent SFRs And Bits? if these names are not recognized.