5 Serial Ports
5 – 6
configuration registers: write a register to an immediate address
(instruction type 3) or write immediate data to an indirect address
(instruction type 2). With either method, it is important to configure the
serial port before enabling it.
The first method of programming configuration registers requires no
setup of DAG registers but does require two instructions to perform the
write. For example:
AX0 = 0x6B27;
DM(0x3FF2) = AX0;
{the contents of AX0 are written}
{to the address 0x3FF2}
AX0 = 0;
DM(0x3FF3) = AX0;
{the contents of AX0 are written}
{to address 0x3FF3}
In the second method, the DAG (I) index register must contain the data
memory address of the configuration register to be written. The modify
(M) register, which updates the I register after the write, must also contain
a valid value. And the length (L) register that has the same number as the
I register must be initialized to zero so that the circular buffer capability is
not active. For example:
I0 = 0x3FF2;
M0 = 1;
L0 = 0;
DM(I0,M0) = 0x6B27;
{the constant 0x6B27 is written to
}
{address pointed to by I0; pointer
}
{then modified by M0}
DM(I0,M0) = 0;
{address 0x3FF3 is set to 0}
Either method works. The second method requires only one cycle to
configure the registers once the I, M and L registers are initialized. This
method is, however, more prone to error because the registers are written
indirectly. You must make sure that the I register contains the intended
value before the write.
5.3.2
Receiving And Transmitting Data
Each SPORT has a receive register and a transmit register. These registers
are not memory mapped, but are identified by assembler mnemonics. The
transmit registers are named TX0 and TX1, for SPORT0 and SPORT1
respectively. Receive registers are named RX0 and RX1 for SPORT0 and
SPORT1 respectively. These registers can be accessed at any time during
program execution using a data memory access with immediate address,