Hardware Reference
In-Depth Information
bne
nc
; no, continue
dex
; decrement the input buffer pointer
ldaa
#WS
; wipe out the previous character
jsr
putch
ldaa
#BS
jsr
putch
bra
gets
nc
inx
bra
gets
qi
clr
0,x
; terminate the string by a NULL character
rts
The C language version of the function is as follows:
int gets(char *ptr)
{
char cx;
while ((cx 5 getch()) ! 5 0x0D) {
*ptr 5 cx;
putch(cx);
if (cx 55 0x08) {
// is it a backspace character?
ptr 22 ;
// move back the string pointer
putch(0x20);
// output a space
putch(0x08);
// output another backspace character
}
ptr 11 ;
// move buffer pointer
}
*ptr 5 0;
// terminate the string with a NULL character
return 0;
}
9.10 Summary
When high-speed data transfer is not necessary, using serial data transfer enables the chip
designer to make the most use of the limited number of I/O pins. Serial data transfer can be per-
formed asynchronously or synchronously. The SCI interface is an asynchronous interface that
is designed to be compatible with the TIA-232 standard. The TIA-232 standard has four aspects:
electrical, mechanical, procedural, and functional. For a short distance, modems are not needed
for two computers to communicate. A connection called null modem is used instead . This is
achieved by connecting signals in such a way as to fool two computers into thinking that they
are connected through modems.
Since there is no common clock signal for data transfer synchronization, devices participat-
ing in communication must agree on a common data rate before data exchange is started. Users
of the TIA-232 standard follow a common data format: Each character is framed with a start bit
and a stop bit. A character can have 8 or 9 data bits. The ninth bit is often used as a parity bit
for error checking or an address mark to alert the receiver to perform address comparison. The
receiver uses a clock signal with a frequency that is 16 times the data rate to sample the RxD
pin to detect the start bit and determine the logic values of data bits.
 
Search WWH ::




Custom Search