DMA Controller
Am186™CC/CH/CU Microcontrollers User’s Manual
8-23
When the DMA channel is initialized as shown in Table 8-9, transmitting a string is performed
as follows:
1. Copy the string from the source to the buffer at the current write pointer position, being
careful to take buffer wrap into account, and being careful not to overwrite data already
in the buffer which is not yet transmitted. (Whether or not data has been transmitted can
be easily determined by reading the DMA channel’s source address register and
comparing it against the write pointer position.) Calculate a new write pointer position,
and save it in memory to use for subsequent writes.
2. Stop the DMA (reset the ST bit) to ensure that the transfer count is stable.
3. Add the length of the new string to the Transfer Count (GDxTC) register. A read/modify/
write cycle adjusts the GDxTC register, and the write to the register automatically restarts
the DMA (if the AST bit is set).
Interrupts are required for transmit under the following conditions:
■
If the XON/XOFF protocol is used, the DMA must be shut off to transmit flow control
characters, and also to stop transmitting when an XOFF is received. One way this
protocol could work is that when DMA is to be stopped, the AST and ST bits can be
reset; when DMA is to be restarted, both these bits can be set again. If this technique
is used, steps 2 and 3 above (stopping DMA and updating transfer count) should be
performed as an atomic operation (i.e., with interrupts disabled) to avoid conflicts with
the XON/XOFF interrupt handler.
■
If a multitasking system is used, an attempt to write too much data to the buffer should
write as much as possible, and then block the task performing the write until additional
space is available. In this case, the GDxTC register should not be programmed with the
actual count of characters in the buffer, but instead be programmed with the lesser of
the actual count and the amount of space to wait for before restarting the blocked task.
Also, the interrupt bit should be set. When the interrupt occurs, the transfer count should
immediately be reprogrammed to the actual remaining buffer count to avoid delay in
transmission, and the blocked task should be marked as ready to run.
Reception Using Circular Buffers
For the UART, DMA reception using a circular buffer is potentially more useful than
transmission because transferring received characters into a circular buffer can help
improve data integrity. (Characters are never lost due to interrupt latency.)
Like basic transmission, basic reception using a circular buffer is simple. Software maintains
a read pointer into the buffer and can dynamically determine the number of characters
available for reading at any time by reading the destination address, subtracting the read
GDxSRCH
(Source Address High)
DSA[19–16]
Buffer address DIV 64K 0
GDxDSTL
(Destination Address Low)
DDA[15–0]
(H)SPTXD
Buffer address
MOD 64K
GDxDSTH
(Destination Address High)
DDA[19–16]
0
Buffer address DIV 64K
GDxTC
(Transfer Count)
TC
Set to total string length
whenever writes
performed
Set to high-water mark
Table 8-9
Example Register Settings for UARTs and Circular Buffers (Continued)
General-Purpose DMA
Register
Bit(s) in Register
Value for
Transmit DMA
Value for
Receive DMA
Содержание Am186 CC
Страница 1: ...Am186 CC CH CU Microcontrollers User s Manual Order 21914B...
Страница 4: ...iv Am186 CC CH CU Microcontrollers User s Manual...
Страница 18: ...Table of Contents xviii Am186 CC CH CU Microcontrollers User s Manual...
Страница 24: ...Introduction xxiv Am186 CC CH CU Microcontrollers User s Manual...
Страница 39: ...Architectural Overview Am186 CC CH CU Microcontrollers User s Manual 1 15 Figure 1 6 32 Channel Linecard CH CC...
Страница 40: ...Architectural Overview 1 16 Am186 CC CH CU Microcontrollers User s Manual...
Страница 86: ...System Overview 3 36 Am186 CC CH CU Microcontrollers User s Manual...
Страница 92: ...Emulator Support 4 6 Am186 CC CH CU Microcontrollers User s Manual...
Страница 112: ...DRAM Controller 6 8 Am186 CC CH CU Microcontrollers User s Manual...
Страница 134: ...Interrupts 7 22 Am186 CC CH CU Microcontrollers User s Manual...
Страница 186: ...Programmable I O Signals 9 8 Am186 CC CH CU Microcontrollers User s Manual...
Страница 200: ...Watchdog Timer 11 6 Am186 CC CH CU Microcontrollers User s Manual...
Страница 232: ...Asynchronous Serial Ports UARTs 13 24 Am186 CC CH CU Microcontrollers User s Manual...
Страница 242: ...Synchronous Serial Port SSI 14 10 Am186 CC CH CU Microcontrollers User s Manual...
Страница 264: ...High Level Data Link Control HDLC 15 22 Am186 CC CH CU Microcontrollers User s Manual...
Страница 332: ...Universal Serial Bus USB 18 34 Am186 CC CH CU Microcontrollers User s Manual...
Страница 348: ...Register Summary A 16 Am186 CC CH CU Microcontrollers User s Manual...
Страница 376: ...Index Index 18 Am186 CC CH CU Microcontrollers User s Manual...