Example 1 for Using Event Controller

The following shows an event controller setting example when analog input is performed at the same timing as analog output within a single device.

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

1.Set analog output start condition

The analog output start condition uses the AioSetAoStartTrigger function.
In this example, software start is used.

Ret = AioSetAoStartTrigger ( Id , 0 )

2.Set analog input start condition

The analog input start condition uses the AioSetAiStartTrigger function.
The start condition uses the control signal from the analog output, so the parameter is 10 event controller outputs.

Ret = AioSetAiStartTrigger ( Id , 10 )

 

3.Set event controller

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

Ret = AioSetEcuSignal ( Id , AIOECU_DEST_AI_START , AIOECU_SRC_START )

※Reference
If the analog output start condition is a condition other than a software start,
It is also necessary to set the connection source (Source) of the event controller.
When analog output start condition is rising edge of external trigger

Ret = AioSetAoStartTrigger ( Id , 1 )
Ret = AioSetAiStartTrigger ( Id , 10 )
Ret = AioSetEcuSignal ( Id , AIOECU_DEST_AI_START , AIOECU_SRC_AO_TRGSTART )

 

Secondly, set the analog output clock signal to be used as the analog input clock signal in order to convert both analog input and output at the same cycle.

4.Sets the analog output clock type

Use the AioSetAoClockType function for the analog output clock type.
In this example, the internal clock is used.

Ret = AioSetAoClockType ( Id , 0 )

5.Sets the analog input clock type

Use the AioSetAiClockType function for the analog input clock type.
Since the clock used uses the control signal from the analog output, the parameter is 10 event controller output.

Ret = AioSetAiClockType ( Id , 10 )

6.Set event controller

Set the event controller.
The connection destination (Destination) is the analog input sampling clock period,
The connection source (Source) is the analog output internal clock signal.

Ret = AioSetEcuSignal ( Id , AIOECU_DEST_AI_CLK , AIOECU_SRC_AO_CLK )

 

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

7.Set analog output stop condition

The analog output stop condition uses the AioSetAoStopTrigger function.
In this example, it is stopped by the Stop conversion by the specified times. (FIFO memory)

Ret = AioSetAoStopTrigger ( Id , 0 )

8.Set analog input stop condition

The analog input stop condition uses the AioSetAiStopTrigger function.
The stop condition uses the control signal from the analog output, so the parameter is 10 event controller outputs.

Ret = AioSetAiStopTrigger ( Id , 10 )

 

9.Set event controller

Set the event controller.
The connection destination (Destination) is Analog input conversion stop signal,
The connection source (Source) is Analog output specified times output stop signal (Use FIFO).

Ret = AioSetEcuSignal ( Id , AIOECU_DEST_AI_STOP , AIOECU_SRC_AO_STOP_FIFO )

 

 

With the above settings, the start condition/clock condition/stop condition settings and event controller setting preparations are complete.

Conversion is started from analog input, and then analog output conversion is started. If you start converting the analog output first, the conversion of the analog input may not occur.

10.Start conversion

Ret = AioStartAi ( Id )

Ret = AioStartAo ( Id )

 

 

Analog input/output is started, and analog input is stopped when the specified number of outputs is reached.