Example 1 for Using Event Controller

Here is an example of setting the event controller that analog output is performed simultaneously at the same timing of analog input in one device.

First, in order to start analog input and analog output at the same time, set the analog input conversion start signal to be used as the analog output start signal.

1. Set the start condition of analog input

Use function AioSetAiStartTrigger to set the start condition of analog input.
In this example software start is used.

Ret = AioSetAiStartTrigger ( Id , 0 )

2. Set the start condition of analog output

Use function AioSetAoStartTrigger to set the start condition of analog output.
Since the control signal from analog input is used as the start condition, the parameter is 10 (Event controller output).

Ret = AioSetAoStartTrigger ( Id , 10 )

3. Set the event controller

Set the event controller.
The connection destination (Destination) is [Analog output conversion start signal].
The connection source (Source) is [Analog input software start signal].

Ret = AioSetEcuSignal ( Id , AIOECU_DEST_AO_START , AIOECU_SRC_START )

* Note
When the analog input start condition is a condition other than software start,
it is necessary to set a corresponding connection source (Source) of the event controller.
When the analog input start condition is level trigger
Ret = AioSetAiStartTrigger ( Id , 3 )
Ret = AioSetAoStartTrigger ( Id , 10 )
Ret = AioSetEcuSignal ( Id , AIOECU_DEST_AO_START, AIOECU_SRC_AI_LVSTART )

Next, set analog input clock signal to be used as analog output clock signal so that both analog input and output are converted at the same cycle.

4. Set the clock type of analog input

Use function AioSetAiClockType to set the clock type of analog input.
In this example internal clock is used.

Ret = AioSetAiClockType ( Id , 0 )

5. Set the clock type of analog output

Use function AioSetAoClockType to set the clock type of analog output.
Since the control signal from analog input is used as the clock, the parameter is 10 (Event controller output).

Ret = AioSetAoClockType ( Id , 10 )

6. Set the event controller

Set the event controller.
The connection destination (Destination) is [Analog output generating clock].
The connection source (Source) is [Analog input internal clock signal].

Ret = AioSetEcuSignal ( Id , AIOECU_DEST_AO_CLK , AIOECU_SRC_AI_CLK )

In this case, conversion starts from the analog output. In fact, analog output is not performed until analog input conversion starts.

7. Conversion start

Ret = AioStartAo ( Id )
Ret = AioStartAi ( Id )