<< Chapter < Page | Chapter >> Page > |
The serial port on the back of the DSP box can be used to transmit data between the DSP and the PC during real-time operation. Eight bits ofdata can be transmitted at one time (signed or unsigned). This can then be used as feedback from the DSP for a variety of applications. The serial port isconnected to a data buffer which holds values coming from the DSP until they are read. This allows for sending larger amounts of data (more than 1-byte) at a time from the DSP to the PC.The same is true in the opposite direction.
The serial port data buffer can be written to with either C or assembly code. These functionalities are supplied through the core file, so it must be includedwith any of this code.
Accessing the serial port in assembly comes in the form of macros (READSER and WRITSER). These macros allow for multiple bytes of data to be written to the serial portbuffer at a time.
READSER
: READSER accepts one parameter, an integer number(n). The macro will read n bytes
into memory and place them starting at the address
*AR3
. The macro modifies
AR3
and it is left
pointing to one byte past the last memory location written. The actual number of data bytes read isput into
AR1
. If
AR1
is zero, there were no available data byte sin the buffer. The calling
format is:
READSER n
WRITSER
: Similar to the previous macro, WRITSER takes a single integer parameter n. This macro will add
n bytes starting at
*AR3
to the serial port buffer.
*AR3
is left pointing one location after the last memory read. This data is queued in the buffer and will
remain there until the PC retrieves the data. The calling format is:
WRITSER n
The core file allows up to 126 characters to be stored in the input and output buffers.
No checks to protect against buffer overflows are made, so do not allow the input and outputbuffers to overflow. (The length of the buffers can be changed by changing
ser_rxlen
and
ser_txlen
values in the core.asm file.) The buffers are 127 characters long; however,
the code cannot distinguish between a completely-full and completely-empty buffer.Therefore, only 126 characters can be stored in the buffers.
It is easy to check if the input or output buffers in memory are empty.
The input buffer can be checked by comparing the values stored in the memorylocations
srx_head
and
srx_tail
; if both memory locations hold the same value,
the input buffer is empty. Likewise, the output buffer can be checked by comparingthe values stored in memory locations
stx_head
and
stx_tail
. The number of characters
in the buffer can be computed by subtracting the head pointer from the tail pointer;add the length of the buffer (normally 127) if the resulting distance is negative.
Notification Switch
Would you like to follow the 'Digital signal processing laboratory (ece 420)' conversation and receive update notifications?