EasyManua.ls Logo

Rabbit 2000 - Reading and Writing I;O Registers; Using Assembly Language; Using Library Functions

Rabbit 2000
230 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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 Users 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

Table of Contents

Other manuals for Rabbit 2000