Download CubeSuite Ver.1.30 Integrated Development Environment 78K0

Transcript
CubeSuite Ver.1.30
2.4
CHAPTER 2 FUNCTIONS
Using Microcontroller Functions
This section explains using microcontroller functions.
2.4.1
Accessing special function registers (SFR) from C
(1) Setting each register of SFR
The SFR area are a area of group of special function registers, such as mode and control registers for the
peripheral hardware of 78K microcontrollers (PM1, P1, TMC80, etc.).
To use the SFR area from C, place the #pragma sfr at the start of C source file. This declares the name of each
SFR register. The sfr keyword can be either uppercase or lowercase.
#pragma sfr
The following error message appears if attempt to use the SFR area without declaring the register names.
E0711 Undeclared 'variable-name' ; function 'function-name'
The symbols made available by the #pragma sfr directive are the same as the abbreviations given in the list of
special function registers.
If #pragma PC (processor type) is specified, however, describe #pragma sfr after that.
The following items can be described before #pragma sfr:
- Comments
- Preprocessor directive which does neither define nor refer to a variable or a function
In the C source, simply use the sfr names supported by the target device. The sfr names do not need to be
declared individually.
SFR names are external variables with no initial values (irregularity).
A compiler error occurs if assign invalid constant data to an SFR name.
Remark
See "How to use the sfr area (sfr)".
(2) Specifying bits in SFR registers
As shown below, specify bits in SFR registers by using reserved names or by using the "register-name.bitposition".
Examples 1.
Starting TM1
TCE1 = 1 ;
or
TMC1.0 = 1 ;
2.
Stopping TM1
TCE1 = 0 ;
or
TMC1.0 = 0 ;
R20UT0004EJ0100 Rev.1.00
Jul 01, 2010
Page 34 of 822