Accessing I/O Port Space - Texas Instruments TMS320C2x User Manual

Optimizing c compiler digital signal processor
Hide thumbs Also See for TMS320C2x:
Table of Contents

Advertisement

5.7.2 Accessing I/O Port Space

The ioport keyword enables access to the I/O port space of the
TM320C2x/C2xx/C5x devices. The keyword has the form:
ioport type porthex_num
ioport
is the keyword that indicates this is a port variable.
type
must be char, short, int, or the unsigned variable.
port hex_num
refers to the port number. The hex_num is a hexadecimal
number.
All declarations of port variables must be done at the file level. Port variables
declared at the function level are not supported.
For example, the following code declares the I/O port as unsigned port 10h,
writes a to port 10h, then reads port 10h into b:
ioport unsigned port10; /* variable to access I/O port 10h */
int func ()
{
...
port10 = a;
...
b = port10;
...
}
The use of port variables is not limited to assignments. Port variables can be
used in expressions like any other variable. Following are examples:
call(port10);
/* read port 10h and pass to call
a = port10 + b;
/* read port 10h, add b, assign to a
port10 += a;
/* read port 10h, add a, write to port 10h */
Initializing Static and Global Variables
/* write a to port 10h
/* read port 10h into b
TMS320C2x/C2xx/C5x C Language
*/
*/
*/
*/
5-13

Advertisement

Table of Contents
loading

This manual is also suitable for:

Tms320c2xxTms320c5x

Table of Contents