Using Bus Master Transfer Function

Sampling(Input)/Generating(Output) by using Bus Master Transfer function is explained as follows.

1. Set conditions of Sampling/Generating

Set the conditions of Sampling/Generating after initialization and mode setting,.
The condition of Sampling/Generating contains 3 types: Start Condition Setting which is the condition (Software Start, External Start) set to start Input/Output by DioDmSetStartTrigger, Clock Condition Setting which is the timing (Internal Clock, External Clock and so on) set to perform Input/Output by DioDmSetClockTrigger, and Stop Condition Setting which is the condition (Software Stop, Specification Number Stop and so on ) set to stop Input/Output by DioDmSetStopTrigger.

And, for each setting there are additional condition setting function (for example: set the stop number for the Specification Number Stop and so on).

In the case that data is input/ouput at the same conditions, after the initialization, those Sampling/Generating condition settings are set for one time, thereafter conditions will not be set before input/ouput. In the case that data is transferred by different conditions for each time, the conditions should be modified before transferring.

2. FIFO Reset

The FIFO substance of the last transfer is reset by Reset function (DioDmFifoReset).

3. Set buffer

If data is transferred to the buffer used by the other process, exception error will be occurred in program.
To make sure about the safety of program, the buffer used for bus master transfer should be set to be global.

The motion of transferring provides 1 Time Transfer which is all of the data in the buffer has been transferred completely and Infinite Transfer which is data is transferred repeatedly to the same buffer for infinite times.


 

4. Start

After the conditions of Sampling/Generating is set and buffer is specified, start the motion by DioDmTransferStart.

As the motion is started, if the start condition is satisfied then Sampling/Generating will be started, if the stop condition is satisfied then Sampling/Generating will be stopped. In the case of Software Start, Sampling/Generating is started with the timing when the function DioDmTransferStart is called.

Input data is saved in the FIFO of board, and the data is transferred to memory of application by the timing when bus is free.

Output data is sent to FIFO of board directly, and as the Clock Condition is satisfied, the data is output to external.

5. Stop/Transfer completion

After it is satisfied the Stop Condition which defines with DioDmSetStopTrigger function, Sampling/Generating will be stopped.
Sampling/Generating will be stopped after the number of transferring is reach for Length which defines with DioDmSetBuffer function as well.

And also, Sampling/Generating will be stopped when you call DioDmTransferStop function or it occurs the unexpected error during Bus Master Transfer.

There are 3 kinds of method to catch the stop motion from application as below:

 - To confirm stop by message (DioDmSetStopEvent)
- To confirm stop by callback (DioDmSetStopCallBackProc)
- To monitor the status (DioDmGetStatus)

The basic notification method is message or callback.

To monitor the status, DIODM_STATUS_BMSTOP and DIODM_STATUS_PIOSTOP should be monitored.
However, this method does I/O to the device to check the status, so the transfer rate of the bus master may decrease.

Before starting sampling data processing or preparing for the next transfer, be sure to use one of these methods to confirm that transfer has been completed before starting the next process. (The same applies when using DioDmTransferStop.)

During the transfer motion, the transferred number can be confirmed (DioDmSetCountEvent).

After transfer, (DioDmGetStatus) is used to confirm whether the bus master transfer has completed normally.

And, accessing the device during bus master transfer will hinder bus master transfer.
Therefore, if you call (DioDmGetStatus) frequently or notify by (DioDmSetCountEvent), the transfer rate may be adversely affected.

6. Notes

If the bus master buffer is set using (DioDmSetBuffer) in the thread, when the thread ends, the memory lock is released and the bus master transfer is forcibly stopped. Therefore, do not terminate the thread until the bus master transfer is completed.

When using the bus master transfer function, normal digital input/output functions cannot be used.