Real Time Devices AD1200 User Manual page 58

Table of Contents

Advertisement

In Pascal:
Segment ::
SEG(Buffer),'
Offset
:= OFS(Buffer);
Linear
Address
:= Segrment
Page := LinearAddress
DfV
PageOffset
:= LinearAddress
MOD 65536,.
In C:
segn€nt = FP_SEG(&Buffer) ;
offset
= FP_OFS (eBuffer)
,.
linear_address
= segrEnt
* 16 * offset,.
page = linear_address
,/ 55536,'
page_offset
= l"j-near_address
* 55536,.
In BASIC:
s = VARSEG(BUFFER)
O : VARPTR(BT]FT'ER)
L A = S * 1 6 + O
P A G E = I N T ( L A l 5 5 5 3 6 )
P O F T = L A - ( P A @ * 6 5 5 3 6 )
I
{
t
{
get
segnent
of buffer
)
get offset
of buffer
)
calculate
a linear
address
)
deterrnine
page corresponding
to this
linear
address
)
determine
offset
into
the
paSe )
1* qet se$nent
of buffer
*/
1* geL offset
of buffer
*,/
/*
calculate
a linear
address
*/
/*
deterrnine
page corresponding
to this
linear
address
*/
/*
deterrnine
offset
into
the
page */
* 16 + Offset,-
65535,.
Beware! There is one big catch when using page-based addresses. The DMA controller cannot write properly to
a buffer that 'straddles' a page boundary. A buffer straddles a page boundary if one part of the buffer resides in one
page of memory while anotier part resides in the following page. The DMA controller cannot properly write to such
a buffer because the DMA controller can only write to one page without reprognmming. When it reaches the end of
the current page, it does not start writing to the next page. Instead, it starts writing back at the first byte of ttre
culrent page. This can be disasEous if the beginning of the page does not correspond to your buffer. More often than
not, this location is being used by the code portion of your prograrn or the operating system, and writing data to it
will almost always causes erratic behavior and an eventual system crash.
You must check to see if your buffer sraddles a page boundary and, if it does, take action to prevent ttre DMA
controller from rying to write to the portion that continues on the next page You can reduce the size of the buffer or
!T [o reposition the buffer. However, this can be difficult when using large satic data strucnres, and often, the only
solution is to use dynamically allocated memory.
. Setting the DMA Page Register
Oddly enough, you do not inform ttre DMA conroller directly of the page to be used. Instead, you put ttre page
to be used into the DMA page register which is sepante from the DMA controller, as shown in the table below. The
location of this register depends on the DMA channel being used.
DMA Channel
Locatlon of Page Register
1
83(131 )
3
82(130)
4-2r

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ada1200

Table of Contents