Usage example
Start conversion digital input to analog signal from 0x00. Add 0x10 to digital input at fixed interval. Stop conversion when digital input becomes 0xFFF.
[GUI setting example]
12-Bit D/A convertor |
||||
DA |
Used | |||
D/Aconvertor operation setting |
Used | |||
D/A reference voltage setting |
AVDD/AVSS | |||
Data format |
Right-alignment | |||
Use DA0 |
Used | |||
Use DA1 |
Unused | |||
D/A A/D synchronous setting |
Unused |
Timer array unit |
||||
TAU0 |
TAU0 | |||
Channel0 |
||||
[API setting example]
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 */
}