78
M2i.30xx / M2i.30xx-exp Manual
Buffer handling
Acquisition modes
area.
• As shown in the drawing above the DMA control will announce new data to the application by sending an event. Waiting for an event is
done internally inside the driver if the application calls one of the wait functions. Waiting for an event does not consume any CPU time
and is therefore highly desirable if other threads do a lot of calculation work. However it is not necessary to use the wait functions and
one can simply request the current status whenever the program has time to do so. When using this polling mode the announced avail-
able bytes still stick to the defined notify size!
• If the on-board FIFO buffer has an overrun (card to PC) or an underrun (PC to card) data transfer is stopped. However in case of transfer
from card to PC there is still a lot of data in the on-board memory. Therefore the data transfer will continue until all data has been trans-
ferred although the status information already shows an overrun.
• Getting best bus transfer performance is done using a „continuous buffer“. This mode is explained in the appendix in greater detail.
The Notify size sticks to the page size which is defined by the PC hardware and the operating system. There-
fore the notify size must be a multiple of 4 kByte. For data transfer it may also be a fraction of 4k in the
range of 16, 32, 64, 128, 256, 512, 1k or 2k. No other values are allowed. For ABA and timestamp the notify
size can be 2k as a minimum. If you need to work with ABA or timestamp data in smaller chunks please use the
polling mode as described later.
The following graphs will show the current buffer positions in different states of the transfer. The drawings have been made for the transfer
from card to PC. However all the block handling is similar for the opposite direction, just the empty and the filled parts of the buffer are
inverted.
Step 1: Buffer definition
Directly after buffer definition the complete buffer is empty (card to PC) or
completely filled (PC to card). In our example we have a notify size which
is 1/4 of complete buffer memory to keep the example simple. In real
world use it is recommended to set the notify size to a smaller stepsize.
Step 2: Start and first data available
In between we have started the transfer and have waited for the first data
to be available for the user. When there is at least one block of notify size
in the memory we get an interrupt and can proceed with the data. Any
data that already was transferred is announced. The USER_POS is still
zero as we are right at the beginning of the complete transfer.
Step 3: set the first data available for card
Now the data can be processed. If transfer is going from card to PC that
may be storing to hard disk or calculation of any figures. If transfer is go-
ing from PC to card that means we have to fill the available buffer again
with data. After the amount of data that has been processed by the user
application we set it available for the card and for the next step.
Step 4: next data available
After reaching the next border of the notify size we get the next part of the
data buffer to be available. In our example at the time when reading the
USER_LEN even some more data is already available. The user position
will now be at the position of the previous set CARD_LEN.
Step 5: set data available again
Again after processing the data we set it free for the card use.
In our example we now make something else and don’t react to the inter-
rupt for a longer time. In the background the buffer is filled with more da-
ta.
Step 6: roll over the end of buffer
Now nearly the complete buffer is filled. Please keep in mind that our cur-
rent user position is still at the end of the data part that we processed and
marked in step 4 and step 5. Therefore the data to process now is split in
two parts. Part 1 is at the end of the buffer while part 2 is starting with
address 0.
Step 7: set the rest of the buffer available
Feel free to process the complete data or just the part 1 until the end of
the buffer as we do in this example. If you decide to process complete
buffer please keep in mind the roll over at the end of the buffer.
This buffer handling can now continue endless as long as we manage to
set the data available for the card fast enough. The USER_POS and USER_LEN for step 8 would now look exactly as the buffer shown in step 2.