Skip to main content
Knowledgebase
Home
Renesas Singapore - Knowledgebase

Is it possible to use the C language for direct operations on SFRs?

Latest Updated:11/20/2014

Question:

I am using the RL78/78K0R compiler. Is it possible to use the C language for direct operations on SFRs?

Answer:

When you place the #pragma sfr directive at the beginning of the C-source file as shown below, the names of SFRs can be used in the C source code. The register and bit names in statements take the form of the abbreviations for register names and the bit names in the user's manual for the MCU.

Only those bit names corresponding to bit numbers enclosed by squares in the user's manual for the MCU can be used. In the case of bits for which the numbers are not enclosed by a square, write the bit number after the register name (8-bit registers only).
For details on reserved words in general, refer to the user's manual for the MCU.

(Example)
#pragma sfr
WDTE=0xAC;
PM5.0 = 0 ;

Suitable Products
C Compiler Package for RL78 and 78K Families
Compiler for RL78 Family and 78K0R [CA78K0R]
Compiler for 78K0R [CC78K0R]