![background image](http://html2.mh-extra.com/html/rabbit/2000/2000_user-manual_3110256176.webp)
170
Rabbit 2000 Microprocessor
17.2 Reading and Writing I/O Registers
The Rabbit has two I/O spaces: internal I/O registers and external I/O registers.
17.2.1 Using Assembly Language
The fastest way to read and write I/O registers in Dynamic C is to use a short segment of
assembly language inserted in the C program. Access is the same as for accessing data
memory except that the instruction is preceded by a prefix (
ioi
or
ioe
) to indicate the
internal or external I/O space.For example.
// compute value and write to Port A Data Register
value=x+y
#asm
ld a,(value) ; value to write
ioi ld (PADR),a ; write value to PADR
#endasm
In the example above the
ioi
prefix changes a store to memory to a store to an internal
I/O port. The prefix
ioe
is used for writes to external I/O ports.
17.2.2 Using Library Functions
Dynamic C functions are available to read and write I/O registers. These functions are pro-
vided for convenience. For speed, assembly code is recommended. For a complete
description of the functions noted in this section, refer to the
Dynamic C User’s Manual
or from the
Help
menu in Dynamic C, access the
HTML Function Reference
or
Function Lookup
options.
To read internal I/O registers, there are two functions.
int RdPortI(int PORT) ; // returns PORT, high byte zero
int BitRdPortI(int PORT, int bitcode); // bit code 0-7
To write internal I/O registers, there are two functions.
void WrPortI(int PORT, char *PORTShadow, int value);
void BitWrPortI(int PORT, char *PORTShadow, int value, int bitcode);
The external registers are also accessible with Dynamic C functions.
int RdPortE(int PORT) ; // returns PORT, high byte zero
int BitRdPortE(int PORT, int bitcode); // bit code 0-7
int WrPortE(int PORT, char *PORTShadow, int value);
int BitWrPortE(int PORT, char *PORTShadow, int value, int bitcode);
In order to read a port the following code could be used:
k=RdPortI(PADR); // returns Port A Data Register
Summary of Contents for 2000
Page 1: ...Rabbit 2000 Microprocessor User s Manual 019 0069 041018 M...
Page 12: ...6 Rabbit 2000 Microprocessor...
Page 46: ...40 Rabbit 2000 Microprocessor...
Page 54: ...48 Rabbit 2000 Microprocessor...
Page 76: ...70 Rabbit 2000 Microprocessor...
Page 96: ...90 Rabbit 2000 Microprocessor...
Page 142: ...136 Rabbit 2000 Microprocessor...
Page 154: ...148 Rabbit 2000 Microprocessor...
Page 170: ...164 Rabbit 2000 Microprocessor...
Page 174: ...168 Rabbit 2000 Microprocessor...
Page 180: ...174 Rabbit 2000 Microprocessor...
Page 202: ...196 Rabbit 2000 Microprocessor...
Page 206: ...200 Rabbit 2000 Microprocessor...
Page 226: ......
Page 230: ...224 Rabbit 2000 Microprocessor...