使用例

0x00から開始した変換出力を一定周期毎に0x10ずつ上げて行き、0x0FFFになると変換停止

 

[GUI設定例]

12 ビットD/A コンバータ

DA

使用する

D/Aコンバータ動作設定

使用する

基準電圧

AVDD/AVSS

データ形式

右詰め

DA0を使用

Used

DA1を使用

Unused

D/A A/D同期設定

使用しない

 

タイマ・アレイ・ユニット

TAU0

TAU0

Channel0

 

 

[API設定例]

r_cg_main.c

/* Start user code for global. Do not edit comment generated here */

volatile uint16_t g_12da0_value;

/* End user code. Do not edit comment generated here */

 

void main(void)

{

       R_MAIN_UserInit();

       /* Start user code. Do not edit comment generated here */

       /* Start TAU0 channel 0 counter */

       R_TAU0_Channel0_Start();

 

       /* Set the DA0 converter value */

       g_12da0_value = 0x0000U;

       R_12DA0_Set_ConversionValue((uint8_t)g_12da0_value);

 

       /* Enable the DA0 converter */

       R_12DA0_Start();

 

       while (1U)

       {

              while (TMIF00 == 0U){

              }

              TMIF00 = 0U;

 

              g_12da0_value += 0x0010U;

              if (g_12da0_value <= 0x0FFFU)

              {

                     /* Set the DA0 converter value */

                     R_12DA0_Set_ConversionValue((uint8_t)g_12da0_value);

              }

              else

              {

                     /* Stop the DA0 converter */

                     R_12DA0_Stop();

              }

       }

       /* End user code. Do not edit comment generated here */

}